MCPcopy
hub / github.com/monkeytypegame/monkeytype / setSnapshot

Function setSnapshot

frontend/src/ts/db.ts:47–77  ·  view source on GitHub ↗
(
  newSnapshot: Snapshot | undefined,
  options?: { dispatchEvent?: boolean },
)

Source from the content-addressed store, hash-verified

45}
46
47export function setSnapshot(
48 newSnapshot: Snapshot | undefined,
49 options?: { dispatchEvent?: boolean },
50): void {
51 const originalBanned = dbSnapshot?.banned;
52 const originalVerified = dbSnapshot?.verified;
53 const lbOptOut = dbSnapshot?.lbOptOut;
54
55 //not allowing user to override these values i guess?
56 try {
57 delete newSnapshot?.banned;
58 } catch {}
59 try {
60 delete newSnapshot?.verified;
61 } catch {}
62 try {
63 delete newSnapshot?.lbOptOut;
64 } catch {}
65 dbSnapshot = newSnapshot;
66 if (dbSnapshot) {
67 dbSnapshot.banned = originalBanned;
68 dbSnapshot.verified = originalVerified;
69 dbSnapshot.lbOptOut = lbOptOut;
70 }
71
72 if (options?.dispatchEvent !== false) {
73 authEvent.dispatch({ type: "snapshotUpdated", data: { isInitial: false } });
74 }
75
76 setSolidSnapshot(newSnapshot);
77}
78
79export async function initSnapshot(): Promise<Snapshot | false> {
80 //send api request with token that returns tags, presets, and data needed for snap

Callers 8

EditProfileFunction · 0.90
showUnlinkDiscordModalFunction · 0.90
applyFunction · 0.90
updateLbMemoryFunction · 0.85
saveLocalResultFunction · 0.85
addXpFunction · 0.85
updateInboxUnreadSizeFunction · 0.85
addBadgeFunction · 0.85

Calls 1

dispatchMethod · 0.80

Tested by

no test coverage detected