╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ─────────────╮ │src/ui/Repo/Issues.zig│ ╰──────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │879 return box; │ │880 } │ │881 │ │856 - fn initCommentForm(allocator: std.mem.Allocator, session: *ui.Session, action: []const u8, author: ui.Author, parent_route: ui.RoutablePage) !wgt.Box(ui.Widget) { │ │882 + fn initCommentForm(allocator: std.mem.Allocator, session: *ui.Session, action: []const u8, author: ui.Author, parent_route: ui.RoutablePage, initial_body: ?[]const u8) !wgt.Box(ui.Widget) {│ │883 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .vert }); │ │884 errdefer box.deinit(allocator); │ │885 box.getFocus().kind = .{ .custom = action }; │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │905 }); │ │906 errdefer body.deinit(allocator); │ │907 body.getFocus().focusable = true; │ │908 + if (initial_body) |text| try body.setContent(allocator, text); │ │909 try box.children.put(allocator, body.getFocus().id, .{ .widget = .{ .text_input = body }, .rect = null, .min_size = null });│ │910 } │ │911 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────╮ │885 - try addSubmitButtonLabeled(allocator, &box, "submit reply"); │ │912 + try addSubmitButtonLabeled(allocator, &box, "submit"); │ │913 box.getFocus().child_id = box.children.keys()[comment_author_field_index];│ │914 return box; │ │915 } │ ╰───────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1265 (switch (self.data.view) { │ │1266 .edit => ui.RoutablePage.repoIssuesEditRoute(self.data.identity, self.data.selected_id), │ │1267 .new_comment => ui.RoutablePage.repoCommentNewRoute(self.data.identity, self.data.selected_id, self.data.comment_id), │ │1268 + .edit_comment => ui.RoutablePage.repoCommentEditRoute(self.data.identity, self.data.selected_id, self.data.comment_id),│ │1269 .resolve => ui.RoutablePage.repoIssuesResolveRoute(self.data.identity, self.data.selected_id, self.data.theirs_picks), │ │1270 else => ui.RoutablePage.repoIssuesNewRoute(self.data.identity), │ │1271 }) │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1361 try self.session.input_values.put(inputs_arena, fields[title_field_index].widget.text_input.getFocus().id, entry.issue.event.title); │ │1362 try self.session.input_values.put(inputs_arena, fields[tags_field_index].widget.text_input.getFocus().id, entry.issue.event.tags); │ │1363 try self.session.input_values.put(inputs_arena, fields[description_field_index].widget.text_input.getFocus().id, entry.issue.event.description);│ │1364 + } │ │1365 + } │ │1366 + │ │1367 + if (self.data.view == .edit_comment) { │ │1368 + if (self.data.comment_page) |page| { │ │1369 + const body = &form.children.values()[comment_body_field_index].widget.text_input; │ │1370 + try self.session.input_values.put(inputs_arena, body.getFocus().id, page.selected.comment.event.body); │ │1371 } │ │1372 } │ │1373 │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────╮ │1621 if (self.formViewActive()) { │ │1622 if (self.data.view == .resolve) { │ │1623 try self.resolveInput(allocator, key, root_focus); │ │1589 - } else if (self.data.view == .new_comment) { │ │1624 + } else if (self.data.view == .new_comment or self.data.view == .edit_comment) {│ │1625 try self.commentFormInput(allocator, key, root_focus); │ │1626 } else { │ │1627 try self.formInput(allocator, key, root_focus); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────╮ │2079 try self.session.navigate(route); │ │2080 } │ │2081 │ │2047 - // commit a reply and navigate to its permalink. this is the terminal path; │ │2048 - // the web posts the form to its /comment route. │ │2082 + // commit a new or edited comment and navigate to its permalink. this is the│ │2083 + // terminal path; the web posts the form to its comment route. │ │2084 fn submitComment(self: *View, allocator: std.mem.Allocator) !void { │ │2085 if (comptime wasm) return; │ │2086 const io = self.session.io orelse return; │ ╰──────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │2100 break :blk parent; │ │2101 }; │ │2102 var event_id_hex: [evt.event_id_size * 2]u8 = undefined; │ │2103 + const editing = self.data.view == .edit_comment; │ │2104 switch (src.repo_kind) { │ │2105 inline else => |repo_kind| { │ │2106 var any_repo = try rp.AnyRepo(repo_kind, .{}).open(io, allocator, .{ .path = src.path });│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │2107 defer any_repo.deinit(io, allocator); │ │2108 switch (any_repo) { │ │2073 - inline else => |*repo| event_id_hex = try evt.Comment.create(repo_kind, repo.self_repo_opts, io, allocator, repo, &thread_id, &parent_id, body, author_email),│ │2109 + inline else => |*repo| if (editing) { │ │2110 + var comment_id: [evt.event_id_size]u8 = undefined; │ │2111 + _ = std.fmt.hexToBytes(&comment_id, self.data.comment_id) catch return; │ │2112 + try evt.Comment.update(repo_kind, repo.self_repo_opts, io, allocator, repo, &thread_id, &comment_id, body, author_email); │ │2113 + event_id_hex = std.fmt.bytesToHex(comment_id, .lower); │ │2114 + } else { │ │2115 + event_id_hex = try evt.Comment.create(repo_kind, repo.self_repo_opts, io, allocator, repo, &thread_id, &parent_id, body, author_email); │ │2116 + }, │ │2117 } │ │2118 }, │ │2119 } │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │2520 const route = switch (data.view) { │ │2521 .edit => ui.RoutablePage.repoIssuesEditRoute(data.identity, data.selected_id) orelse return error.RouteTooLong, │ │2522 .new_comment => ui.RoutablePage.repoCommentNewRoute(data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, │ │2523 + .edit_comment => ui.RoutablePage.repoCommentEditRoute(data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong,│ │2524 .resolve => ui.RoutablePage.repoIssuesResolveRoute(data.identity, data.selected_id, data.theirs_picks) orelse return error.RouteTooLong, │ │2525 else => ui.RoutablePage.repoIssuesNewRoute(data.identity) orelse return error.RouteTooLong, │ │2526 }; │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯