Make mobile Thread List v2 the default (#4717)
This commit is contained in:
1 parent
dd5ea32488
commit
b0c4992c79
4 files changed
+24
-63
No files matched your search
@@ -40,43 +40,21 @@ function makeThread(
|
||||
const NOW = "2026-06-02T00:00:00.000Z";
|
||||
|
||||
describe("resolveThreadListV2Enabled", () => {
|
||||
it.each(["development", "preview"])("defaults on for the %s variant", (appVariant) => {
|
||||
expect(
|
||||
resolveThreadListV2Enabled({ preference: undefined, preferencesLoaded: true, appVariant }),
|
||||
).toBe(true);
|
||||
it("defaults on when the device has never chosen", () => {
|
||||
expect(resolveThreadListV2Enabled({ preference: undefined, preferencesLoaded: true })).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
it.each(["production", undefined])("defaults off for the %s variant", (appVariant) => {
|
||||
expect(
|
||||
resolveThreadListV2Enabled({ preference: undefined, preferencesLoaded: true, appVariant }),
|
||||
).toBe(false);
|
||||
it("honors an explicit device opt-out", () => {
|
||||
expect(resolveThreadListV2Enabled({ preference: false, preferencesLoaded: true })).toBe(false);
|
||||
expect(resolveThreadListV2Enabled({ preference: true, preferencesLoaded: true })).toBe(true);
|
||||
});
|
||||
|
||||
it("prefers an explicit device choice over the variant default", () => {
|
||||
expect(
|
||||
resolveThreadListV2Enabled({
|
||||
preference: false,
|
||||
preferencesLoaded: true,
|
||||
appVariant: "preview",
|
||||
}),
|
||||
).toBe(false);
|
||||
expect(
|
||||
resolveThreadListV2Enabled({
|
||||
preference: true,
|
||||
preferencesLoaded: true,
|
||||
appVariant: "production",
|
||||
}),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("holds v1 while preferences are still loading so the list does not remount", () => {
|
||||
expect(
|
||||
resolveThreadListV2Enabled({
|
||||
preference: undefined,
|
||||
preferencesLoaded: false,
|
||||
appVariant: "development",
|
||||
}),
|
||||
).toBe(false);
|
||||
it("holds the default while preferences are still loading so the list does not remount", () => {
|
||||
expect(resolveThreadListV2Enabled({ preference: undefined, preferencesLoaded: false })).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -19,34 +19,23 @@ export const THREAD_LIST_V2_SETTLED_INITIAL_COUNT = 10;
|
||||
export const THREAD_LIST_V2_SETTLED_PAGE_COUNT = 25;
|
||||
|
||||
/**
|
||||
* Whether Thread List v2 is on by default for an app variant. The `development`
|
||||
* and `preview` variants are mobile's nightly equivalents and opt in;
|
||||
* `production` stays on v1. Counterpart of web's `resolveSidebarV2Default`.
|
||||
*/
|
||||
export function resolveThreadListV2Default(appVariant: unknown): boolean {
|
||||
return appVariant === "development" || appVariant === "preview";
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolved Thread List v2 state: the device-local preference if the user has
|
||||
* set one, otherwise the default for this app variant. Preferences persist as
|
||||
* sparse patches, so `undefined` genuinely means "never chosen".
|
||||
* Thread List v2 is on by default on every app variant; the Settings → Beta
|
||||
* toggle is an opt-out. Preferences persist as sparse patches, so `undefined`
|
||||
* genuinely means "never chosen".
|
||||
*
|
||||
* `preferencesLoaded` guards the startup window: preferences load
|
||||
* asynchronously, and treating "still loading" as "never chosen" would mount
|
||||
* v2 on a development build and then flip to v1 once a stored opt-out arrives,
|
||||
* remounting the whole list. While loading, hold v1 — the state both variants
|
||||
* already start from.
|
||||
* asynchronously, and rendering one list before the stored choice arrives would
|
||||
* remount the whole thing a tick later. While loading, hold the default — that
|
||||
* is where every device without an explicit opt-out lands anyway.
|
||||
*/
|
||||
export function resolveThreadListV2Enabled(input: {
|
||||
readonly preference: boolean | undefined;
|
||||
readonly preferencesLoaded: boolean;
|
||||
readonly appVariant: unknown;
|
||||
}): boolean {
|
||||
if (!input.preferencesLoaded) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return input.preference ?? resolveThreadListV2Default(input.appVariant);
|
||||
return input.preference ?? true;
|
||||
}
|
||||
|
||||
export function resolveThreadListV2Status(
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
import { useAtomValue } from "@effect/atom-react";
|
||||
import { AsyncResult } from "effect/unstable/reactivity";
|
||||
import Constants from "expo-constants";
|
||||
|
||||
import { mobilePreferencesAtom } from "../../state/preferences";
|
||||
import { resolveThreadListV2Enabled } from "./threadListV2";
|
||||
|
||||
/**
|
||||
* Resolved Thread List v2 state: the device-local preference if the user has
|
||||
* set one, otherwise the default for this app variant (on for development and
|
||||
* preview, off for production). Every consumer must read through this rather
|
||||
* than the raw preference, which is undefined until explicitly chosen.
|
||||
*
|
||||
* Kept out of `state/preferences.ts` so that module stays importable from node
|
||||
* test environments, which have no `__DEV__` for expo-constants.
|
||||
* set one, otherwise the default (on). Every consumer must read through this
|
||||
* rather than the raw preference, which is undefined until explicitly chosen.
|
||||
*/
|
||||
export function useThreadListV2Enabled(): boolean {
|
||||
const preferencesResult = useAtomValue(mobilePreferencesAtom);
|
||||
@@ -20,6 +15,5 @@ export function useThreadListV2Enabled(): boolean {
|
||||
return resolveThreadListV2Enabled({
|
||||
preference: loaded ? preferencesResult.value.threadListV2Enabled : undefined,
|
||||
preferencesLoaded: loaded,
|
||||
appVariant: Constants.expoConfig?.extra?.appVariant,
|
||||
});
|
||||
}
|
||||
@@ -25,9 +25,9 @@ export interface Preferences {
|
||||
readonly projectGroupingEnabled?: boolean;
|
||||
/**
|
||||
* Device-local mirror of the web beta's `sidebarV2Enabled`. Mobile has no
|
||||
* client-settings sync, so the flat v2 thread list is opted into per
|
||||
* device. Undefined means the user has never chosen, in which case the app
|
||||
* variant decides — see `resolveThreadListV2Enabled`.
|
||||
* client-settings sync, so the flat v2 thread list is opted out of per
|
||||
* device. Undefined means the user has never chosen, which resolves to on —
|
||||
* see `resolveThreadListV2Enabled`.
|
||||
*/
|
||||
readonly threadListV2Enabled?: boolean;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user