mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
getNextActionId() util fn
This commit is contained in:
parent
007c2391f1
commit
5fa65107c9
@ -287,6 +287,24 @@ function makeConnRoute(conn: string): string {
|
||||
return "conn:" + conn;
|
||||
}
|
||||
|
||||
let lastTimestamp = 0;
|
||||
let counter = 0;
|
||||
|
||||
// guaranteed to be monotonically increasing for each call within the same tab
|
||||
function getNextActionId(): string {
|
||||
const now = Date.now();
|
||||
|
||||
if (now === lastTimestamp) {
|
||||
counter += 1;
|
||||
} else {
|
||||
lastTimestamp = now;
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
const paddedCounter = String(counter).padStart(5, "0");
|
||||
return `${now}:${paddedCounter}`;
|
||||
}
|
||||
|
||||
export {
|
||||
atomWithDebounce,
|
||||
atomWithThrottle,
|
||||
@ -295,6 +313,7 @@ export {
|
||||
boundNumber,
|
||||
countGraphemes,
|
||||
fireAndForget,
|
||||
getNextActionId,
|
||||
getPrefixedSettings,
|
||||
getPromiseState,
|
||||
getPromiseValue,
|
||||
|
Loading…
Reference in New Issue
Block a user