Convert UUID to class

This commit is contained in:
Jim Hamill
2025-04-11 00:25:48 +00:00
parent 7a03bc2c3d
commit 2fea14522f
3 changed files with 371 additions and 32 deletions
+4 -4
View File
@@ -3,7 +3,7 @@
// Jason mentions pruning, but I don't quite understand how that will be done yet.
// He also has the concept of "extensions" - but I'm not sure this has been fleshed out yet.
import { generateUUIDV7, getTimestampFromUUID } from '../utils';
import { UUIDV7 } from '../utils';
import { BaseStore } from '../storage';
// TODO: Think about different activities
@@ -200,7 +200,7 @@ export class Activities {
timestamp,
};
const key = generateUUIDV7(timestamp);
const key = UUIDV7.fromTimestamp(timestamp).toString();
await this.store.set(key, activityWithTimestamp);
// Note: We don't need to call processActivity here as the 'set' event will trigger it
}
@@ -221,8 +221,8 @@ export class Activities {
// Sort activities by timestamp using UUID v7's embedded timestamp
const activitiesSorted = filteredEntries.sort(([keyA], [keyB]) => {
const timestampA = getTimestampFromUUID(keyA);
const timestampB = getTimestampFromUUID(keyB);
const timestampA = UUIDV7.from(keyA).getTimestamp();
const timestampB = UUIDV7.from(keyB).getTimestamp();
return Number(timestampA - timestampB);
});