╭ changed ──────────────╮ │src/ui/Repo/Comment.zig│ ╰───────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────╮ │13 pub const page_size = 10; │ │14 │ │15 pub const CommentWithId = struct { │ │16 - id: []const u8, │ │16 + id: [evt.event_id_size * 2]u8, │ │17 comment: evt.Comment.Record, │ │18 author: ui.Author = .unknown, │ │19 parent_author: ?ui.Author = null,│ ╰─────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │23 comments: []const CommentWithId, │ │24 start: usize, │ │25 count: usize, │ │26 - has_prev: bool, │ │27 - has_more: bool, │ │26 │ │29 - pub const empty: Window = .{ .comments = &.{}, .start = 0, .count = 0, .has_prev = false, .has_more = false };│ │27 + pub const empty: Window = .{ .comments = &.{}, .start = 0, .count = 0 }; │ │28 }; │ │29 │ │30 pub const Permalink = struct { │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────╮ │33 - thread_id: []const u8, │ │31 selected: CommentWithId,│ │32 replies: Window, │ │33 }; │ ╰────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │46 if (!std.mem.eql(u8, &selected.comment.event.thread_id, thread_id)) return error.NotFound; │ │47 │ │48 return .{ │ │52 - .thread_id = try arena.allocator().dupe(u8, thread_id), │ │49 .selected = selected, │ │50 .replies = try loadWindow(hash_kind, arena, admin_moment, haxy_moment, evt.Comment.parent_id_to_comment_id_set_key, selected_id, start),│ │51 }; │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ │66 .comments = &.{}, │ │67 .start = start, │ │68 .count = 0, │ │73 - .has_prev = start > 0, │ │74 - .has_more = false, │ │69 }; │ │70 const index = try DB.HashMap(.read_only).init(index_cursor); │ │71 const set_cursor = try index.getCursor(hash.hashInt(hash_kind, owner_id)) orelse return .{│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────╮ │72 .comments = &.{}, │ │73 .start = start, │ │74 .count = 0, │ │81 - .has_prev = start > 0, │ │82 - .has_more = false, │ │75 }; │ │76 const set = try DB.SortedSet(.read_only).init(set_cursor);│ │77 const count: usize = @intCast(try set.count()); │ ╰──────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────╮ │86 - const end = @min(start + page_size, count); │ │78 + const end = start + @min(page_size, count -| start);│ │79 var iter = try set.iteratorFromIndex(start); │ │80 var comments: std.ArrayList(CommentWithId) = .empty;│ │81 var i = start; │ ╰────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │84 const kv = try cursor.readKeyValuePair(); │ │85 var order_key: [@sizeOf(u64) + evt.event_id_size]u8 = undefined; │ │86 _ = try kv.key_cursor.readBytes(&order_key); │ │95 - const id_hex = std.fmt.bytesToHex(order_key[@sizeOf(u64)..].*, .lower); │ │96 - const entry = (try readOneBytes(hash_kind, arena, admin_moment, haxy_moment, order_key[@sizeOf(u64)..], &id_hex)) orelse continue;│ │87 + const id_bytes = order_key[@sizeOf(u64)..].*; │ │88 + const entry = (try readOneBytes(hash_kind, arena, admin_moment, haxy_moment, &id_bytes)) orelse continue; │ │89 try comments.append(arena.allocator(), entry); │ │90 } │ │91 return .{ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────╮ │ 92 .comments = comments.items,│ │ 93 .start = start, │ │ 94 .count = count, │ │103 - .has_prev = start > 0, │ │104 - .has_more = end < count, │ │ 95 }; │ │ 96 } │ │ 97 │ ╰────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────╮ │102 haxy_moment: evt.EventDB(hash_kind).HashMap(.read_only), │ │103 id: []const u8, │ │104 ) !?CommentWithId { │ │115 - const bytes = (try idBytes(id)) orelse return null; │ │116 - return readOneBytes(hash_kind, arena, admin_moment, haxy_moment, &bytes, id);│ │105 + const bytes = idBytes(id) orelse return null; │ │106 + return readOneBytes(hash_kind, arena, admin_moment, haxy_moment, &bytes); │ │107 } │ │108 │ │109 fn readOneBytes( │ ╰──────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯