Skip to content

Commit 2a92294

Browse files
committed
changed alerts to toast notifications
1 parent 4b523fb commit 2a92294

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

popup-page-scripts/popup-page-backup-handler.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ function exportCurrentProfile() {
2323
a.href = url;
2424
a.download = `${currentProfile.PROFILE_NAME}_profile.json`;
2525

26-
2726
// Append to the document, trigger click, and remove
2827
document.body.appendChild(a);
2928
a.click();
@@ -33,10 +32,14 @@ function exportCurrentProfile() {
3332
// Revoke the object URL
3433
URL.revokeObjectURL(url);
3534
logToConsole('Revoked the object URL.');
35+
36+
// Show a toast notification after initiating the download
37+
showToast('Profile Download Initiated', 'success');
3638
} catch (error) {
3739
console.error('Error during profile export:', error);
3840
logToConsole(`Error during profile export: ${error.message}`);
39-
alert('Failed to export profile. Please try again.');
41+
// Use toast notification instead of alert
42+
showToast('Failed to export profile. Please try again.', 'error');
4043
}
4144
}
4245

@@ -107,7 +110,6 @@ async function handleImportProfile(event) {
107110
event.target.value = '';
108111
}
109112

110-
111113
// Function to overwrite the existing profile with the parsed profile
112114
async function overwriteCurrentProfile() {
113115
const parsedProfile = window.tempParsedProfile;
@@ -132,10 +134,12 @@ async function overwriteCurrentProfile() {
132134

133135
updateInterface();
134136
logToConsole(`Profile "${parsedProfile.PROFILE_NAME}" imported and overwritten successfully.`);
135-
alert(`Profile "${parsedProfile.PROFILE_NAME}" has been overwritten successfully.`);
137+
// Use toast notification instead of alert
138+
showToast(`Profile "${parsedProfile.PROFILE_NAME}" has been overwritten successfully.`, 'success');
136139
} catch (error) {
137140
logToConsole(`Failed to save the imported profile: ${error.message}`);
138-
alert('Failed to overwrite the existing profile. Please try again.');
141+
// Use toast notification instead of alert
142+
showToast('Failed to overwrite the existing profile. Please try again.', 'error');
139143
}
140144

141145
// Hide the confirmation div
@@ -145,7 +149,6 @@ async function overwriteCurrentProfile() {
145149
window.tempParsedProfile = null;
146150
}
147151

148-
149152
// Function to cancel the import process
150153
function cancelImport() {
151154
logToConsole('User canceled the profile overwrite.');
@@ -173,14 +176,15 @@ async function importProfile(parsedProfile) {
173176

174177
updateInterface();
175178
logToConsole(`Profile "${parsedProfile.PROFILE_NAME}" imported successfully.`);
176-
alert(`Profile "${parsedProfile.PROFILE_NAME}" has been imported successfully.`);
179+
// Use toast notification instead of alert
180+
showToast(`Profile "${parsedProfile.PROFILE_NAME}" has been imported successfully.`, 'success');
177181
} catch (error) {
178182
logToConsole(`Failed to save the imported profile: ${error.message}`);
179-
alert('Failed to import the profile. Please try again.');
183+
// Use toast notification instead of alert
184+
showToast('Failed to import the profile. Please try again.', 'error');
180185
}
181186
}
182187

183-
184188
// Attach event listeners after DOM content is loaded
185189
document.addEventListener('DOMContentLoaded', () => {
186190
// Export Profile button

0 commit comments

Comments
 (0)