fix(app): classify existing web profiles for layout transition (#38117)
Co-authored-by: Brendan Allan <14191578+Brendonovich@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { describe, expect, test } from "bun:test"
|
import { describe, expect, test } from "bun:test"
|
||||||
import {
|
import {
|
||||||
|
hasExistingWebState,
|
||||||
isAppUpgrade,
|
isAppUpgrade,
|
||||||
layoutTransitionState,
|
layoutTransitionState,
|
||||||
maximumSunsetTimeout,
|
maximumSunsetTimeout,
|
||||||
@@ -23,6 +24,12 @@ describe("layout transition", () => {
|
|||||||
expect(layoutTransitionState(true, true, false, false)).toEqual({ available: true, notice: false })
|
expect(layoutTransitionState(true, true, false, false)).toEqual({ available: true, notice: false })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("classifies web profiles from existing settings or a recorded version", () => {
|
||||||
|
expect(hasExistingWebState("{}", undefined)).toBe(true)
|
||||||
|
expect(hasExistingWebState(null, "1.17.19")).toBe(true)
|
||||||
|
expect(hasExistingWebState(null, undefined)).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
test("preserves explicit and default layout preferences", () => {
|
test("preserves explicit and default layout preferences", () => {
|
||||||
expect(resolveNewLayoutDesigns(false, false, true)).toBe(false)
|
expect(resolveNewLayoutDesigns(false, false, true)).toBe(false)
|
||||||
expect(resolveNewLayoutDesigns(false, undefined, false)).toBe(false)
|
expect(resolveNewLayoutDesigns(false, undefined, false)).toBe(false)
|
||||||
|
|||||||
@@ -89,6 +89,13 @@ export function shouldDisplayTabsToast(
|
|||||||
return isAppUpgrade(previous, current) || (!previous && existingInstall)
|
return isAppUpgrade(previous, current) || (!previous && existingInstall)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function hasExistingWebState(
|
||||||
|
settings: Promise<string> | string | null,
|
||||||
|
previousVersion: string | undefined,
|
||||||
|
) {
|
||||||
|
return settings !== null || previousVersion !== undefined
|
||||||
|
}
|
||||||
|
|
||||||
export function shouldEnableNewLayout(previous: string | undefined, current: string | undefined) {
|
export function shouldEnableNewLayout(previous: string | undefined, current: string | undefined) {
|
||||||
if (!current) return false
|
if (!current) return false
|
||||||
const currentComparison = compareVersions(current, newLayoutDesignsUpgradeCutoff)
|
const currentComparison = compareVersions(current, newLayoutDesignsUpgradeCutoff)
|
||||||
@@ -220,7 +227,7 @@ export const { use: useSettings, provider: SettingsProvider } = createSimpleCont
|
|||||||
gate: false,
|
gate: false,
|
||||||
init: () => {
|
init: () => {
|
||||||
const platform = usePlatform()
|
const platform = usePlatform()
|
||||||
const [store, setStore, _, ready] = persisted("settings.v3", createStore<Settings>(defaultSettings))
|
const [store, setStore, settingsInit, ready] = persisted("settings.v3", createStore<Settings>(defaultSettings))
|
||||||
const [launch, setLaunch, , launchReady] = persisted(
|
const [launch, setLaunch, , launchReady] = persisted(
|
||||||
"app-version.v1",
|
"app-version.v1",
|
||||||
createStore<{ version?: string }>({ version: undefined }),
|
createStore<{ version?: string }>({ version: undefined }),
|
||||||
@@ -293,6 +300,16 @@ export const { use: useSettings, provider: SettingsProvider } = createSimpleCont
|
|||||||
setLaunch("version", platform.version)
|
setLaunch("version", platform.version)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
createEffect(() => {
|
||||||
|
if (!ready() || !launchState.classified || platform.platform !== "web") return
|
||||||
|
if (layoutTransitionClassified()) return
|
||||||
|
setStore(
|
||||||
|
"general",
|
||||||
|
"layoutTransitionEligible",
|
||||||
|
hasExistingWebState(settingsInit, launchState.previous),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
if (!ready() || !launchState.classified || launchState.migrationApplied) return
|
if (!ready() || !launchState.classified || launchState.migrationApplied) return
|
||||||
if (layoutUpgrade() && store.general?.newLayoutDesigns !== true) {
|
if (layoutUpgrade() && store.general?.newLayoutDesigns !== true) {
|
||||||
|
|||||||
Reference in New Issue
Block a user