╭──────────╮ │← previous│ ╰──────────╯ ╭ changed ─────────────╮ │src/ui/Auth/Logout.zig│ ╰──────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────╮ │20 data: *const Self, │ │21 session: *ui.Session, │ │22 button_id: usize, │ │23 - // focus id of the header's "users" tab; on logout we jump there so the│ │24 - // user isn't stranded on a button that's about to be hidden. │ │25 - users_tab_id: usize, │ │23 │ │24 const prompt_index: usize = 0; │ │25 const button_index: usize = 1; │ ╰───────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │26 │ │30 - pub fn init(allocator: std.mem.Allocator, data: *const Self, session: *ui.Session, users_tab_id: usize) !View { │ │27 + pub fn init(allocator: std.mem.Allocator, data: *const Self, session: *ui.Session) !View { │ │28 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .rounded_corners = true, .direction = .vert });│ │29 errdefer box.deinit(allocator); │ │30 // marks this subtree as an HTML form scope for the web overlay │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────╮ │63 .data = data, │ │64 .session = session, │ │65 .button_id = button_id, │ │69 - .users_tab_id = users_tab_id,│ │66 }; │ │67 } │ │68 │ ╰─────────────────────────────────────────────╯ ╭────────────────────────────────────────────────╮ │78 _ = allocator; │ │79 switch (key) { │ │80 .enter => { │ │85 - try self.logout(root_focus);│ │81 + try self.logout(); │ │82 return; │ │83 }, │ │84 .mouse => |mouse| { │ ╰────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────╮ │85 if (inp.leftClickOn(root_focus, self.button_id, mouse)) {│ │90 - try self.logout(root_focus); │ │86 + try self.logout(); │ │87 return; │ │88 } │ │89 }, │ ╰─────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────╮ │ 91 } │ │ 92 } │ │ 93 │ │ 98 - fn logout(self: *View, root_focus: *Focus) !void { │ │ 94 + fn logout(self: *View) !void { │ │ 95 self.session.data.user_id = null; │ │100 - // jump focus back to the users tab — the logout button is about to │ │101 - // be hidden by the tab-label swap. │ │102 - root_focus.setFocus(self.users_tab_id); │ │ 96 + self.session.data.user_name = null; │ │ 97 + // leave the auth tab for the page it belongs to, where the web's │ │ 98 + // /logout redirect also lands │ │ 99 + try self.session.navigate(self.session.data.current_page.pageRoot());│ │100 } │ │101 │ │102 pub fn clearGrid(self: *View) void { │ ╰──────────────────────────────────────────────────────────────────────────────────╯ ╭ changed ─────────╮ │src/ui/AuthTab.zig│ ╰──────────────────╯ ╭───────────────────────────────────────╮ │1 const std = @import("std"); │ │2 +const evt = @import("../event.zig");│ │3 const ui = @import("../ui.zig"); │ │4 const xit = @import("xit"); │ │5 const xitui = xit.xitui; │ ╰───────────────────────────────────────╯ ╭──────────────────────────────────────────────────╮ │10 const Focus = xitui.focus.Focus; │ │11 │ │12 const Self = @This(); │ │12 - │ │13 -pub const min_width: usize = "logout".len + 2;│ │13 │ │14 pub fn init() Self { │ │15 return .{}; │ ╰──────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │18 pub const View = struct { │ │19 text_box: wgt.TextBox(ui.Widget), │ │20 session: *ui.Session, │ │21 + // backs the tab's text, which borrows it. sized for the longest name, so │ │22 + // build never allocates. │ │23 + text_buf: [logout_prefix.len + evt.User.name_max_len]u8, │ │24 │ │25 + const logout_prefix = "logout "; │ │26 + │ │27 pub fn init(allocator: std.mem.Allocator, session: *ui.Session) !View { │ │28 var text_box = try wgt.TextBox(ui.Widget).init(allocator, "login", .{ .border_style = .single, .rounded_corners = true, .wrap_kind = .none });│ │29 errdefer text_box.deinit(allocator); │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────╮ │32 return .{ │ │33 .text_box = text_box, │ │34 .session = session, │ │35 + .text_buf = undefined,│ │36 }; │ │37 } │ │38 │ ╰──────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯