╭ changed ──────────────╮ │src/ui/Repo/Threads.zig│ ╰───────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭────────────────────────────────────────────────────────────────────────────────────╮ │345 const Event = Data.Event; │ │346 const Status = Data.Status; │ │347 const has_status = @hasField(Event, "status"); │ │348 - const has_conflicts = Event.merge_policy == .field_conflicts; │ │349 - const has_drafts = @hasField(Self, "drafts"); │ │350 - const FieldConflict = if (has_conflicts) Data.FieldConflict else void; │ │348 + const supports_conflicts = Event.merge_policy == .field_conflicts; │ │349 + const supports_drafts = @hasField(Self, "drafts"); │ │350 + const FieldConflict = if (supports_conflicts) Data.FieldConflict else void;│ │351 const ViewKind = Data.ViewKind; │ │352 - const thread_name = switch (kind) { │ │353 - .issue => "issue", │ │354 - .patch => "patch", │ │355 - .discuss => "discussion", │ │356 - else => @compileError("unsupported thread event kind"), │ │357 - }; │ │352 + const thread_name = Data.thread_name; │ │353 │ │354 return struct { │ │355 const This = @This(); │ ╰────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────╮ │377 // the conflicts split; the tab and stack child exist only when the repo │ │378 // has conflicted threads. │ │379 const drafts_view_index: usize = form_view_index + 1; │ │385 - const conflict_view_index: usize = drafts_view_index + @intFromBool(has_drafts); │ │386 - const view_count: usize = conflict_view_index + @intFromBool(has_conflicts); │ │380 + const conflict_view_index: usize = drafts_view_index + @intFromBool(supports_drafts);│ │381 + const view_count: usize = conflict_view_index + @intFromBool(supports_conflicts); │ │382 // indices within a split (the horizontal box inside the stack). │ │383 const list_index: usize = 0; │ │384 const detail_index: usize = 1; │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────╮ │413 } │ │414 │ │415 fn entryConflicted(entry: Entry) bool { │ │421 - return if (has_conflicts) entry.conflicted else false; │ │416 + return if (supports_conflicts) entry.conflicted else false;│ │417 } │ │418 │ │419 fn entryStatus(entry: Entry) Status { │ ╰────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────╮ │421 } │ │422 │ │423 fn entryDraft(entry: Entry) bool { │ │429 - return if (has_drafts) entry.draft else false; │ │424 + return if (supports_drafts) entry.draft else false;│ │425 } │ │426 │ │427 const StatusChange = struct { │ ╰────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │443 } │ │444 │ │445 fn listRoute(identity: []const u8, status: Status, tag: []const u8, selected: []const u8) ?ui.RoutablePage {│ │451 - return switch (kind) { │ │452 - .issue => ui.RoutablePage.repoIssuesRoute(identity, status, tag, selected), │ │453 - .patch => ui.RoutablePage.repoPatchesRoute(identity, status, tag, selected), │ │454 - .discuss => ui.RoutablePage.repoDiscussionsRoute(identity, tag, selected), │ │455 - else => @compileError("unsupported thread event kind"), │ │456 - }; │ │446 + return Data.listRoute(identity, status, tag, selected); │ │447 } │ │448 │ │449 fn draftsRoute(identity: []const u8) ?ui.RoutablePage { │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────╮ │460 - return switch (kind) { │ │461 - .patch => ui.RoutablePage.repoPatchesDraftsRoute(identity), │ │462 - else => null, │ │463 - }; │ │450 + return if (supports_drafts) Data.draftsRoute(identity) else null; │ │451 } │ │452 │ │453 fn conflictsRoute(identity: []const u8, selected: []const u8) ?ui.RoutablePage {│ ╰─────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │467 - return switch (kind) { │ │468 - .issue => ui.RoutablePage.repoIssuesConflictsRoute(identity, selected), │ │469 - .patch => ui.RoutablePage.repoPatchesConflictsRoute(identity, selected), │ │470 - else => @compileError("thread event kind has no conflict route"), │ │471 - }; │ │454 + return if (supports_conflicts) Data.conflictsRoute(identity, selected) else null; │ │455 } │ │456 │ │457 fn resolveRoute(identity: []const u8, selected: []const u8, picks: []const u8) ?ui.RoutablePage {│ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │475 - return switch (kind) { │ │476 - .issue => ui.RoutablePage.repoIssuesResolveRoute(identity, selected, picks), │ │477 - .patch => ui.RoutablePage.repoPatchesResolveRoute(identity, selected, picks), │ │478 - else => @compileError("thread event kind has no resolve route"), │ │479 - }; │ │458 + return if (supports_conflicts) Data.resolveRoute(identity, selected, picks) else null; │ │459 } │ │460 │ │461 fn listLink(page_arena: *std.heap.ArenaAllocator, identity: []const u8, status: Status, tag: []const u8, id: []const u8) ![]const u8 {│ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │478 } │ │479 │ │480 fn windowLink(page_arena: *std.heap.ArenaAllocator, data: *const Self, status_maybe: ?Status, drafts: bool, id: []const u8) ![]const u8 {│ │502 - if (has_conflicts and status_maybe == null and !drafts) { │ │481 + if (supports_conflicts and status_maybe == null and !drafts) { │ │482 const route = conflictsRoute(data.identity, id) orelse return error.RouteTooLong; │ │483 return std.fmt.allocPrint(page_arena.allocator(), "a:{s}", .{try route.toUrl(page_arena)}); │ │484 } │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │502 { │ │503 var hdr = try Data.initHeader(allocator, session, data); │ │504 errdefer hdr.deinit(allocator); │ │526 - switch (kind) { │ │527 - .issue => try outer.children.put(allocator, hdr.getFocus().id, .{ .widget = .{ .repo_issues_header = hdr }, .rect = null, .min_size = null }), │ │528 - .patch => try outer.children.put(allocator, hdr.getFocus().id, .{ .widget = .{ .repo_patches_header = hdr }, .rect = null, .min_size = null }), │ │529 - .discuss => try outer.children.put(allocator, hdr.getFocus().id, .{ .widget = .{ .repo_discussions_header = hdr }, .rect = null, .min_size = null }),│ │530 - else => @compileError("unsupported thread event kind"), │ │531 - } │ │505 + try outer.children.put(allocator, hdr.getFocus().id, .{ .widget = @unionInit(ui.Widget, Data.header_widget_name, hdr), .rect = null, .min_size = null });│ │506 } │ │507 │ │508 // the stack enters `outer` before its children enter it, so an error │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯