╭ changed ─────────────╮ │src/ui/User/Header.zig│ ╰──────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ │27 │ │28 pub const View = struct { │ │29 scroll: wgt.Scroll(ui.Widget), │ │30 - data: *const Self, │ │30 tab_ids: std.AutoArrayHashMapUnmanaged(usize, void), │ │31 │ │32 pub fn init(allocator: std.mem.Allocator, data: *const Self, session: *ui.Session) !View {│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │70 // still followed with js off. allocated in the page arena so the focus │ │71 // kinds that borrow them live as long as this page's widget tree. │ │72 const aa = session.page_arena.allocator(); │ │74 - const repos_link = try std.fmt.allocPrint(aa, "ai:/user/{s}", .{data.name}); │ │75 - const forks_link = try std.fmt.allocPrint(aa, "ai:/user/{s}/forks", .{data.name}); │ │76 - const settings_link = try std.fmt.allocPrint(aa, "ai:/user/{s}/settings", .{data.name}); │ │77 - const auth_link = try std.fmt.allocPrint(aa, "ai:/user/{s}/auth", .{data.name}); │ │73 + const current_page = session.data.current_page; │ │74 + const current_tag = std.meta.activeTag(current_page); │ │75 + const current_link = try std.fmt.allocPrint(aa, "ai:{s}", .{try current_page.toUrl(session.page_arena)}); │ │76 + const repos_link = if (current_tag == .user_repos) current_link else try std.fmt.allocPrint(aa, "ai:/user/{s}", .{data.name}); │ │77 + const forks_link = if (current_tag == .user_forks) current_link else try std.fmt.allocPrint(aa, "ai:/user/{s}/forks", .{data.name}); │ │78 + const settings_link = if (current_tag == .user_settings) current_link else try std.fmt.allocPrint(aa, "ai:/user/{s}/settings", .{data.name});│ │79 + const auth_link = if (current_tag == .user_auth) current_link else try std.fmt.allocPrint(aa, "ai:/user/{s}/auth", .{data.name}); │ │80 │ │81 // the tab matching the current page is focused initially; matching by │ │82 // link (rather than position) keeps this robust to tab changes. │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────╮ │81 - const current_link: []const u8 = switch (session.data.current_page) {│ │83 + const selected_link: []const u8 = switch (current_page) { │ │84 .user_settings => settings_link, │ │85 .user_auth => auth_link, │ │86 .user_forks => forks_link, │ ╰─────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────╮ │ 95 text_box.getFocus().focusable = true; │ │ 96 text_box.getFocus().kind = .{ .custom = repos_link }; │ │ 97 try tab_ids.put(allocator, text_box.getFocus().id, {}); │ │ 96 - if (std.mem.eql(u8, repos_link, current_link)) selected_tab = text_box.getFocus().id; │ │ 98 + if (std.mem.eql(u8, repos_link, selected_link)) selected_tab = text_box.getFocus().id;│ │ 99 try box.children.put(allocator, text_box.getFocus().id, .{ │ │100 .widget = .{ .text_box = text_box }, │ │101 .rect = null, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────╮ │110 text_box.getFocus().focusable = true; │ │111 text_box.getFocus().kind = .{ .custom = forks_link }; │ │112 try tab_ids.put(allocator, text_box.getFocus().id, {}); │ │111 - if (std.mem.eql(u8, forks_link, current_link)) selected_tab = text_box.getFocus().id; │ │113 + if (std.mem.eql(u8, forks_link, selected_link)) selected_tab = text_box.getFocus().id;│ │114 try box.children.put(allocator, text_box.getFocus().id, .{ │ │115 .widget = .{ .text_box = text_box }, │ │116 .rect = null, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │137 text_box.getFocus().focusable = true; │ │138 text_box.getFocus().kind = .{ .custom = settings_link }; │ │139 try tab_ids.put(allocator, text_box.getFocus().id, {}); │ │138 - if (std.mem.eql(u8, settings_link, current_link)) selected_tab = text_box.getFocus().id; │ │140 + if (std.mem.eql(u8, settings_link, selected_link)) selected_tab = text_box.getFocus().id;│ │141 try box.children.put(allocator, text_box.getFocus().id, .{ │ │142 .widget = .{ .text_box = text_box }, │ │143 .rect = null, │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────╮ │152 errdefer auth_tab.deinit(allocator); │ │153 auth_tab.text_box.getFocus().kind = .{ .custom = auth_link }; │ │154 try tab_ids.put(allocator, auth_tab.getFocus().id, {}); │ │153 - if (std.mem.eql(u8, auth_link, current_link)) selected_tab = auth_tab.getFocus().id; │ │155 + if (std.mem.eql(u8, auth_link, selected_link)) selected_tab = auth_tab.getFocus().id;│ │156 try box.children.put(allocator, auth_tab.getFocus().id, .{ │ │157 .widget = .{ .auth_tab = auth_tab }, │ │158 .rect = null, │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │177 │ │178 var self = View{ │ │179 .scroll = try wgt.Scroll(ui.Widget).init(allocator, .{ .box = box }, .{ .direction = .horiz, .show_bar = false, .web_native = !session.is_terminal }),│ │178 - .data = data, │ │180 .tab_ids = tab_ids, │ │181 }; │ │182 self.getFocus().child_id = selected_tab orelse self.tab_ids.keys()[0]; │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯