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