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 }
69556955 throw new Error(result.statusText);
69566956 }
69576957
69586958 const forceSaveConfirmedpopupResult = await Popup.show.confirminput(
69596959 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;
69666972 }
6973+
6974+ await saveChat({ chatName, withMetadata, mesId, force: true });
69676975 } catch (error) {
69686976 console.error(error);
69696977 toastr.error(t`Check the server connection and reload the page to prevent data loss.`, t`Chat could not be saved`);