╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Notify.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
73 74 var record = record_maybe orelse try evt.removedRecord(Record, DB, hash_kind, haxy_moment.readOnly(), existing_maybe); 75 76 if (!record.removed) try validate(event_id, record); 77 78 if (existing_maybe) |existing| { 79 // updates preserve the original creation metadata 80 record.created_order = existing.created_order; 81 } 82 83 const notify_cursor = try records.putCursor(notify_key); 84 try evt.upsert(Record, DB, hash_kind, try DB.HashMap(.read_write).init(notify_cursor), record); 85 try evt.indexEvent(DB, hash_kind, haxy_moment, event_id, .notify, existing_maybe, record); 86 87 // the id set retains removed records so merges can carry removals 88 if (existing_cursor_maybe == null) { 89 const ids = try DB.SortedSet(.read_write).init(try haxy_moment.putCursor(hash.hashInt(hash_kind, all_id_set_key))); 90 try ids.put(&evt.orderKeyDesc(record.created_order, event_id)); 91 } 92 } 93 94 // the user's mode for the thread, or null without a record 95 pub fn readMode( 96 comptime DB: type, 97 comptime hash_kind: hash.HashKind, 98 haxy_moment: DB.HashMap(.read_only), 99 arena: *std.heap.ArenaAllocator, 100 repo_id: *const [evt.event_id_size]u8, 101 thread_id: *const [evt.event_id_size]u8, 102 ) !?Mode { 103 const record = (try evt.readRecordSubset(Self, struct { removed: bool, event: struct { mode: Mode } }, DB, hash_kind, haxy_moment, arena, &idOf(repo_id, thread_id))) orelse return null; 104 return if (record.removed) null else record.event.mode; 105 } 106