╭ changed ────────────╮ │src/ui/Home/Users.zig│ ╰─────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────╮ │10 const Grid = xitui.grid.Grid; │ │11 const Focus = xitui.focus.Focus; │ │12 │ │13 -// how many users a page shows before the "load more" row appears. │ │14 -pub const page_size = 20; │ │13 +pub const page_size = 20; // how many users one window shows │ │14 │ │15 users: []const evt.User.Safe, │ │17 -// the window start this page was built with, mirrored into the url. │ │18 -after: usize, │ │19 -// the `after` for the "load more" link, or null when this is the last page. │ │20 -next_after: ?usize, │ │16 +after: usize, // the window start this page was built with, mirrored into the url │ │17 +next_after: ?usize, // the `after` for the "next" row, or null when this is the last window│ │18 │ │19 const Self = @This(); │ │20 │ ╰───────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 80 defer arena.deinit(); │ │ 81 const aa = arena.allocator(); │ │ 82 │ │ 86 - // one row per user, plus a trailing "load more" row when more remain. │ │ 87 - const extra: usize = if (data.next_after != null) 1 else 0; │ │ 88 - const lines = try aa.alloc([]const u8, data.users.len + extra); │ │ 89 - const links = try aa.alloc([]const u8, data.users.len + extra); │ │ 83 + // a leading "previous" row off the first window, one row per user, then │ │ 84 + // a trailing "next" row when more remain. each window row navigates to the │ │ 85 + // adjacent window (full reload on web, Nav rebuild on the TUI). │ │ 86 + const lead: usize = if (data.after > 0) 1 else 0; │ │ 87 + const trail: usize = if (data.next_after != null) 1 else 0; │ │ 88 + const lines = try aa.alloc([]const u8, lead + data.users.len + trail); │ │ 89 + const links = try aa.alloc([]const u8, lead + data.users.len + trail); │ │ 90 + if (data.after > 0) { │ │ 91 + lines[0] = "← previous"; │ │ 92 + links[0] = try std.fmt.allocPrint(aa, "a:/users?after={d}", .{data.after -| page_size}); │ │ 93 + } │ │ 94 for (data.users, 0..) |user, i| { │ │ 91 - lines[i] = try std.fmt.allocPrint(aa, "{s} ({s})", .{ user.name, user.display_name }); │ │ 95 + lines[lead + i] = try std.fmt.allocPrint(aa, "{s} ({s})", .{ user.name, user.display_name }); │ │ 96 // clicking a user opens their page; the "a:" prefix makes the web │ │ 97 // renderer emit an <a href="/user/foo"> anchor. │ │ 94 - links[i] = try std.fmt.allocPrint(aa, "a:/user/{s}", .{user.name}); │ │ 98 + links[lead + i] = try std.fmt.allocPrint(aa, "a:/user/{s}", .{user.name}); │ │ 99 } │ │100 if (data.next_after) |next_after| { │ │ 97 - // the load-more row navigates to the next window (full reload on web, │ │ 98 - // Nav rebuild on the TUI), exactly like the commits "load more". │ │ 99 - lines[data.users.len] = "load more"; │ │100 - links[data.users.len] = try std.fmt.allocPrint(aa, "a:/users?after={d}", .{next_after}); │ │101 + lines[lead + data.users.len] = "next →"; │ │102 + links[lead + data.users.len] = try std.fmt.allocPrint(aa, "a:/users?after={d}", .{next_after});│ │103 } │ │104 try self.list.setItems(allocator, lines, links); │ │105 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯