╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ thread.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2698 const route = listRoute(self.data.identity, merged, "", entry.id) orelse return; 2699 try self.session.navigate(route); 2700 } else unreachable, 2701 .remove => try self.submitRemove(allocator), 2702 } 2703 } 2704 2705 fn submitRemove(self: *This, allocator: std.mem.Allocator) !void { 2706 const comment = self.data.comment_id.len != 0; 2707 const event_id = if (comment) self.data.comment_id else self.data.selected_id; 2708 const id = evt.parseEventId(event_id) catch return; 2709 try self.removeEvent(allocator, if (comment) .comment else kind, id); 2710 } 2711 2712 fn removeEvent(self: *This, allocator: std.mem.Allocator, event_kind: evt.EventKind, id: [evt.event_id_size]u8) !void { 2713 if (comptime wasm) return; 2714 2715 if (comptime supports_drafts) { 2716 const selected = self.data.selectedThread() orelse return; 2717 if (event_kind == kind and entryDraft(selected.*)) { 2718 try Data.removeDraft(self.session, allocator, &id); 2719 const route = draftsRoute(self.data.identity) orelse return; 2720 try self.session.navigate(route); 2721 return; 2722 } 2723 } 2724 2725 const io = self.session.io orelse return; 2726 const src = self.data.repo_source orelse return; 2727 const author = (try self.session.eventAuthor()) orelse return; 2728 2729 switch (src.repo_kind) { 2730 inline else => |repo_kind| { 2731 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2732 defer any_repo.deinit(io, allocator); 2733 switch (any_repo) { 2734 inline else => |*repo| try evt.remove(self.session.data.host_kind, .repo, repo_kind, repo.self_repo_opts, io, allocator, repo, &id, event_kind, author), 2735 } 2736 }, 2737 } 2738 2739 const id_hex = std.fmt.bytesToHex(id, .lower); 2740 const route = ui.RoutablePage.repoEventsRoute(self.data.identity, .removed, event_kind, &id_hex) orelse return; 2741 try self.session.navigate(route); 2742 } 2743 2744 // return to the list. 2745 fn focusList(self: *This, index: usize, root_focus: *Focus) void { 2746 root_focus.setFocus(self.listScroll(index).getFocus().id); 2747 } 2748 2749 // cross to the header tabs above the stack. 2750 fn focusHeader(self: *This, root_focus: *Focus) void { 2751 root_focus.setFocus(self.box.children.keys()[header_index]); 2752 } 2753 2754 pub fn clearGrid(self: *This) void { 2755 self.box.clearGrid(); 2756 } 2757 2758 pub fn getGrid(self: This) ?Grid { 2759 return self.box.getGrid(); 2760 } 2761 2762 pub fn getFocus(self: *This) *Focus { 2763 return self.box.getFocus(); 2764 } 2765 2766 // for the parent's "scroll up at the top jumps to the header" check: at the 2767 // top only while the header tabs hold focus, so up from the split 2768 // crosses into the tabs first. 2769 pub fn atTop(self: *This) bool { 2770 return self.headerActive(); 2771 } 2772 }; 2773 } 2774