mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Mobile: Added support for ResourceFetcher service
This commit is contained in:
parent
3bdf621026
commit
069dce69cd
@ -76,8 +76,6 @@ class NoteBodyViewer extends Component {
|
||||
paddingBottom: '3.8em', // Extra bottom padding to make it possible to scroll past the action button (so that it doesn't overlap the text)
|
||||
};
|
||||
|
||||
console.info('RRRRRRRRRRRR');
|
||||
|
||||
let html = this.mdToHtml_.render(note ? note.body : '', this.props.webViewStyle, mdOptions);
|
||||
|
||||
html = `
|
||||
|
@ -80,8 +80,21 @@ class ResourceFetcher extends BaseService {
|
||||
if (this.fetchingItems_[resourceId]) return;
|
||||
this.fetchingItems_[resourceId] = true;
|
||||
|
||||
const completeDownload = (emitDownloadComplete = true) => {
|
||||
delete this.fetchingItems_[resource.id];
|
||||
this.scheduleQueueProcess();
|
||||
if (emitDownloadComplete) this.eventEmitter_.emit('downloadComplete', { id: resource.id });
|
||||
}
|
||||
|
||||
const resource = await Resource.load(resourceId);
|
||||
|
||||
// Shouldn't happen, but just to be safe don't re-download the
|
||||
// resource if it's already been downloaded.
|
||||
if (resource.fetch_status === Resource.FETCH_STATUS_DONE) {
|
||||
completeDownload(false);
|
||||
return;
|
||||
}
|
||||
|
||||
this.fetchingItems_[resourceId] = resource;
|
||||
|
||||
const localResourceContentPath = Resource.fullPath(resource);
|
||||
@ -93,12 +106,6 @@ class ResourceFetcher extends BaseService {
|
||||
|
||||
this.logger().debug('ResourceFetcher: Downloading resource: ' + resource.id);
|
||||
|
||||
const completeDownload = () => {
|
||||
delete this.fetchingItems_[resource.id];
|
||||
this.scheduleQueueProcess();
|
||||
this.eventEmitter_.emit('downloadComplete', { id: resource.id });
|
||||
}
|
||||
|
||||
fileApi.get(remoteResourceContentPath, { path: localResourceContentPath, target: "file" }).then(async () => {
|
||||
await Resource.saveFetchStatus(resource.id, Resource.FETCH_STATUS_DONE);
|
||||
this.logger().debug('ResourceFetcher: Resource downloaded: ' + resource.id);
|
||||
|
@ -51,6 +51,7 @@ const { reducer, defaultState } = require('lib/reducer.js');
|
||||
const { FileApiDriverLocal } = require('lib/file-api-driver-local.js');
|
||||
const DropdownAlert = require('react-native-dropdownalert').default;
|
||||
const ShareExtension = require('react-native-share-extension').default;
|
||||
const ResourceFetcher = require('lib/services/ResourceFetcher');
|
||||
|
||||
const SyncTargetRegistry = require('lib/SyncTargetRegistry.js');
|
||||
const SyncTargetOneDrive = require('lib/SyncTargetOneDrive.js');
|
||||
@ -138,6 +139,10 @@ const generalMiddleware = store => next => async (action) => {
|
||||
DecryptionWorker.instance().scheduleStart();
|
||||
}
|
||||
|
||||
if (action.type === 'SYNC_CREATED_RESOURCE') {
|
||||
ResourceFetcher.instance().queueDownload(action.id);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -488,6 +493,10 @@ async function initialize(dispatch) {
|
||||
|
||||
ResourceService.runInBackground();
|
||||
|
||||
ResourceFetcher.instance().setFileApi(() => { return reg.syncTarget().fileApi() });
|
||||
ResourceFetcher.instance().setLogger(reg.logger());
|
||||
ResourceFetcher.instance().start();
|
||||
|
||||
reg.scheduleSync().then(() => {
|
||||
// Wait for the first sync before updating the notifications, since synchronisation
|
||||
// might change the notifications.
|
||||
|
Loading…
Reference in New Issue
Block a user