mirror of
https://github.com/laurent22/joplin.git
synced 2025-01-02 12:47:41 +02:00
Desktop, Mobile: Fixes #9157: Clear "Some items cannot be synchronised" banner after situation is resolved
This commit is contained in:
parent
e4854b0bc2
commit
149e409bfa
@ -973,6 +973,7 @@ packages/lib/services/synchronizer/syncInfoUtils.js
|
|||||||
packages/lib/services/synchronizer/synchronizer_LockHandler.test.js
|
packages/lib/services/synchronizer/synchronizer_LockHandler.test.js
|
||||||
packages/lib/services/synchronizer/synchronizer_MigrationHandler.test.js
|
packages/lib/services/synchronizer/synchronizer_MigrationHandler.test.js
|
||||||
packages/lib/services/synchronizer/tools.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/handleConflictAction.js
|
||||||
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.js
|
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.js
|
||||||
packages/lib/services/synchronizer/utils/resourceRemotePath.js
|
packages/lib/services/synchronizer/utils/resourceRemotePath.js
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -953,6 +953,7 @@ packages/lib/services/synchronizer/syncInfoUtils.js
|
|||||||
packages/lib/services/synchronizer/synchronizer_LockHandler.test.js
|
packages/lib/services/synchronizer/synchronizer_LockHandler.test.js
|
||||||
packages/lib/services/synchronizer/synchronizer_MigrationHandler.test.js
|
packages/lib/services/synchronizer/synchronizer_MigrationHandler.test.js
|
||||||
packages/lib/services/synchronizer/tools.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/handleConflictAction.js
|
||||||
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.js
|
packages/lib/services/synchronizer/utils/handleSyncStartupOperation.js
|
||||||
packages/lib/services/synchronizer/utils/resourceRemotePath.js
|
packages/lib/services/synchronizer/utils/resourceRemotePath.js
|
||||||
|
@ -81,10 +81,10 @@ function StatusScreen(props: Props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderRetryAll = (section: ReportSection) => {
|
const renderRetryAll = (key: string, section: ReportSection) => {
|
||||||
const items: React.JSX.Element[] = [];
|
const items: React.JSX.Element[] = [];
|
||||||
if (section.canRetryAll) {
|
if (section.canRetryAll) {
|
||||||
items.push(renderSectionRetryAll(section.title, async () => {
|
items.push(renderSectionRetryAll(`${key}_${section.title}`, async () => {
|
||||||
await section.retryAllHandler();
|
await section.retryAllHandler();
|
||||||
void resfreshScreen();
|
void resfreshScreen();
|
||||||
}));
|
}));
|
||||||
@ -97,7 +97,7 @@ function StatusScreen(props: Props) {
|
|||||||
|
|
||||||
items.push(renderSectionTitle(section.title, section.title));
|
items.push(renderSectionTitle(section.title, section.title));
|
||||||
|
|
||||||
items = items.concat(renderRetryAll(section));
|
items = items.concat(renderRetryAll('top', section));
|
||||||
|
|
||||||
let currentListKey = '';
|
let currentListKey = '';
|
||||||
let listItems: React.JSX.Element[] = [];
|
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>;
|
return <div key={key}>{items}</div>;
|
||||||
};
|
};
|
||||||
|
@ -543,7 +543,7 @@ async function initialize(dispatch: Function) {
|
|||||||
if (Setting.value('env') === 'prod') {
|
if (Setting.value('env') === 'prod') {
|
||||||
await db.open({ name: getDatabaseName(currentProfile, isSubProfile) });
|
await db.open({ name: getDatabaseName(currentProfile, isSubProfile) });
|
||||||
} else {
|
} else {
|
||||||
await db.open({ name: getDatabaseName(currentProfile, isSubProfile, '-3') });
|
await db.open({ name: getDatabaseName(currentProfile, isSubProfile, '-20240127-1') });
|
||||||
|
|
||||||
// await db.clearForTesting();
|
// await db.clearForTesting();
|
||||||
}
|
}
|
||||||
@ -755,6 +755,8 @@ async function initialize(dispatch: Function) {
|
|||||||
await runOnDeviceFsDriverTests();
|
await runOnDeviceFsDriverTests();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dispatch({ type: 'SYNC_HAS_DISABLED_SYNC_ITEMS' });
|
||||||
|
|
||||||
reg.logger().info('Application initialized');
|
reg.logger().info('Application initialized');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ import resourceRemotePath from './services/synchronizer/utils/resourceRemotePath
|
|||||||
import syncDeleteStep from './services/synchronizer/utils/syncDeleteStep';
|
import syncDeleteStep from './services/synchronizer/utils/syncDeleteStep';
|
||||||
import { ErrorCode } from './errors';
|
import { ErrorCode } from './errors';
|
||||||
import { SyncAction } from './services/synchronizer/utils/types';
|
import { SyncAction } from './services/synchronizer/utils/types';
|
||||||
|
import checkDisabledSyncItemsNotification from './services/synchronizer/utils/checkDisabledSyncItemsNotification';
|
||||||
const { sprintf } = require('sprintf-js');
|
const { sprintf } = require('sprintf-js');
|
||||||
const { Dirnames } = require('./services/synchronizer/utils/types');
|
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) => {
|
const handleCannotSyncItem = async (ItemClass: any, syncTargetId: any, item: any, cannotSyncReason: string, itemLocation: any = null) => {
|
||||||
await ItemClass.saveSyncDisabled(syncTargetId, item, cannotSyncReason, itemLocation);
|
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
|
// We index resources before sync mostly to flag any potential orphan
|
||||||
@ -1127,6 +1127,8 @@ export default class Synchronizer {
|
|||||||
withErrors: Synchronizer.reportHasErrors(this.progressReport_),
|
withErrors: Synchronizer.reportHasErrors(this.progressReport_),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await checkDisabledSyncItemsNotification((action: any) => this.dispatch(action));
|
||||||
|
|
||||||
this.onProgress_ = function() {};
|
this.onProgress_ = function() {};
|
||||||
this.progressReport_ = {};
|
this.progressReport_ = {};
|
||||||
|
|
||||||
|
@ -791,6 +791,11 @@ export default class BaseItem extends BaseModel {
|
|||||||
return output;
|
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) {
|
public static updateSyncTimeQueries(syncTarget: number, item: any, syncTime: number, syncDisabled = false, syncDisabledReason = '', itemLocation: number = null) {
|
||||||
const itemType = item.type_;
|
const itemType = item.type_;
|
||||||
const itemId = item.id;
|
const itemId = item.id;
|
||||||
|
@ -1155,7 +1155,7 @@ const reducer = produce((draft: Draft<State> = defaultState, action: any) => {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'SYNC_HAS_DISABLED_SYNC_ITEMS':
|
case 'SYNC_HAS_DISABLED_SYNC_ITEMS':
|
||||||
draft.hasDisabledSyncItems = true;
|
draft.hasDisabledSyncItems = 'value' in action ? action.value : true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'ENCRYPTION_HAS_DISABLED_ITEMS':
|
case 'ENCRYPTION_HAS_DISABLED_ITEMS':
|
||||||
|
@ -4,6 +4,7 @@ import BaseService from './BaseService';
|
|||||||
import ResourceService from './ResourceService';
|
import ResourceService from './ResourceService';
|
||||||
import Logger from '@joplin/utils/Logger';
|
import Logger from '@joplin/utils/Logger';
|
||||||
import shim from '../shim';
|
import shim from '../shim';
|
||||||
|
import notifyDisabledSyncItems from './synchronizer/utils/checkDisabledSyncItemsNotification';
|
||||||
const { Dirnames } = require('./synchronizer/utils/types');
|
const { Dirnames } = require('./synchronizer/utils/types');
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
|
|
||||||
@ -243,9 +244,7 @@ export default class ResourceFetcher extends BaseService {
|
|||||||
|
|
||||||
this.logger().info(`ResourceFetcher: Auto-added resources: ${count}`);
|
this.logger().info(`ResourceFetcher: Auto-added resources: ${count}`);
|
||||||
|
|
||||||
const errorCount = await Resource.downloadStatusCounts(Resource.FETCH_STATUS_ERROR);
|
await notifyDisabledSyncItems((action: any) => this.dispatch(action));
|
||||||
if (errorCount) this.dispatch({ type: 'SYNC_HAS_DISABLED_SYNC_ITEMS' });
|
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
this.addingResources_ = false;
|
this.addingResources_ = false;
|
||||||
this.autoAddResourcesCalls_.pop();
|
this.autoAddResourcesCalls_.pop();
|
||||||
|
@ -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,
|
||||||
|
});
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user