π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[photos][web] Extract gallery changelog controller
AswinAsok92633ed9a871
diff --git a/web/apps/photos/src/components/DesktopWhatsNew.tsx b/web/apps/photos/src/components/DesktopWhatsNew.tsxnew file mode 100644index 0000000000..182f84a30b--- /dev/null+++ b/web/apps/photos/src/components/DesktopWhatsNew.tsx@@ -0,0 +1,33 @@+import { shouldShowWhatsNew } from "@/services/changelog";+import { useModalVisibility } from "ente-base/components/utils/modal";+import log from "ente-base/log";+import { useEffect } from "react";+import { WhatsNew } from "./WhatsNew";++/** Desktop changelog dialog, enabled after the gallery's initial sync. */+export const DesktopWhatsNew: React.FC<{ enabled: boolean }> = ({+ enabled,+}) => {+ const { show, props } = useModalVisibility();++ useEffect(() => {+ const electron = globalThis.electron;+ if (!enabled || !electron) return;++ let cancelled = false;++ const check = async () => {+ if ((await shouldShowWhatsNew(electron)) && !cancelled) show();+ };++ void check().catch((error: unknown) => {+ log.warn("Failed to check whether to show What's New", error);+ });++ return () => {+ cancelled = true;+ };+ }, [enabled, show]);++ return <WhatsNew {...props} open={enabled && props.open} />;+};diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex ed0cd2565f..15338350db 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -6,6 +6,7 @@ import {CollectionSelector,type CollectionSelectorAttributes,} from "@/components/CollectionSelector";+import { DesktopWhatsNew } from "@/components/DesktopWhatsNew";import { FamilyManagement } from "@/components/FamilyManagement";import type { FileListHeaderOrFooter } from "@/components/FileList";import { FileListWithViewer } from "@/components/FileListWithViewer";@@ -18,7 +19,6 @@ import {type FileOp,} from "@/components/SelectedFileOptions";import { Upload } from "@/components/Upload";-import { WhatsNew } from "@/components/WhatsNew";import { AlbumSlideshow } from "@/components/collections/AlbumSlideshow";import { CollectionMap } from "@/components/collections/CollectionMap";import {@@ -57,7 +57,6 @@ import {notifyUnsupportedSharedFavoritesDialogAttributes,trashFilesDialogAttributes,} from "@/components/utils/dialog-attributes";-import { shouldShowWhatsNew } from "@/services/changelog";import exportService from "@/services/export";import { processPendingAlbumJoin } from "@/services/join-album";import {@@ -208,6 +207,7 @@ const Page: React.FC = () => {>();const isCleanupViewOpen = cleanupView !== undefined;const [isFirstLoad, setIsFirstLoad] = useState(false);+ const [isWhatsNewReady, setIsWhatsNewReady] = useState(false);const [isContextMenuOpen, setIsContextMenuOpen] = useState(false);const [suppressContextSelectionBar, setSuppressContextSelectionBar] =useState(false);@@ -313,8 +313,6 @@ const Page: React.FC = () => {show: showFamilyManagement,props: familyManagementVisibilityProps,} = useModalVisibility();- const { show: showWhatsNew, props: whatsNewVisibilityProps } =- useModalVisibility();const { show: showFixCreationTime, props: fixCreationTimeVisibilityProps } =useModalVisibility();const {@@ -773,7 +771,7 @@ const Page: React.FC = () => {void remotePull({ silent: true, source: "desktop-focus" });void watcher.checkAccessibility();});- if (await shouldShowWhatsNew(electron)) showWhatsNew();+ setIsWhatsNewReady(true);}})();@@ -2585,7 +2583,7 @@ const Page: React.FC = () => {renderSubscriptionDialogs(onRootClose)}</Sidebar>- <WhatsNew {...whatsNewVisibilityProps} />+ <DesktopWhatsNew enabled={isWhatsNewReady} /><PeopleConsentDialog{...peopleConsentVisibilityProps}onClose={() => {