╭ changed ──────╮ │src/ui/Home.zig│ ╰───────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────╮ │13 pub const Users = @import("./Home/Users.zig"); │ │14 pub const Repos = @import("./Home/Repos.zig"); │ │15 pub const Header = @import("./Home/Header.zig");│ │16 +pub const Auth = @import("./Home/Auth.zig"); │ │17 │ │18 header: Header, │ │19 users: Users, │ ╰────────────────────────────────────────────────────╯ ╭────────────────────────────────╮ │20 repos: Repos, │ │21 +auth: Auth, │ │22 +user_id: ?[]const u8 = null,│ │23 │ │24 const Self = @This(); │ │25 │ ╰────────────────────────────────╯ ╭───────────────────────────────────────────────╮ │27 comptime repo_opts: rp.RepoOpts(.xit), │ │28 arena: *std.heap.ArenaAllocator, │ │29 repo: *rp.Repo(.xit, repo_opts), │ │30 + session: *ui.Session, │ │31 ) !Self { │ │32 const DB = rp.Repo(.xit, repo_opts).DB;│ │33 │ ╰───────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │48 │ │49 const haxy_moment_cursor = try haxy_moments.getCursor(hash.bytesToInt(repo_opts.hash, &last_object_id)) orelse return error.NotFound;│ │50 const haxy_moment = try DB.HashMap(.read_only).init(haxy_moment_cursor); │ │51 + │ │52 + // hand the cursor + arena off to the session so Login (and any future │ │53 + // page that needs DB access at input time) can use them on demand. │ │54 + session.arena = arena; │ │55 + session.haxy_moment = haxy_moment; │ │56 │ │57 return .{ │ │58 .header = Header.init(), │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────╮ │59 .users = try Users.init(repo_opts, arena, haxy_moment),│ │60 .repos = try Repos.init(repo_opts, arena, haxy_moment),│ │61 + .auth = Auth.init(), │ │62 + .user_id = session.user_id, │ │63 }; │ │64 } │ │65 │ ╰───────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────╮ │66 pub const View = struct { │ │67 box: wgt.Box(ui.Widget), │ │68 data: *const Self, │ │69 + session: *ui.Session, │ │70 │ │71 const header_index: usize = 0;│ │72 const stack_index: usize = 1; │ ╰──────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │73 │ │62 - pub fn init(allocator: std.mem.Allocator, data: *const Self) !View { │ │74 + pub fn init(allocator: std.mem.Allocator, data: *const Self, session: *ui.Session) !View { │ │75 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .vert });│ │76 errdefer box.deinit(); │ │77 │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │78 + // build the header first so we can grab the users-tab focus id and │ │79 + // hand it to login/logout │ │80 + var users_tab_id: usize = undefined; │ │81 { │ │67 - var header_view = try Header.View.init(allocator, &data.header); │ │82 + var header_view = try Header.View.init(allocator, &data.header, session); │ │83 errdefer header_view.deinit(); │ │84 + users_tab_id = header_view.tab_ids[0]; │ │85 try box.children.put(allocator, header_view.getFocus().id, .{ .widget = .{ .home_header = header_view }, .rect = null, .min_size = null });│ │86 } │ │87 │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 99 var repos_view = try Repos.View.init(allocator, &data.repos); │ │100 errdefer repos_view.deinit(); │ │101 try stack.children.put(stack.allocator, repos_view.getFocus().id, .{ .home_repos = repos_view }); │ │102 + } │ │103 + │ │104 + { │ │105 + var auth_view = try Auth.View.init(allocator, &data.auth, session, users_tab_id); │ │106 + errdefer auth_view.deinit(); │ │107 + try stack.children.put(stack.allocator, auth_view.getFocus().id, .{ .home_auth = auth_view }); │ │108 } │ │109 │ │110 try box.children.put(allocator, stack.getFocus().id, .{ .widget = .{ .stack = stack }, .rect = null, .min_size = null });│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────╮ │113 var self = View{ │ │114 .box = box, │ │115 .data = data, │ │116 + .session = session, │ │117 }; │ │118 self.getFocus().child_id = box.children.keys()[header_index];│ │119 return self; │ ╰──────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯