π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Refresh space conversations on foreground
Neeraj Guptaefe1acdd5bed
diff --git a/web/apps/space/src/components/SpaceMessagesPage.tsx b/web/apps/space/src/components/SpaceMessagesPage.tsxindex 9cec0c68b9..a7717e07ad 100644--- a/web/apps/space/src/components/SpaceMessagesPage.tsx+++ b/web/apps/space/src/components/SpaceMessagesPage.tsx@@ -127,6 +127,9 @@ export const SpaceMessagesPage: React.FC<SpaceMessagesPageProps> = ({undefined,);const markedReadSpaceIdRef = React.useRef<string | undefined>(undefined);+ const previousSelectedSpaceIdRef = React.useRef<string | undefined>(+ selectedSpaceId,+ );const selectedConversation = React.useMemo(() =>selectedSpaceId@@ -385,6 +388,34 @@ export const SpaceMessagesPage: React.FC<SpaceMessagesPageProps> = ({void refreshConversations();}, [profile, refreshConversations]);+ React.useEffect(() => {+ const previousSelectedSpaceId = previousSelectedSpaceIdRef.current;+ previousSelectedSpaceIdRef.current = selectedSpaceId;++ if (!profile || selectedSpaceId || !previousSelectedSpaceId) return;+ void refreshConversations();+ }, [profile, refreshConversations, selectedSpaceId]);++ React.useEffect(() => {+ if (!profile) return;++ const refreshWhenVisible = () => {+ if (document.visibilityState == "visible") {+ void refreshConversations();+ }+ };++ window.addEventListener("focus", refreshWhenVisible);+ document.addEventListener("visibilitychange", refreshWhenVisible);+ return () => {+ window.removeEventListener("focus", refreshWhenVisible);+ document.removeEventListener(+ "visibilitychange",+ refreshWhenVisible,+ );+ };+ }, [profile, refreshConversations]);+React.useEffect(() => {if (!selectedSpaceId || !selectedConversation) return;if (markedReadSpaceIdRef.current == selectedSpaceId) return;