| author | |
| committer | |
| log | 31eeb443305a4e11c8b20a7c8ff2b3f5e841eb0f |
| tree | e0f34f12a9f23b1dfef59e69c8639c1b37b55bed |
| parent | 9ebbeda5a03fd8fce7be147b65ea396e50721c68 |
| signature | Signed by PGP key B5690EEEBB952194 |
Co-authored-by: maria-rcks <254055478+maria-rcks@users.noreply.github.com>4 files changed, 31 insertions(+), 30 deletions(-)
apps/mobile/src/features/threads/use-thread-list-v2-shelf-preferences.ts+4-4| ... | ... | @@ -14,9 +14,9 @@ export function useThreadListV2ShelfPreferences() { |
| 14 | 14 | const savePreferences = useAtomSet(updateMobilePreferencesAtom); |
| 15 | 15 | const loaded = AsyncResult.isSuccess(preferencesResult); |
| 16 | 16 | const snoozedShelfExpanded = |
| 17 | loaded && preferencesResult.value.threadListV2SnoozedShelfExpanded === true; | |
| 17 | loaded && preferencesResult.value.threadListSnoozedShelfExpanded === true; | |
| 18 | 18 | const settledShelfExpanded = |
| 19 | !loaded || preferencesResult.value.threadListV2SettledShelfExpanded !== false; | |
| 19 | loaded && preferencesResult.value.threadListSettledShelfExpanded === true; | |
| 20 | 20 | const snoozedShelfExpandedRef = useRef(snoozedShelfExpanded); |
| 21 | 21 | const settledShelfExpandedRef = useRef(settledShelfExpanded); |
| 22 | 22 | snoozedShelfExpandedRef.current = snoozedShelfExpanded; |
| ... | ... | @@ -26,13 +26,13 @@ export function useThreadListV2ShelfPreferences() { |
| 26 | 26 | if (!loaded) return; |
| 27 | 27 | const expanded = !snoozedShelfExpandedRef.current; |
| 28 | 28 | snoozedShelfExpandedRef.current = expanded; |
| 29 | savePreferences({ threadListV2SnoozedShelfExpanded: expanded }); | |
| 29 | savePreferences({ threadListSnoozedShelfExpanded: expanded }); | |
| 30 | 30 | }, [loaded, savePreferences]); |
| 31 | 31 | const toggleSettledShelf = useCallback(() => { |
| 32 | 32 | if (!loaded) return; |
| 33 | 33 | const expanded = !settledShelfExpandedRef.current; |
| 34 | 34 | settledShelfExpandedRef.current = expanded; |
| 35 | savePreferences({ threadListV2SettledShelfExpanded: expanded }); | |
| 35 | savePreferences({ threadListSettledShelfExpanded: expanded }); | |
| 36 | 36 | }, [loaded, savePreferences]); |
| 37 | 37 | |
| 38 | 38 | return { |
apps/mobile/src/lib/storage.test.ts+14-12| ... | ... | @@ -213,33 +213,35 @@ describe("mobile connection storage", () => { |
| 213 | 213 | expect(fallback.updatedAt).toEqual(expect.any(Number)); |
| 214 | 214 | }); |
| 215 | 215 | |
| 216 | it("persists Thread List v2 shelf expansion preferences", async () => { | |
| 216 | it("persists thread list shelf expansion preferences", async () => { | |
| 217 | 217 | await expect( |
| 218 | 218 | savePreferencesPatch({ |
| 219 | threadListV2SettledShelfExpanded: false, | |
| 220 | threadListV2SnoozedShelfExpanded: true, | |
| 219 | threadListSettledShelfExpanded: false, | |
| 220 | threadListSnoozedShelfExpanded: true, | |
| 221 | 221 | }), |
| 222 | 222 | ).resolves.toEqual({ |
| 223 | threadListV2SettledShelfExpanded: false, | |
| 224 | threadListV2SnoozedShelfExpanded: true, | |
| 223 | threadListSettledShelfExpanded: false, | |
| 224 | threadListSnoozedShelfExpanded: true, | |
| 225 | 225 | }); |
| 226 | 226 | |
| 227 | 227 | await expect(loadPreferences()).resolves.toEqual({ |
| 228 | threadListV2SettledShelfExpanded: false, | |
| 229 | threadListV2SnoozedShelfExpanded: true, | |
| 228 | threadListSettledShelfExpanded: false, | |
| 229 | threadListSnoozedShelfExpanded: true, | |
| 230 | 230 | }); |
| 231 | 231 | expect(JSON.parse(mocks.getPreferencesJson() ?? "")).toEqual({ |
| 232 | threadListV2SettledShelfExpanded: false, | |
| 233 | threadListV2SnoozedShelfExpanded: true, | |
| 232 | threadListSettledShelfExpanded: false, | |
| 233 | threadListSnoozedShelfExpanded: true, | |
| 234 | 234 | }); |
| 235 | 235 | }); |
| 236 | 236 | |
| 237 | it("ignores invalid Thread List v2 shelf expansion preference types", async () => { | |
| 237 | it("drops legacy and invalid thread list shelf expansion preferences", async () => { | |
| 238 | 238 | mocks.setPreferencesJson( |
| 239 | 239 | JSON.stringify({ |
| 240 | 240 | baseFontSize: 17, |
| 241 | threadListV2SettledShelfExpanded: "false", | |
| 242 | threadListV2SnoozedShelfExpanded: 1, | |
| 241 | threadListV2SettledShelfExpanded: true, | |
| 242 | threadListV2SnoozedShelfExpanded: true, | |
| 243 | threadListSettledShelfExpanded: "false", | |
| 244 | threadListSnoozedShelfExpanded: 1, | |
| 243 | 245 | }), |
| 244 | 246 | 10, |
| 245 | 247 | ); |
apps/mobile/src/persistence/mobile-preferences.ts+9-10| ... | ... | @@ -41,10 +41,9 @@ export interface Preferences { |
| 41 | 41 | readonly legacyThreadListEnabled?: boolean; |
| 42 | 42 | /** Device-local counterpart of desktop's `planModeEnabled` legacy flag. */ |
| 43 | 43 | readonly planModeEnabled?: boolean; |
| 44 | /** Undefined preserves the default expanded Settled shelf. */ | |
| 45 | readonly threadListV2SettledShelfExpanded?: boolean; | |
| 46 | /** Undefined preserves the default collapsed Snoozed shelf. */ | |
| 47 | readonly threadListV2SnoozedShelfExpanded?: boolean; | |
| 44 | /** Fresh keys reset both shelves to collapsed when users update. */ | |
| 45 | readonly threadListSettledShelfExpanded?: boolean; | |
| 46 | readonly threadListSnoozedShelfExpanded?: boolean; | |
| 48 | 47 | } |
| 49 | 48 | |
| 50 | 49 | export class MobilePreferencesLoadError extends Schema.TaggedErrorClass<MobilePreferencesLoadError>()( |
| ... | ... | @@ -102,8 +101,8 @@ function sanitizePreferences(parsed: Preferences): Preferences { |
| 102 | 101 | projectGroupingMode?: SidebarProjectGroupingMode; |
| 103 | 102 | legacyThreadListEnabled?: boolean; |
| 104 | 103 | planModeEnabled?: boolean; |
| 105 | threadListV2SettledShelfExpanded?: boolean; | |
| 106 | threadListV2SnoozedShelfExpanded?: boolean; | |
| 104 | threadListSettledShelfExpanded?: boolean; | |
| 105 | threadListSnoozedShelfExpanded?: boolean; | |
| 107 | 106 | } = {}; |
| 108 | 107 | |
| 109 | 108 | if (typeof parsed.liveActivitiesEnabled === "boolean") { |
| ... | ... | @@ -171,11 +170,11 @@ function sanitizePreferences(parsed: Preferences): Preferences { |
| 171 | 170 | if (typeof parsed.planModeEnabled === "boolean") { |
| 172 | 171 | preferences.planModeEnabled = parsed.planModeEnabled; |
| 173 | 172 | } |
| 174 | if (typeof parsed.threadListV2SettledShelfExpanded === "boolean") { | |
| 175 | preferences.threadListV2SettledShelfExpanded = parsed.threadListV2SettledShelfExpanded; | |
| 173 | if (typeof parsed.threadListSettledShelfExpanded === "boolean") { | |
| 174 | preferences.threadListSettledShelfExpanded = parsed.threadListSettledShelfExpanded; | |
| 176 | 175 | } |
| 177 | if (typeof parsed.threadListV2SnoozedShelfExpanded === "boolean") { | |
| 178 | preferences.threadListV2SnoozedShelfExpanded = parsed.threadListV2SnoozedShelfExpanded; | |
| 176 | if (typeof parsed.threadListSnoozedShelfExpanded === "boolean") { | |
| 177 | preferences.threadListSnoozedShelfExpanded = parsed.threadListSnoozedShelfExpanded; | |
| 179 | 178 | } |
| 180 | 179 | return preferences; |
| 181 | 180 | } |
apps/web/src/components/Sidebar.tsx+4-4| ... | ... | @@ -211,9 +211,9 @@ import { |
| 211 | 211 | // stays behind an explicit Show more. |
| 212 | 212 | const SETTLED_TAIL_INITIAL_COUNT = 10; |
| 213 | 213 | const SETTLED_TAIL_PAGE_COUNT = 25; |
| 214 | // Keep the v2 key so existing preferences survive the v2-to-default rename. | |
| 215 | const SETTLED_SHELF_EXPANDED_KEY = "t3code:sidebar-v2:settled-expanded"; | |
| 216 | const SNOOZED_SHELF_EXPANDED_KEY = "t3code:sidebar-v2:snoozed-expanded"; | |
| 214 | // Fresh keys deliberately reset both shelves to collapsed for existing users. | |
| 215 | const SETTLED_SHELF_EXPANDED_KEY = "t3code:sidebar:settled-expanded"; | |
| 216 | const SNOOZED_SHELF_EXPANDED_KEY = "t3code:sidebar:snoozed-expanded"; | |
| 217 | 217 | |
| 218 | 218 | function compactSidebarTimeLabel(label: string): string { |
| 219 | 219 | if (label === "just now") return "now"; |
| ... | ... | @@ -2274,7 +2274,7 @@ export default function Sidebar() { |
| 2274 | 2274 | ); |
| 2275 | 2275 | const [settledShelfExpanded, setSettledShelfExpanded] = useLocalStorage( |
| 2276 | 2276 | SETTLED_SHELF_EXPANDED_KEY, |
| 2277 | true, | |
| 2277 | false, | |
| 2278 | 2278 | Schema.Boolean, |
| 2279 | 2279 | ); |
| 2280 | 2280 | const toggleSettledShelf = useCallback( |