╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ thread.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
2906 const merged = std.meta.stringToEnum(Status, "merged") orelse return; 2907 const route = listRoute(self.data.identity, merged, "", entry.id) orelse return; 2908 try self.session.navigate(route); 2909 } else unreachable, 2910 .remove => try self.submitRemove(allocator), 2911 } 2912 } 2913 2914 fn submitRemove(self: *This, allocator: std.mem.Allocator) !void { 2915 const comment = self.data.comment_id.len != 0; 2916 const event_id = if (comment) self.data.comment_id else self.data.selected_id; 2917 const id = evt.parseEventId(event_id) catch return; 2918 try self.removeEvent(allocator, if (comment) .comment else kind, id); 2919 } 2920 2921 fn removeEvent(self: *This, allocator: std.mem.Allocator, event_kind: evt.EventKind, id: [evt.event_id_size]u8) !void { 2922 if (comptime wasm) return; 2923 const actor = (try self.session.authorize(self.data.identity, .read, kind)) orelse return; 2924 const author = actor.author; 2925 2926 if (comptime supports_drafts) { 2927 const selected = self.data.selectedThread() orelse return; 2928 if (event_kind == kind and entryDraft(selected.*)) { 2929 try Data.removeDraft(self.session, allocator, author, &id); 2930 const route = draftsRoute(self.data.identity) orelse return; 2931 try self.session.navigate(route); 2932 return; 2933 } 2934 } 2935 2936 const io = self.session.io orelse return; 2937 const src = self.data.repo_source orelse return; 2938 if (!try src.canModify(io, allocator, actor, event_kind, &id)) return; 2939 const thread_id = evt.parseEventId(self.data.selected_id) catch return; 2940 2941 switch (src.repo_kind) { 2942 inline else => |repo_kind| { 2943 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, src.localInitOpts()); 2944 defer any_repo.deinit(io, allocator); 2945 switch (any_repo) { 2946 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), 2947 } 2948 }, 2949 } 2950 2951 const id_hex = std.fmt.bytesToHex(id, .lower); 2952 const route = ui.RoutablePage.repoEventsRoute(self.data.identity, .removed, event_kind, &id_hex, null) orelse return; 2953 try self.session.navigate(route); 2954 } 2955 2956 // return to the list. 2957 fn focusList(self: *This, index: usize, root_focus: *Focus) void { 2958 root_focus.setFocus(self.listScroll(index).getFocus().id); 2959 } 2960 2961 // cross to the header tabs above the stack. 2962 fn focusHeader(self: *This, root_focus: *Focus) void { 2963 root_focus.setFocus(self.box.children.keys()[header_index]); 2964 } 2965 2966 pub fn clearGrid(self: *This) void { 2967 self.box.clearGrid(); 2968 } 2969 2970 pub fn getGrid(self: This) ?Grid { 2971 return self.box.getGrid(); 2972 } 2973 2974 pub fn getFocus(self: *This) *Focus { 2975 return self.box.getFocus(); 2976 } 2977 2978 // for the parent's "scroll up at the top jumps to the header" check: at the 2979 // top only while the header tabs hold focus, so up from the split 2980 // crosses into the tabs first. 2981 pub fn atTop(self: *This) bool { 2982 return self.headerActive(); 2983 } 2984 }; 2985 } 2986