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