╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ thread.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
3313 } 3314 3315 fn removeEvent(self: *This, allocator: std.mem.Allocator, event_kind: evt.EventKind, id: [evt.event_id_size]u8) !void { 3316 if (comptime wasm) return; 3317 const actor = (try self.session.authorize(self.data.identity, .read, kind)) orelse return; 3318 const author = actor.author; 3319 3320 if (comptime supports_drafts) { 3321 const selected = self.data.selectedThread() orelse return; 3322 if (event_kind == kind and entryDraft(selected.*)) { 3323 try Data.removeDraft(self.session, allocator, author, &id); 3324 const route = draftsRoute(self.data.identity) orelse return; 3325 try self.session.navigate(route); 3326 return; 3327 } 3328 } 3329 3330 const io = self.session.io orelse return; 3331 const src = self.data.repo_source orelse return; 3332 if (!try src.canModify(io, allocator, actor, event_kind, &id)) return; 3333 const thread_id = evt.parseEventId(self.data.selected_id) catch return; 3334 3335 switch (src.repo_kind) { 3336 inline else => |repo_kind| { 3337 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 3338 defer any_repo.deinit(io, allocator); 3339 switch (any_repo) { 3340 inline else => |*repo| try evt.removeInThread(self.session.eventHost(), repo_kind, repo.self_repo_opts, io, allocator, repo, kind, &thread_id, event_kind, &id, author), 3341 } 3342 }, 3343 } 3344 3345 const id_hex = std.fmt.bytesToHex(id, .lower); 3346 const route = ui.RoutablePage.repoEventsRoute(self.data.identity, .removed, event_kind, &id_hex, null) orelse return; 3347 try self.session.navigate(route); 3348 } 3349 3350 // enter the detail pane, landing on the way back to the list when it shows 3351 fn focusDetail(self: *This, index: usize, root_focus: *Focus) void { 3352 if (widget.listBackId(self.detailFrame(index)) != null) return widget.focusListBack(self.detailFrame(index), root_focus); 3353 _ = self.detail(index).focusFirst(root_focus); 3354 } 3355 3356 // return to the list. 3357 fn focusList(self: *This, index: usize, root_focus: *Focus) void { 3358 root_focus.setFocus(self.listScroll(index).getFocus().id); 3359 } 3360 3361 // cross to the header tabs above the stack. 3362 fn focusHeader(self: *This, root_focus: *Focus) void { 3363 root_focus.setFocus(self.box.children.keys()[header_index]); 3364 } 3365 3366 pub fn clearGrid(self: *This) void { 3367 self.box.clearGrid(); 3368 } 3369 3370 pub fn getGrid(self: This) ?Grid { 3371 return self.box.getGrid(); 3372 } 3373 3374 pub fn getFocus(self: *This) *Focus { 3375 return self.box.getFocus(); 3376 } 3377 3378 // for the parent's "scroll up at the top jumps to the header" check: at the 3379 // top only while the header tabs hold focus, so up from the split 3380 // crosses into the tabs first. 3381 pub fn atTop(self: *This) bool { 3382 return self.headerActive(); 3383 } 3384 }; 3385 } 3386