╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ thread.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
3282 } 3283 3284 fn submitRemove(self: *This, allocator: std.mem.Allocator) !void { 3285 const comment = self.data.comment_id.len != 0; 3286 const event_id = if (comment) self.data.comment_id else self.data.selected_id; 3287 const id = evt.parseEventId(event_id) catch return; 3288 try self.removeEvent(allocator, if (comment) .comment else kind, id); 3289 } 3290 3291 fn removeEvent(self: *This, allocator: std.mem.Allocator, event_kind: evt.EventKind, id: [evt.event_id_size]u8) !void { 3292 if (comptime wasm) return; 3293 const actor = (try self.session.authorize(self.data.identity, .read, kind)) orelse return; 3294 const author = actor.author; 3295 3296 if (comptime supports_drafts) { 3297 const selected = self.data.selectedThread() orelse return; 3298 if (event_kind == kind and entryDraft(selected.*)) { 3299 try Data.removeDraft(self.session, allocator, author, &id); 3300 const route = draftsRoute(self.data.identity) orelse return; 3301 try self.session.navigate(route); 3302 return; 3303 } 3304 } 3305 3306 const io = self.session.io orelse return; 3307 const src = self.data.repo_source orelse return; 3308 if (!try src.canModify(io, allocator, actor, event_kind, &id)) return; 3309 const thread_id = evt.parseEventId(self.data.selected_id) catch return; 3310 3311 switch (src.repo_kind) { 3312 inline else => |repo_kind| { 3313 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 3314 defer any_repo.deinit(io, allocator); 3315 switch (any_repo) { 3316 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), 3317 } 3318 }, 3319 } 3320 3321 const id_hex = std.fmt.bytesToHex(id, .lower); 3322 const route = ui.RoutablePage.repoEventsRoute(self.data.identity, .removed, event_kind, &id_hex, null) orelse return; 3323 try self.session.navigate(route); 3324 } 3325 3326 // enter the detail pane, landing on the way back to the list when it shows 3327 fn focusDetail(self: *This, index: usize, root_focus: *Focus) void { 3328 if (widget.listBackId(self.detailFrame(index)) != null) return widget.focusListBack(self.detailFrame(index), root_focus); 3329 _ = self.detail(index).focusFirst(root_focus); 3330 } 3331 3332 // return to the list. 3333 fn focusList(self: *This, index: usize, root_focus: *Focus) void { 3334 root_focus.setFocus(self.listScroll(index).getFocus().id); 3335 } 3336 3337 // cross to the header tabs above the stack. 3338 fn focusHeader(self: *This, root_focus: *Focus) void { 3339 root_focus.setFocus(self.box.children.keys()[header_index]); 3340 } 3341 3342 pub fn clearGrid(self: *This) void { 3343 self.box.clearGrid(); 3344 } 3345 3346 pub fn getGrid(self: This) ?Grid { 3347 return self.box.getGrid(); 3348 } 3349 3350 pub fn getFocus(self: *This) *Focus { 3351 return self.box.getFocus(); 3352 } 3353 3354 // for the parent's "scroll up at the top jumps to the header" check: at the 3355 // top only while the header tabs hold focus, so up from the split 3356 // crosses into the tabs first. 3357 pub fn atTop(self: *This) bool { 3358 return self.headerActive(); 3359 } 3360 }; 3361 } 3362