Skip to content

Commit

Permalink
Add "Disable synchronisation" to Joplin Cloud invalid credentials war…
Browse files Browse the repository at this point in the history
…ning.
  • Loading branch information
Vortrix5 committed Jan 22, 2025
1 parent 64d1da9 commit 5bb0179
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions packages/app-desktop/gui/MainScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ class MainScreenComponent extends React.Component<Props, State> {

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();
}
Expand Down Expand Up @@ -465,6 +465,11 @@ class MainScreenComponent extends React.Component<Props, State> {
});
};

const onViewJoplinCloudDisableSync = async () => {
Setting.setValue('sync.target', null);
await Setting.saveAll();
};

const onViewSyncSettingsScreen = () => {
this.props.dispatch({
type: 'NAV_GO',
Expand Down Expand Up @@ -560,8 +565,10 @@ class MainScreenComponent extends React.Component<Props, State> {
} 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,
);
}

Expand All @@ -575,17 +582,17 @@ class MainScreenComponent extends React.Component<Props, State> {
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
Expand Down

0 comments on commit 5bb0179

Please sign in to comment.