Skip to content

Commit

Permalink
fix: changelog on mobile not appearing
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardoperra committed Dec 11, 2023
1 parent b831b74 commit 4af79e6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 33 deletions.
7 changes: 6 additions & 1 deletion apps/codeimage/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {getRootEditorStore} from '@codeimage/store/editor';
import {EditorConfigStore} from '@codeimage/store/editor/config.store';
import {getThemeStore} from '@codeimage/store/theme/theme.store';
import {getUiStore} from '@codeimage/store/ui';
import {VersionStore} from '@codeimage/store/version/version.store';
import {
backgroundColorVar,
CodeImageThemeProvider,
Expand Down Expand Up @@ -54,10 +55,14 @@ const Editor = () => {
getThemeStore().loadThemes();

const editorConfig = provideState(EditorConfigStore);
const versionState = provideState(VersionStore);

return (
<Suspense fallback={<EditorPageSkeleton />}>
<Show fallback={<EditorPageSkeleton />} when={editorConfig.get.ready}>
<Show
fallback={<EditorPageSkeleton />}
when={editorConfig.get.ready && versionState.ready()}
>
<Page />
</Show>
</Suspense>
Expand Down
1 change: 0 additions & 1 deletion apps/codeimage/src/mdx/Video.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {themeVars} from '@codeui/kit';
import {JSX, onCleanup, onMount} from 'solid-js';
import * as styles from './components.css';

Expand Down
66 changes: 35 additions & 31 deletions apps/codeimage/src/state/version/version.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,43 +70,47 @@ export const VersionStore = defineStore<VersionStore>(initialValue)
onMount(() => {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const owner = getOwner()!;
_.idb.get().then(data => {
if (data) {
const currentVersion = appEnvironment.version;
const previousVersion = data.appVersion;
const isFirstTime = data.seen.length === 0;
const hasNewUpdate = !data.seen.includes(currentVersion);
if (currentVersion !== previousVersion) {
data.appVersion = currentVersion;
data.previousAppVersion = previousVersion;
console.info(
`New app version: ${previousVersion} -> ${currentVersion}`,
);
Object.values(data.features).forEach(feature => {
feature.seen[currentVersion] = 0;
});
}
if (isFirstTime || hasNewUpdate) {
controlledDialog(Changelog, {latest: false});
batch(() => {
seeLatestVersion();
_.idb
.get()
.then(data => {
if (data) {
const currentVersion = appEnvironment.version;
const previousVersion = data.appVersion;
const isFirstTime = data.seen.length === 0;
const hasNewUpdate = !data.seen.includes(currentVersion);
if (currentVersion !== previousVersion) {
data.appVersion = currentVersion;
data.previousAppVersion = previousVersion;
console.info(
`New app version: ${previousVersion} -> ${currentVersion}`,
);
Object.values(data.features).forEach(feature => {
feature.seen[currentVersion] = 0;
});
}
if (isFirstTime || hasNewUpdate) {
controlledDialog(Changelog, {latest: false});
batch(() => {
seeLatestVersion();
_.set(() => data);
});
} else {
const versionSeen = new Set([...data.seen, currentVersion]);
data.seen = [...versionSeen];
_.set(() => data);
});
} else {
const versionSeen = new Set([...data.seen, currentVersion]);
data.seen = [...versionSeen];
_.set(() => data);
}
setReady(true);
}
setReady(true);
}

runWithOwner(owner, () =>
createEffect(on(_, state => _.idb.set(unwrap(state)))),
);
});
runWithOwner(owner, () =>
createEffect(on(_, state => _.idb.set(unwrap(state)))),
);
})
.finally(() => setReady(true));
});

return {
ready,
see(featureName: FeatureName, log?: boolean) {
if (!untrack(() => _().features.hasOwnProperty(featureName))) {
console.warn(`Feature ${featureName} does not exists.`);
Expand Down

0 comments on commit 4af79e6

Please sign in to comment.