╭ changed ──────────────╮ │src/ui/Repo/Comment.zig│ ╰───────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │20 // whether the viewer may edit or remove the comment │ │21 can_modify: bool = false, │ │22 }; │ │23 - │ │24 -// who a thread page is built for, which picks the comment buttons it shows │ │25 -pub const Viewer = struct { │ │26 - role: evt.Repo.Role, │ │27 - email: []const u8, │ │23 │ │29 - // the session's viewer of `repo`, or null when logged out. local mode owns everything. │ │30 - pub fn init(session: *ui.Session, arena: *std.heap.ArenaAllocator, repo: evt.Repo.Record) !?Viewer {│ │31 - if (session.data.host_kind == .local) return .{ .role = .owner, .email = "" }; │ │32 - const user_id = session.userId() orelse return null; │ │33 - const moment = session.haxy_moment orelse unreachable; │ │34 - const user = (try ui.activeUser(moment, arena, user_id)) orelse return null; │ │35 - return .{ .role = evt.Repo.roleOf(repo, user_id), .email = user.event.email }; │ │36 - } │ │37 -}; │ │38 - │ │24 pub const Window = struct { │ │25 comments: []const CommentWithId, │ │26 start: usize, │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │43 thread_id: []const u8, │ │44 selected_id: []const u8, │ │45 start: usize, │ │61 - viewer: ?Viewer, │ │46 + viewer: ?ui.Viewer, │ │47 ) !Permalink { │ │48 const selected = (try readOne(hash_kind, arena, admin_moment, haxy_moment, selected_id, viewer)) orelse return error.NotFound;│ │49 if (!std.mem.eql(u8, &selected.comment.event.thread_id, thread_id)) return error.NotFound; │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │63 index_key: []const u8, │ │64 owner_id: []const u8, │ │65 start: usize, │ │81 - viewer: ?Viewer, │ │66 + viewer: ?ui.Viewer, │ │67 ) !Window { │ │68 const DB = evt.EventDB(hash_kind); │ │69 const index_cursor = try haxy_moment.getCursor(hash.hashInt(hash_kind, index_key)) orelse return .{│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────╮ │105 admin_moment: ?evt.AdminDB.HashMap(.read_only), │ │106 haxy_moment: evt.EventDB(hash_kind).HashMap(.read_only), │ │107 id: []const u8, │ │123 - viewer: ?Viewer, │ │108 + viewer: ?ui.Viewer, │ │109 ) !?CommentWithId { │ │110 const bytes = idBytes(id) orelse return null; │ │111 return readOneBytes(hash_kind, arena, admin_moment, haxy_moment, &bytes, viewer);│ ╰──────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │117 admin_moment: ?evt.AdminDB.HashMap(.read_only), │ │118 haxy_moment: evt.EventDB(hash_kind).HashMap(.read_only), │ │119 id_bytes: *const [evt.event_id_size]u8, │ │135 - viewer: ?Viewer, │ │120 + viewer: ?ui.Viewer, │ │121 ) !?CommentWithId { │ │122 const DB = evt.EventDB(hash_kind); │ │123 const comment = (try evt.Comment.readById(DB, hash_kind, haxy_moment, arena, id_bytes)) orelse return null;│ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯