╭ changed ─────────────╮ │src/ui/Repo/Events.zig│ ╰──────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────╮ │← previous│ ╰──────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │181 kind: evt.EventKind, │ │182 id: *const [evt.event_id_size]u8, │ │168 -) !u64 { │ │183 +) !EventMeta { │ │184 return switch (kind) { │ │170 - .user => (try readRecord(evt.User, hash_kind, arena, haxy_moment, id) orelse return error.NotFound).created_ts, │ │171 - .repo => (try readRecord(evt.Repo, hash_kind, arena, haxy_moment, id) orelse return error.NotFound).created_ts, │ │172 - .issue => (try readRecord(evt.Issue, hash_kind, arena, haxy_moment, id) orelse return error.NotFound).created_ts, │ │173 - .comment => (try readRecord(evt.Comment, hash_kind, arena, haxy_moment, id) orelse return error.NotFound).created_ts, │ │174 - .attach => (try readRecord(evt.Attachment, hash_kind, arena, haxy_moment, id) orelse return error.NotFound).created_ts,│ │185 + inline else => |event_kind| blk: { │ │186 + const T = switch (event_kind) { │ │187 + .user => evt.User, │ │188 + .repo => evt.Repo, │ │189 + .issue => evt.Issue, │ │190 + .comment => evt.Comment, │ │191 + .attach => evt.Attachment, │ │192 + }; │ │193 + const record = (try readRecord(T, hash_kind, arena, haxy_moment, id)) orelse return error.NotFound; │ │194 + break :blk .{ .created_ts = record.created_ts, .removed = record.removed }; │ │195 + }, │ │196 }; │ │197 } │ │198 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────╮ │203 kind_map: evt.EventDB(hash_kind).HashMap(.read_only),│ │204 admin_moment: ?evt.AdminDB.HashMap(.read_only), │ │205 identity: []const u8, │ │206 + include_view_url: bool, │ │207 kind: evt.EventKind, │ │208 id: *const [evt.event_id_size]u8, │ │209 ) !?Item { │ ╰──────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────╮ │210 var item: Item = .{ │ │211 .id = try formatId(arena.allocator(), id),│ │212 .kind = kind, │ │191 - .deleted = false, │ │213 .author = .unknown, │ │214 }; │ │215 switch (kind) { │ ╰───────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │216 .user => { │ │217 const record = (try readRecord(evt.User, hash_kind, arena, haxy_moment, id)) orelse return null;│ │197 - item.deleted = record.deleted; │ │218 item.author = try ui.Author.initFromEmail(admin_moment, arena, record.event.email); │ │219 }, │ │220 .repo => { │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │221 const record = (try readRecord(evt.Repo, hash_kind, arena, haxy_moment, id)) orelse return null; │ │202 - item.deleted = record.deleted; │ │222 if (admin_moment) |moment| { │ │223 if (try evt.User.readById(evt.AdminDB, evt.admin_repo_opts.hash, moment, arena, record.event.user_id)) |user|│ │224 item.author = .{ .user_name = user.event.name }; │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │226 }, │ │227 .issue => { │ │228 const record = (try readRecord(evt.Issue, hash_kind, arena, haxy_moment, id)) orelse return null; │ │210 - item.deleted = record.deleted; │ │229 item.author = try ui.Author.initFromEmail(admin_moment, arena, record.author_email); │ │230 + if (!include_view_url) return item; │ │231 const route = ui.RoutablePage.repoIssueCommentsRoute(identity, item.id, 0) orelse return error.RouteTooLong;│ │232 item.view_url = try route.toUrl(arena); │ │233 }, │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │234 .comment => { │ │235 const record = (try readRecord(evt.Comment, hash_kind, arena, haxy_moment, id)) orelse return null;│ │217 - item.deleted = record.deleted; │ │236 item.author = try ui.Author.initFromEmail(admin_moment, arena, record.author_email); │ │237 + if (!include_view_url) return item; │ │238 var thread_id: [evt.event_id_size]u8 = undefined; │ │239 _ = std.fmt.hexToBytes(&thread_id, &record.event.thread_id) catch return error.InvalidEventId; │ │221 - const thread_kind = (try readKind(hash_kind, kind_map, &thread_id)) orelse return item; │ │240 + const thread_kind = (try evt.readEventKind(hash_kind, kind_map, &thread_id)) orelse return item; │ │241 const route = switch (thread_kind) { │ │242 .issue => ui.RoutablePage.repoCommentsRoute(identity, &record.event.thread_id, item.id, 0), │ │243 else => null, │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │246 }, │ │247 .attach => { │ │248 const record = (try readRecord(evt.Attachment, hash_kind, arena, haxy_moment, id)) orelse return null;│ │230 - item.deleted = record.deleted; │ │249 item.author = try ui.Author.initFromEmail(admin_moment, arena, record.author_email); │ │250 + if (!include_view_url) return item; │ │251 var parent_id: [evt.event_id_size]u8 = undefined; │ │252 _ = std.fmt.hexToBytes(&parent_id, &record.event.parent_id) catch return error.InvalidEventId; │ │234 - const parent_kind = (try readKind(hash_kind, kind_map, &parent_id)) orelse return item; │ │253 + const parent_kind = (try evt.readEventKind(hash_kind, kind_map, &parent_id)) orelse return item; │ │254 const route = switch (parent_kind) { │ │255 .issue => ui.RoutablePage.repoIssueCommentsRoute(identity, &record.event.parent_id, 0), │ │256 else => null, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────╮ │265 box: wgt.Box(ui.Widget), │ │266 data: *const Self, │ │267 session: *ui.Session, │ │249 - detailed_index: ?usize, │ │268 + detailed_index: [2]?usize,│ │269 │ │270 const header_index = 0; │ │271 const content_index = 1; │ ╰───────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │278 var outer = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .vert }); │ │279 errdefer outer.deinit(allocator); │ │280 │ │262 - var header_view = try Header.View.init(allocator, &data.header, session); │ │281 + var header_view = try Header.View.init(allocator, data, session); │ │282 errdefer header_view.deinit(allocator); │ │283 try outer.children.put(allocator, header_view.getFocus().id, .{ .widget = .{ .repo_events_header = header_view }, .rect = null, .min_size = .{ .width = null, .height = 3 } });│ │284 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯