fix: adding no backup preview condition

This commit is contained in:
Chubby Granny Chaser 2024-09-25 21:07:41 +01:00
parent 89b830fe9a
commit 3e165e05fb
No known key found for this signature in database
4 changed files with 20 additions and 36 deletions

View File

@ -33,9 +33,6 @@ const getNewProfileImageUrl = async (localImageUrl: string) => {
headers: { headers: {
"Content-Type": mimeType, "Content-Type": mimeType,
}, },
onUploadProgress: (progressEvent) => {
console.log(progressEvent);
},
}); });
return profileImageUrl; return profileImageUrl;

View File

@ -25,7 +25,7 @@ export interface CloudSyncContext {
setShowCloudSyncModal: React.Dispatch<React.SetStateAction<boolean>>; setShowCloudSyncModal: React.Dispatch<React.SetStateAction<boolean>>;
downloadGameArtifact: (gameArtifactId: string) => Promise<void>; downloadGameArtifact: (gameArtifactId: string) => Promise<void>;
uploadSaveGame: () => Promise<void>; uploadSaveGame: () => Promise<void>;
deleteGameArtifact: (gameArtifactId: string) => Promise<{ ok: boolean }>; deleteGameArtifact: (gameArtifactId: string) => Promise<void>;
restoringBackup: boolean; restoringBackup: boolean;
uploadingBackup: boolean; uploadingBackup: boolean;
} }
@ -39,7 +39,7 @@ export const cloudSyncContext = createContext<CloudSyncContext>({
downloadGameArtifact: async () => {}, downloadGameArtifact: async () => {},
uploadSaveGame: async () => {}, uploadSaveGame: async () => {},
artifacts: [], artifacts: [],
deleteGameArtifact: async () => ({ ok: false }), deleteGameArtifact: async () => {},
restoringBackup: false, restoringBackup: false,
uploadingBackup: false, uploadingBackup: false,
}); });
@ -135,20 +135,26 @@ export function CloudSyncContextProvider({
async (gameArtifactId: string) => { async (gameArtifactId: string) => {
return window.electron.deleteGameArtifact(gameArtifactId).then(() => { return window.electron.deleteGameArtifact(gameArtifactId).then(() => {
getGameBackupPreview(); getGameBackupPreview();
return { ok: true };
}); });
}, },
[getGameBackupPreview] [getGameBackupPreview]
); );
useEffect(() => { useEffect(() => {
getGameBackupPreview();
window.electron.checkGameCloudSyncSupport(objectId, shop).then((result) => { window.electron.checkGameCloudSyncSupport(objectId, shop).then((result) => {
setSupportsCloudSync(result); setSupportsCloudSync(result);
}); });
}, [objectId, shop, getGameBackupPreview]); }, [objectId, shop, getGameBackupPreview]);
useEffect(() => {
setBackupPreview(null);
setArtifacts([]);
setSupportsCloudSync(null);
setShowCloudSyncModal(false);
setRestoringBackup(false);
setUploadingBackup(false);
}, [objectId, shop]);
useEffect(() => { useEffect(() => {
if (showCloudSyncModal) { if (showCloudSyncModal) {
getGameBackupPreview(); getGameBackupPreview();

View File

@ -46,32 +46,9 @@ export function useUserDetails() {
const updateUserDetails = useCallback( const updateUserDetails = useCallback(
async (userDetails: UserDetails) => { async (userDetails: UserDetails) => {
dispatch(setUserDetails(userDetails)); dispatch(setUserDetails(userDetails));
window.localStorage.setItem("userDetails", JSON.stringify(userDetails));
if (userDetails.profileImageUrl) {
// TODO: Decide if we want to use this
// const profileBackground = await profileBackgroundFromProfileImage(
// userDetails.profileImageUrl
// ).catch((err) => {
// logger.error("profileBackgroundFromProfileImage", err);
// return `#151515B3`;
// });
// dispatch(setProfileBackground(profileBackground));
window.localStorage.setItem(
"userDetails",
JSON.stringify({ ...userDetails, profileBackground })
);
} else {
const profileBackground = `#151515B3`;
dispatch(setProfileBackground(profileBackground));
window.localStorage.setItem(
"userDetails",
JSON.stringify({ ...userDetails, profileBackground })
);
}
}, },
[dispatch, profileBackground] [dispatch]
); );
const fetchUserDetails = useCallback(async () => { const fetchUserDetails = useCallback(async () => {

View File

@ -87,8 +87,12 @@ export function CloudSyncModal({ visible, onClose }: CloudSyncModalProps) {
); );
} }
return "no_backups"; if (!backupPreview) {
}, [uploadingBackup, lastBackup, restoringBackup]); return "no_backup_preview";
}
return "no_artifacts";
}, [uploadingBackup, lastBackup, backupPreview, restoringBackup]);
const disableActions = uploadingBackup || restoringBackup || deletingArtifact; const disableActions = uploadingBackup || restoringBackup || deletingArtifact;
@ -116,7 +120,7 @@ export function CloudSyncModal({ visible, onClose }: CloudSyncModalProps) {
<Button <Button
type="button" type="button"
onClick={uploadSaveGame} onClick={uploadSaveGame}
disabled={disableActions} disabled={disableActions || !backupPreview}
> >
<UploadIcon /> <UploadIcon />
create_backup create_backup