╭ changed ──────────────╮ │src/ui/Repo/Comment.zig│ ╰───────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────╮ │138 │ │139 pub const Item = struct { │ │140 box: wgt.Box(ui.Widget), │ │141 - id: [evt.event_id_size]u8, │ │142 - remove_button_id: ?usize, │ │141 │ │142 const metadata_index: usize = 0;│ │143 const body_index: usize = 1; │ ╰─────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │147 pub fn init(allocator: std.mem.Allocator, session: *ui.Session, identity: []const u8, thread_kind: evt.EventKind, entry: CommentWithId) !Item {│ │148 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .vert }); │ │149 errdefer box.deinit(allocator); │ │152 - var remove_button_id: ?usize = null; │ │150 │ │151 { │ │152 var bar = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .horiz }); │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │193 } │ │194 │ │195 if (!entry.comment.removed and (session.data.is_local or session.data.user_id != null)) { │ │199 - const route = commentsRoute(thread_kind, identity, &entry.comment.event.thread_id, &entry.id, 0) orelse return error.RouteTooLong; │ │200 - bar.getFocus().kind = .{ .custom = try std.fmt.allocPrint(session.page_arena.allocator(), "form:{s}/remove", .{try route.toUrl(session.page_arena)}) }; │ │201 - var remove = try wgt.TextBox(ui.Widget).init(allocator, "✕", .{ .border_style = .single, .rounded_corners = true, .wrap_kind = .none }); │ │196 + var remove = try linkBox(allocator, session, "✕", removeRoute(thread_kind, identity, &entry.comment.event.thread_id, &entry.id) orelse return error.RouteTooLong);│ │197 errdefer remove.deinit(allocator); │ │203 - remove.getFocus().focusable = true; │ │204 - remove.getFocus().kind = .{ .custom = "submit" }; │ │205 - remove_button_id = remove.getFocus().id; │ │198 try bar.children.put(allocator, remove.getFocus().id, .{ .widget = .{ .text_box = remove }, .rect = null, .min_size = .{ .width = 3, .height = null } }); │ │199 } │ │200 │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────╮ │214 │ │215 box.getFocus().child_id = box.children.keys()[metadata_index]; │ │216 │ │225 - return .{ │ │226 - .box = box, │ │227 - .id = idBytes(&entry.id) orelse return error.InvalidEventId,│ │228 - .remove_button_id = remove_button_id, │ │229 - }; │ │217 + return .{ .box = box }; │ │218 } │ │219 │ │220 fn metadata(self: *Item) *wgt.Box(ui.Widget) { │ ╰─────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────╮ │227 │ │228 pub fn bodyFocused(self: *Item) bool { │ │229 return self.box.getFocus().child_id == self.body().getFocus().id;│ │242 - } │ │243 - │ │244 - pub fn removeFocused(self: *Item) bool { │ │245 - const id = self.remove_button_id orelse return false; │ │246 - return self.metadata().getFocus().child_id == id; │ │230 } │ │231 │ │232 pub fn focusMetadata(self: *Item, root_focus: *Focus) void { │ ╰──────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │332 │ │333 fn commentEditRoute(kind: evt.EventKind, identity: []const u8, thread_id: []const u8, comment_id: []const u8) ?ui.RoutablePage { │ │334 return ui.RoutablePage.repoThreadCommentEditRoute(kind, identity, thread_id, comment_id); │ │335 +} │ │336 + │ │337 +fn removeRoute(kind: evt.EventKind, identity: []const u8, thread_id: []const u8, comment_id: []const u8) ?ui.RoutablePage { │ │338 + return ui.RoutablePage.repoThreadRemoveRoute(kind, identity, thread_id, comment_id); │ │339 } │ │340 │ │341 pub fn linkBox(allocator: std.mem.Allocator, session: *ui.Session, text: []const u8, route: ui.RoutablePage) !wgt.TextBox(ui.Widget) {│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯