diff --git a/src/App.tsx b/src/App.tsx index f477e48..1fb36fc 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -441,7 +441,7 @@ function App() { const [creationStep, setCreationStep] = useState(1) const qortalRequestCheckbox1Ref = useRef(null); useRetrieveDataLocalStorage(); - useQortalGetSaveSettings(userInfo?.name); + useQortalGetSaveSettings(userInfo?.name, extState === "authenticated"); const [fullScreen, setFullScreen] = useRecoilState(fullScreenAtom); const { toggleFullScreen } = useAppFullScreen(setFullScreen); diff --git a/src/components/Group/Group.tsx b/src/components/Group/Group.tsx index 6ccdc2a..22e904d 100644 --- a/src/components/Group/Group.tsx +++ b/src/components/Group/Group.tsx @@ -36,6 +36,8 @@ import GroupIcon from "@mui/icons-material/Group"; import PersonIcon from "@mui/icons-material/Person"; import LockIcon from '@mui/icons-material/Lock'; import NoEncryptionGmailerrorredIcon from '@mui/icons-material/NoEncryptionGmailerrorred'; +import LockIcon from '@mui/icons-material/Lock'; +import NoEncryptionGmailerrorredIcon from '@mui/icons-material/NoEncryptionGmailerrorred'; import { AuthenticatedContainerInnerRight, CustomButton, @@ -2368,6 +2370,16 @@ export const Group = ({ justifyContent: "flex-end", }} > + {isPrivate === true && ( + + )} + {isPrivate === false && ( + + )} {/* */} diff --git a/src/components/Mobile/MobileHeader.tsx b/src/components/Mobile/MobileHeader.tsx index 9902a28..6bc5482 100644 --- a/src/components/Mobile/MobileHeader.tsx +++ b/src/components/Mobile/MobileHeader.tsx @@ -139,7 +139,7 @@ const Header = ({ /> - + @@ -295,7 +295,7 @@ const Header = ({ }} > {/* Right Logout Icon */} - + { +import { Spacer } from "../../common/Spacer"; +import { LoadingButton } from "@mui/lab"; +import { saveToLocalStorage } from "../Apps/AppsNavBar"; +export const Save = ({ isDesktop, disableWidth, myName }) => { const [pinnedApps, setPinnedApps] = useRecoilState(sortablePinnedAppsAtom); const [settingsQdnLastUpdated, setSettingsQdnLastUpdated] = useRecoilState( settingsQDNLastUpdatedAtom @@ -31,7 +34,7 @@ export const Save = ({ isDesktop }) => { const [isLoading, setIsLoading] = useState(false); const [infoSnack, setInfoSnack] = useState(null); const [oldPinnedApps, setOldPinnedApps] = useRecoilState(oldPinnedAppsAtom); - + const [anchorEl, setAnchorEl] = useState(null); const { show } = useContext(MyContext); const hasChanged = useMemo(() => { @@ -83,9 +86,7 @@ export const Save = ({ isDesktop }) => { .sendMessage( "ENCRYPT_DATA", { - - data64, - + data64, }, 60000 ) @@ -135,6 +136,7 @@ export const Save = ({ isDesktop }) => { message: "Sucessfully published to QDN", }); setOpenSnack(true); + setAnchorEl(null) } } } catch (error) { @@ -147,19 +149,31 @@ export const Save = ({ isDesktop }) => { setIsLoading(false); } }; + const handlePopupClick = (event) => { + event.stopPropagation(); // Prevent parent onClick from firing + setAnchorEl(event.currentTarget); + }; + + const revertChanges = () => { + setPinnedApps(oldPinnedApps); + saveToLocalStorage("ext_saved_settings", "sortablePinnedApps", null); + setAnchorEl(null) + }; + return ( <> {isDesktop ? ( { /> )} + setAnchorEl(null)} // Close popover on click outside + anchorOrigin={{ + vertical: "bottom", + horizontal: "center", + }} + transformOrigin={{ + vertical: "top", + horizontal: "center", + }} + // sx={{ + // width: "300px", + // maxWidth: "90%", + // maxHeight: "80%", + // overflow: "auto", + // }} + > + + {!myName ? ( + + + You need a registered Qortal name to save your pinned apps to QDN. + + + ) : ( + <> + {hasChanged && ( + + + You have unsaved changes to your pinned apps. Save them to QDN. + + + + Save to QDN + + + {!isNaN(settingsQdnLastUpdated) && settingsQdnLastUpdated > 0 && ( + <> + + Don't like your current local changes? Would you like to + reset to your saved QDN pinned apps? + + + + Revert to QDN + + + )} + {!isNaN(settingsQdnLastUpdated) && settingsQdnLastUpdated === 0 && ( + <> + + Don't like your current local changes? Would you like to + reset to the default pinned apps? + + + + Revert to default + + + )} + + )} + {!isNaN(settingsQdnLastUpdated) && settingsQdnLastUpdated === -100 && ( + + + The app was unable to download your existing QDN-saved pinned + apps. Would you like to overwrite those changes? + + + + Overwrite to QDN + + + )} + {!hasChanged && ( + + + You currently do not have any changes to your pinned apps + + + + )} + + )} + + + { ); data = await res.text(); - if(!data) throw new Error('Unable to fetch publish') const decryptedKey: any = await decryptResource(data); @@ -53,7 +52,8 @@ const getPublishRecord = async (myName) => { } }; -export const useQortalGetSaveSettings = (myName) => { + +export const useQortalGetSaveSettings = (myName, isAuthenticated) => { const setSortablePinnedApps = useSetRecoilState(sortablePinnedAppsAtom); const setCanSave = useSetRecoilState(canSaveSettingToQdnAtom); const setSettingsQDNLastUpdated = useSetRecoilState(settingsQDNLastUpdatedAtom); @@ -67,7 +67,7 @@ export const useQortalGetSaveSettings = (myName) => { const settings = await getPublish(myName) if(settings?.sortablePinnedApps && timestamp > settingsLocalLastUpdated){ setSortablePinnedApps(settings.sortablePinnedApps) - + setSettingsQDNLastUpdated(timestamp || 0) } else if(settings?.sortablePinnedApps){ setSettingsQDNLastUpdated(timestamp || 0) @@ -87,8 +87,8 @@ export const useQortalGetSaveSettings = (myName) => { } }, []) useEffect(()=> { - if(!myName || !settingsLocalLastUpdated) return + if(!myName || !settingsLocalLastUpdated || !isAuthenticated) return getSavedSettings(myName, settingsLocalLastUpdated) - }, [getSavedSettings, myName, settingsLocalLastUpdated]) + }, [getSavedSettings, myName, settingsLocalLastUpdated, isAuthenticated]) } diff --git a/src/useRetrieveDataLocalStorage.tsx b/src/useRetrieveDataLocalStorage.tsx index 88e93f4..8f808ab 100644 --- a/src/useRetrieveDataLocalStorage.tsx +++ b/src/useRetrieveDataLocalStorage.tsx @@ -23,8 +23,11 @@ export const useRetrieveDataLocalStorage = () => { const pinnedAppsLocal = fetchFromLocalStorage('ext_saved_settings') if(pinnedAppsLocal?.sortablePinnedApps){ setSortablePinnedApps(pinnedAppsLocal?.sortablePinnedApps) + setSettingsLocalLastUpdated(pinnedAppsLocal?.timestamp || -1) + } else { + setSettingsLocalLastUpdated(-1) } - setSettingsLocalLastUpdated(pinnedAppsLocal?.timestamp || -1) + }, []) useEffect(()=> {