╭ changed ─╮ │src/ui.zig│ ╰──────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │371 .repo_settings => |a_name| std.mem.eql(u8, a_name.slice(), b.repo_settings.slice()), │ │372 .repo_auth => |a_name| std.mem.eql(u8, a_name.slice(), b.repo_auth.slice()), │ │373 else => true, │ │374 - }; │ │375 - } │ │376 - │ │377 - // the content a repo route renders: which repo, plus the files directory and │ │378 - // commits page. tab switches keep this fixed (the page already holds every │ │379 - // tab's data); a files-directory or commits-page change alters it. │ │380 - const RepoContent = struct { │ │381 - identity: []const u8, │ │382 - ref_or_oid: ?RefOrOid, │ │383 - ref_or_oid_value: []const u8, │ │384 - files_dir: []const u8, │ │385 - commits_ref_or_oid: ?RefOrOid, │ │386 - commits_ref_or_oid_value: []const u8, │ │387 - commits_after: usize, │ │388 - refs_kind: RefKind, │ │389 - refs_after: usize, │ │390 - }; │ │391 - │ │392 - // `r` is borrowed by pointer: the returned slices point into its inline │ │393 - // route string, so it must outlive the RepoContent (passing by value would │ │394 - // leave them dangling into a freed copy). │ │395 - fn repoContent(r: *const RoutablePage) ?RepoContent { │ │396 - const name = switch (r.*) { │ │397 - .repo, .repo_settings, .repo_auth => |*n| n.slice(), │ │398 - .repo_commits => |*c| c.name.slice(), │ │399 - .repo_refs => |*r2| r2.name.slice(), │ │400 - else => return null, │ │401 - }; │ │402 - const files = RepoFiles.parse(name) orelse return null; │ │403 - // a 0 offset means no refs pagination, so canonicalize the column to │ │404 - // branch then — otherwise the base /refs route would look like a content │ │405 - // change relative to the same page mirrored with kind=tag. │ │406 - const refs_after = switch (r.*) { │ │407 - .repo_refs => |r2| r2.after, │ │408 - else => 0, │ │409 - }; │ │410 - const is_files = std.meta.activeTag(r.*) == .repo; │ │411 - const is_commits = std.meta.activeTag(r.*) == .repo_commits; │ │412 - const commits_ref = if (is_commits) repoCommitsRef(name) else CommitsRef{ .ref_or_oid = null, .value = "" };│ │413 - return .{ │ │414 - .identity = files.identity, │ │415 - .ref_or_oid = if (is_files) files.ref_kind else null, │ │416 - .ref_or_oid_value = if (is_files) files.ref_value else "", │ │417 - .files_dir = if (is_files) files.dir else "", │ │418 - .commits_ref_or_oid = commits_ref.ref_or_oid, │ │419 - .commits_ref_or_oid_value = commits_ref.value, │ │420 - .commits_after = switch (r.*) { │ │421 - .repo_commits => |c| c.after, │ │422 - else => 0, │ │423 - }, │ │424 - .refs_kind = switch (r.*) { │ │425 - .repo_refs => |r2| if (refs_after == 0) .branch else r2.kind, │ │426 - else => .branch, │ │427 - }, │ │428 - .refs_after = refs_after, │ │374 }; │ │375 } │ │376 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────╮ │432 - // true when `a` and `b` are both repo routes that render different content │ │377 + // true when following a link from `b` to `a` (both repo routes) should reload │ │378 + // rather than stay in page │ │379 pub fn repoPageChanged(a: RoutablePage, b: RoutablePage) bool { │ │434 - const ca = repoContent(&a) orelse return false; │ │435 - const cb = repoContent(&b) orelse return false; │ │436 - return !std.mem.eql(u8, ca.identity, cb.identity) or │ │437 - ca.ref_or_oid != cb.ref_or_oid or │ │438 - !std.mem.eql(u8, ca.ref_or_oid_value, cb.ref_or_oid_value) or │ │439 - !std.mem.eql(u8, ca.files_dir, cb.files_dir) or │ │440 - ca.commits_ref_or_oid != cb.commits_ref_or_oid or │ │441 - !std.mem.eql(u8, ca.commits_ref_or_oid_value, cb.commits_ref_or_oid_value) or │ │442 - ca.commits_after != cb.commits_after or │ │443 - ca.refs_kind != cb.refs_kind or │ │444 - ca.refs_after != cb.refs_after; │ │380 + if (a.parent() != .repo or b.parent() != .repo) return false; │ │381 + if (std.meta.activeTag(a) == .repo_refs and std.meta.activeTag(b) == .repo_refs and│ │382 + a.repo_refs.after == 0 and b.repo_refs.after == 0) │ │383 + return !std.mem.eql(u8, a.repo_refs.name.slice(), b.repo_refs.name.slice()); │ │384 + return !a.eql(b); │ │385 } │ │386 │ │387 // true when `a` and `b` are the same home list tab paginated to a different │ ╰────────────────────────────────────────────────────────────────────────────────────────────────╯