╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ thread.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2609 .remove => try self.submitRemove(allocator), 2610 } 2611 } 2612 2613 fn submitRemove(self: *This, allocator: std.mem.Allocator) !void { 2614 const comment = self.data.comment_id.len != 0; 2615 const event_id = if (comment) self.data.comment_id else self.data.selected_id; 2616 const id = evt.parseEventId(event_id) catch return; 2617 try self.removeEvent(allocator, if (comment) .comment else kind, id); 2618 } 2619 2620 fn removeEvent(self: *This, allocator: std.mem.Allocator, event_kind: evt.EventKind, id: [evt.event_id_size]u8) !void { 2621 if (comptime wasm) return; 2622 2623 if (comptime supports_drafts) { 2624 const selected = self.data.selectedThread() orelse return; 2625 if (event_kind == kind and entryDraft(selected.*)) { 2626 try Data.removeDraft(self.session, allocator, &id); 2627 const route = draftsRoute(self.data.identity) orelse return; 2628 try self.session.navigate(route); 2629 return; 2630 } 2631 } 2632 2633 const io = self.session.io orelse return; 2634 const src = self.data.repo_source orelse return; 2635 const author = (try self.session.eventAuthor()) orelse return; 2636 2637 switch (src.repo_kind) { 2638 inline else => |repo_kind| { 2639 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2640 defer any_repo.deinit(io, allocator); 2641 switch (any_repo) { 2642 inline else => |*repo| try evt.remove(.repo, repo_kind, repo.self_repo_opts, io, allocator, repo, &id, event_kind, author), 2643 } 2644 }, 2645 } 2646 2647 const id_hex = std.fmt.bytesToHex(id, .lower); 2648 const route = ui.RoutablePage.repoEventsRoute(self.data.identity, .removed, event_kind, &id_hex) orelse return; 2649 try self.session.navigate(route); 2650 } 2651 2652 // return to the list. 2653 fn focusList(self: *This, index: usize, root_focus: *Focus) void { 2654 root_focus.setFocus(self.listScroll(index).getFocus().id); 2655 } 2656 2657 // cross to the header tabs above the stack. 2658 fn focusHeader(self: *This, root_focus: *Focus) void { 2659 root_focus.setFocus(self.box.children.keys()[header_index]); 2660 } 2661 2662 pub fn clearGrid(self: *This) void { 2663 self.box.clearGrid(); 2664 } 2665 2666 pub fn getGrid(self: This) ?Grid { 2667 return self.box.getGrid(); 2668 } 2669 2670 pub fn getFocus(self: *This) *Focus { 2671 return self.box.getFocus(); 2672 } 2673 2674 // for the parent's "scroll up at the top jumps to the header" check: at the 2675 // top only while the header tabs hold focus, so up from the split 2676 // crosses into the tabs first. 2677 pub fn getSelectedIndex(self: *This) ?usize { 2678 return if (self.headerActive()) 0 else 1; 2679 } 2680 }; 2681 } 2682