mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-22 16:48: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;
|
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 {
|
export {
|
||||||
atomWithDebounce,
|
atomWithDebounce,
|
||||||
atomWithThrottle,
|
atomWithThrottle,
|
||||||
@ -295,6 +313,7 @@ export {
|
|||||||
boundNumber,
|
boundNumber,
|
||||||
countGraphemes,
|
countGraphemes,
|
||||||
fireAndForget,
|
fireAndForget,
|
||||||
|
getNextActionId,
|
||||||
getPrefixedSettings,
|
getPrefixedSettings,
|
||||||
getPromiseState,
|
getPromiseState,
|
||||||
getPromiseValue,
|
getPromiseValue,
|
||||||
|
Loading…
Reference in New Issue
Block a user