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