From 5bb01796616956c50ceabcc1940da22940d87219 Mon Sep 17 00:00:00 2001 From: Amine Zouaoui Date: Wed, 22 Jan 2025 15:54:40 +0100 Subject: [PATCH] Add "Disable synchronisation" to Joplin Cloud invalid credentials warning. --- packages/app-desktop/gui/MainScreen.tsx | 35 +++++++++++++++---------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/packages/app-desktop/gui/MainScreen.tsx b/packages/app-desktop/gui/MainScreen.tsx index 195c689e9c..c4fd12f90a 100644 --- a/packages/app-desktop/gui/MainScreen.tsx +++ b/packages/app-desktop/gui/MainScreen.tsx @@ -305,8 +305,8 @@ class MainScreenComponent extends React.Component { public componentDidUpdate(prevProps: Props, prevState: State) { if (prevProps.style.width !== this.props.style.width || - prevProps.style.height !== this.props.style.height || - this.messageBoxVisible(prevProps) !== this.messageBoxVisible(this.props) + prevProps.style.height !== this.props.style.height || + this.messageBoxVisible(prevProps) !== this.messageBoxVisible(this.props) ) { this.updateRootLayoutSize(); } @@ -465,6 +465,11 @@ class MainScreenComponent extends React.Component { }); }; + const onViewJoplinCloudDisableSync = async () => { + Setting.setValue('sync.target', null); + await Setting.saveAll(); + }; + const onViewSyncSettingsScreen = () => { this.props.dispatch({ type: 'NAV_GO', @@ -560,8 +565,10 @@ class MainScreenComponent extends React.Component { } else if (this.props.showInvalidJoplinCloudCredential) { msg = this.renderNotificationMessage( _('Your Joplin Cloud credentials are invalid, please login.'), - _('Login to Joplin Cloud.'), + _('Login to Joplin Cloud'), onViewJoplinCloudLoginScreen, + _('Disable synchronisation'), + onViewJoplinCloudDisableSync, ); } @@ -575,17 +582,17 @@ class MainScreenComponent extends React.Component { public messageBoxVisible(props: Props = null) { if (!props) props = this.props; return props.hasDisabledSyncItems || - props.showMissingMasterKeyMessage || - props.hasMissingSyncCredentials || - props.showNeedUpgradingMasterKeyMessage || - props.showShouldReencryptMessage || - props.hasDisabledEncryptionItems || - this.props.shouldUpgradeSyncTarget || - props.isSafeMode || - this.showShareInvitationNotification(props) || - this.props.needApiAuth || - !!this.props.mustUpgradeAppMessage || - props.showInvalidJoplinCloudCredential; + props.showMissingMasterKeyMessage || + props.hasMissingSyncCredentials || + props.showNeedUpgradingMasterKeyMessage || + props.showShouldReencryptMessage || + props.hasDisabledEncryptionItems || + this.props.shouldUpgradeSyncTarget || + props.isSafeMode || + this.showShareInvitationNotification(props) || + this.props.needApiAuth || + !!this.props.mustUpgradeAppMessage || + props.showInvalidJoplinCloudCredential; } // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied