Change UI for failed integrity checks

c16be2ec0e48b6d8df393bbffea8c2fbeb179ee8

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +15 -7Showing whitespace changes
public/script.js+15 -7
@@ -6955,15 +6955,23 @@ export async function saveChat({ chatName, withMetadata, mesId, force = false }
6955 throw new Error(result.statusText);6955 throw new Error(result.statusText);
6956 }6956 }
69576957
6958 const forceSaveConfirmed = await Popup.show.confirm(6958 const popupResult = await Popup.show.input(
6959 t`ERROR: Chat integrity check failed.`,6959 t`ERROR: Chat integrity check failed while saving the file.`,
6960 t`Continuing the operation may result in data loss. Would you like to overwrite the chat file anyway? Pressing "NO" will cancel the save operation.`,6960 t`<p>After you click OK, the page will be reloaded to prevent data corruption.</p>
6961 { okButton: t`Yes, overwrite`, cancelButton: t`No, cancel` },6961 <p>To confirm an overwrite (and potentially <b>LOSE YOUR DATA</b>), enter <code>OVERWRITE</code> (in all caps) in the box below before clicking OK.</p>`,
6962 ) === POPUP_RESULT.AFFIRMATIVE;6962 '',
6963 { okButton: 'OK', cancelButton: false },
6964 );
69636965
6964 if (forceSaveConfirmed) {6966 const forceSaveConfirmed = popupResult === 'OVERWRITE';
6965 await saveChat({ chatName, withMetadata, mesId, force: true });6967
6968 if (!forceSaveConfirmed) {
6969 console.warn('Chat integrity check failed, and user did not confirm the overwrite. Reloading the page.');
6970 window.location.reload();
6971 return;
6966 }6972 }
6973
6974 await saveChat({ chatName, withMetadata, mesId, force: true });
6967 } catch (error) {6975 } catch (error) {
6968 console.error(error);6976 console.error(error);
6969 toastr.error(t`Check the server connection and reload the page to prevent data loss.`, t`Chat could not be saved`);6977 toastr.error(t`Check the server connection and reload the page to prevent data loss.`, t`Chat could not be saved`);