1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00

Desktop, Mobile: Fixes #9157: Clear "Some items cannot be synchronised" banner after situation is resolved

This commit is contained in:
Laurent Cozic 2024-01-27 16:59:19 +00:00
parent e4854b0bc2
commit 149e409bfa
9 changed files with 50 additions and 10 deletions

View File

@ -973,6 +973,7 @@ packages/lib/services/synchronizer/syncInfoUtils.js
packages/lib/services/synchronizer/synchronizer_LockHandler.test.js
packages/lib/services/synchronizer/synchronizer_MigrationHandler.test.js
packages/lib/services/synchronizer/tools.js
packages/lib/services/synchronizer/utils/checkDisabledSyncItemsNotification.js
packages/lib/services/synchronizer/utils/handleConflictAction.js
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.js
packages/lib/services/synchronizer/utils/resourceRemotePath.js

1
.gitignore vendored
View File

@ -953,6 +953,7 @@ packages/lib/services/synchronizer/syncInfoUtils.js
packages/lib/services/synchronizer/synchronizer_LockHandler.test.js
packages/lib/services/synchronizer/synchronizer_MigrationHandler.test.js
packages/lib/services/synchronizer/tools.js
packages/lib/services/synchronizer/utils/checkDisabledSyncItemsNotification.js
packages/lib/services/synchronizer/utils/handleConflictAction.js
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.js
packages/lib/services/synchronizer/utils/resourceRemotePath.js

View File

@ -81,10 +81,10 @@ function StatusScreen(props: Props) {
);
}
const renderRetryAll = (section: ReportSection) => {
const renderRetryAll = (key: string, section: ReportSection) => {
const items: React.JSX.Element[] = [];
if (section.canRetryAll) {
items.push(renderSectionRetryAll(section.title, async () => {
items.push(renderSectionRetryAll(`${key}_${section.title}`, async () => {
await section.retryAllHandler();
void resfreshScreen();
}));
@ -97,7 +97,7 @@ function StatusScreen(props: Props) {
items.push(renderSectionTitle(section.title, section.title));
items = items.concat(renderRetryAll(section));
items = items.concat(renderRetryAll('top', section));
let currentListKey = '';
let listItems: React.JSX.Element[] = [];
@ -158,7 +158,7 @@ function StatusScreen(props: Props) {
}
}
items = items.concat(renderRetryAll(section));
items = items.concat(renderRetryAll('bottom', section));
return <div key={key}>{items}</div>;
};

View File

@ -543,7 +543,7 @@ async function initialize(dispatch: Function) {
if (Setting.value('env') === 'prod') {
await db.open({ name: getDatabaseName(currentProfile, isSubProfile) });
} else {
await db.open({ name: getDatabaseName(currentProfile, isSubProfile, '-3') });
await db.open({ name: getDatabaseName(currentProfile, isSubProfile, '-20240127-1') });
// await db.clearForTesting();
}
@ -755,6 +755,8 @@ async function initialize(dispatch: Function) {
await runOnDeviceFsDriverTests();
}
dispatch({ type: 'SYNC_HAS_DISABLED_SYNC_ITEMS' });
reg.logger().info('Application initialized');
}

View File

@ -31,6 +31,7 @@ import resourceRemotePath from './services/synchronizer/utils/resourceRemotePath
import syncDeleteStep from './services/synchronizer/utils/syncDeleteStep';
import { ErrorCode } from './errors';
import { SyncAction } from './services/synchronizer/utils/types';
import checkDisabledSyncItemsNotification from './services/synchronizer/utils/checkDisabledSyncItemsNotification';
const { sprintf } = require('sprintf-js');
const { Dirnames } = require('./services/synchronizer/utils/types');
@ -405,7 +406,6 @@ export default class Synchronizer {
const handleCannotSyncItem = async (ItemClass: any, syncTargetId: any, item: any, cannotSyncReason: string, itemLocation: any = null) => {
await ItemClass.saveSyncDisabled(syncTargetId, item, cannotSyncReason, itemLocation);
this.dispatch({ type: 'SYNC_HAS_DISABLED_SYNC_ITEMS' });
};
// We index resources before sync mostly to flag any potential orphan
@ -1127,6 +1127,8 @@ export default class Synchronizer {
withErrors: Synchronizer.reportHasErrors(this.progressReport_),
});
await checkDisabledSyncItemsNotification((action: any) => this.dispatch(action));
this.onProgress_ = function() {};
this.progressReport_ = {};

View File

@ -791,6 +791,11 @@ export default class BaseItem extends BaseModel {
return output;
}
public static async syncDisabledItemsCount(syncTargetId: number) {
const r = await this.db().selectOne('SELECT count(*) as total FROM sync_items WHERE sync_disabled = 1 AND sync_target = ?', [syncTargetId]);
return r ? r.total : 0;
}
public static updateSyncTimeQueries(syncTarget: number, item: any, syncTime: number, syncDisabled = false, syncDisabledReason = '', itemLocation: number = null) {
const itemType = item.type_;
const itemId = item.id;

View File

@ -1155,7 +1155,7 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
break;
case 'SYNC_HAS_DISABLED_SYNC_ITEMS':
draft.hasDisabledSyncItems = true;
draft.hasDisabledSyncItems = 'value' in action ? action.value : true;
break;
case 'ENCRYPTION_HAS_DISABLED_ITEMS':

View File

@ -4,6 +4,7 @@ import BaseService from './BaseService';
import ResourceService from './ResourceService';
import Logger from '@joplin/utils/Logger';
import shim from '../shim';
import notifyDisabledSyncItems from './synchronizer/utils/checkDisabledSyncItemsNotification';
const { Dirnames } = require('./synchronizer/utils/types');
const EventEmitter = require('events');
@ -243,9 +244,7 @@ export default class ResourceFetcher extends BaseService {
this.logger().info(`ResourceFetcher: Auto-added resources: ${count}`);
const errorCount = await Resource.downloadStatusCounts(Resource.FETCH_STATUS_ERROR);
if (errorCount) this.dispatch({ type: 'SYNC_HAS_DISABLED_SYNC_ITEMS' });
await notifyDisabledSyncItems((action: any) => this.dispatch(action));
} finally {
this.addingResources_ = false;
this.autoAddResourcesCalls_.pop();

View File

@ -0,0 +1,30 @@
import { Dispatch } from 'redux';
import Resource from '../../../models/Resource';
import BaseItem from '../../../models/BaseItem';
import Setting from '../../../models/Setting';
import Logger from '@joplin/utils/Logger';
const logger = Logger.create('checkDisabledSyncItemsNotification');
export default async (dispatch: Dispatch) => {
const errorCount = await Resource.downloadStatusCounts(Resource.FETCH_STATUS_ERROR);
if (errorCount) {
logger.info(`${errorCount} resource download errors: Triggering notification`);
dispatch({ type: 'SYNC_HAS_DISABLED_SYNC_ITEMS' });
return;
}
const disabledCount = await BaseItem.syncDisabledItemsCount(Setting.value('sync.target'));
if (disabledCount) {
logger.info(`${disabledCount} disabled sync items: Triggering notification`);
dispatch({ type: 'SYNC_HAS_DISABLED_SYNC_ITEMS' });
return;
}
logger.info('No errors: Hiding notification');
dispatch({
type: 'SYNC_HAS_DISABLED_SYNC_ITEMS',
value: false,
});
};