mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 19:33:11 +02:00
Bug/v2/onboarding slides fix (#5005)
# Description of Changes - Stop onboarding from appearing before logging in - Also (should've done this in a different PR) fixed a small bug in settings when changing logo --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### Translations (if applicable) - [ ] I ran [`scripts/counter_translation.py`](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/docs/counter_translation.md) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details. --------- Co-authored-by: Anthony Stirling <[email protected]> Co-authored-by: Connor Yoh <[email protected]>
This commit is contained in:
co-authored by
Anthony Stirling
Connor Yoh
parent
2277a94c91
commit
f8386843d4
+21
-5
@@ -54,6 +54,7 @@ export default function AdminGeneralSection() {
|
||||
const [originalSettingsSnapshot, setOriginalSettingsSnapshot] = useState<string>('');
|
||||
const [isDirty, setLocalIsDirty] = useState(false);
|
||||
const isInitialLoad = useRef(true);
|
||||
const justSavedRef = useRef(false);
|
||||
|
||||
const {
|
||||
settings,
|
||||
@@ -158,9 +159,12 @@ export default function AdminGeneralSection() {
|
||||
}
|
||||
}, [loginEnabled, fetchSettings]);
|
||||
|
||||
// Snapshot original settings after initial load and sync local preference with server
|
||||
// Snapshot original settings after initial load OR after successful save (when refetch completes)
|
||||
useEffect(() => {
|
||||
if (!loading && isInitialLoad.current && Object.keys(settings).length > 0) {
|
||||
if (loading || Object.keys(settings).length === 0) return;
|
||||
|
||||
// After initial load: set snapshot and sync preference
|
||||
if (isInitialLoad.current) {
|
||||
setOriginalSettingsSnapshot(JSON.stringify(settings));
|
||||
|
||||
// Sync local preference with server setting on initial load to ensure they're in sync
|
||||
@@ -170,8 +174,17 @@ export default function AdminGeneralSection() {
|
||||
}
|
||||
|
||||
isInitialLoad.current = false;
|
||||
return;
|
||||
}
|
||||
}, [loading, settings, loginEnabled, updatePreference]);
|
||||
|
||||
// After save: update snapshot to new server state so dirty tracking is accurate
|
||||
if (justSavedRef.current) {
|
||||
setOriginalSettingsSnapshot(JSON.stringify(settings));
|
||||
setLocalIsDirty(false);
|
||||
setIsDirty(false);
|
||||
justSavedRef.current = false;
|
||||
}
|
||||
}, [loading, settings, loginEnabled, updatePreference, setIsDirty]);
|
||||
|
||||
// Track dirty state by comparing current settings to snapshot
|
||||
useEffect(() => {
|
||||
@@ -238,6 +251,9 @@ export default function AdminGeneralSection() {
|
||||
}
|
||||
|
||||
try {
|
||||
// Mark that we just saved - the snapshot will be updated when refetch completes
|
||||
justSavedRef.current = true;
|
||||
|
||||
await saveSettings();
|
||||
|
||||
// Update local preference after successful save so the app reflects the saved logo style
|
||||
@@ -245,12 +261,12 @@ export default function AdminGeneralSection() {
|
||||
updatePreference('logoVariant', settings.ui.logoStyle);
|
||||
}
|
||||
|
||||
// Update snapshot to current settings after successful save
|
||||
setOriginalSettingsSnapshot(JSON.stringify(settings));
|
||||
// Clear dirty state immediately (snapshot will be updated by effect when refetch completes)
|
||||
setLocalIsDirty(false);
|
||||
markClean();
|
||||
showRestartModal();
|
||||
} catch (_error) {
|
||||
justSavedRef.current = false;
|
||||
alert({
|
||||
alertType: 'error',
|
||||
title: t('admin.error', 'Error'),
|
||||
|
||||
@@ -222,6 +222,7 @@ const AdminPlanSection: React.FC = () => {
|
||||
buttonColor="orange.7"
|
||||
/>
|
||||
)}
|
||||
|
||||
<AvailablePlansSection
|
||||
plans={plans}
|
||||
currentLicenseInfo={licenseInfo}
|
||||
|
||||
Reference in New Issue
Block a user