mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-03 08:43:48 +03:00
fix: adding no backup preview condition
This commit is contained in:
parent
89b830fe9a
commit
3e165e05fb
@ -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;
|
||||||
|
@ -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();
|
||||||
|
@ -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 () => {
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user