Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

project-grouping.logic.ts

33 lines1.1 KB

1import type { ProjectGroupingSettings } from "@t3tools/client-runtime/state/project-grouping";
2import type { SidebarProjectGroupingMode } from "@t3tools/contracts";
3​
4import type { Preferences } from "../persistence/mobile-preferences";
5​
6export const DEFAULT_MOBILE_PROJECT_GROUPING_SETTINGS: ProjectGroupingSettings = {
7 sidebarProjectGroupingMode: "repository",
8 sidebarProjectGroupingOverrides: {},
9};
10​
11export function resolveMobileProjectGroupingSettings(
12 preferences: Preferences,
13): ProjectGroupingSettings {
14 return {
15 sidebarProjectGroupingMode:
16 preferences.projectGroupingMode ??
17 (preferences.projectGroupingEnabled === false ? "separate" : "repository"),
18 sidebarProjectGroupingOverrides: {},
19 };
21​
22/**
23 * Dual-writes the legacy boolean for one release so an OTA rollback to an
24 * older mobile bundle preserves the user's grouping choice.
25 */
26export function mobileProjectGroupingModePatch(
27 mode: SidebarProjectGroupingMode,
28): Partial<Preferences> {
29 return {
30 projectGroupingMode: mode,
31 projectGroupingEnabled: mode !== "separate",
32 };