mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update media sync
This commit is contained in:
parent
6ef418cf8d
commit
09c7da7d48
19 changed files with 138 additions and 95 deletions
43
dashboard-ui/cordova/ios/backgroundfetch.js
vendored
43
dashboard-ui/cordova/ios/backgroundfetch.js
vendored
|
@ -27,7 +27,7 @@
|
|||
fetcher.finish(); // <-- N.B. You MUST called #finish so that native-side can signal completion of the background-thread to the os.
|
||||
}
|
||||
|
||||
function startSync(reportToFetcher) {
|
||||
function startSync(reportToFetcher, syncOptions) {
|
||||
lastStart = new Date().getTime();
|
||||
|
||||
require(['localsync'], function () {
|
||||
|
@ -37,7 +37,7 @@
|
|||
return;
|
||||
}
|
||||
|
||||
var promise = LocalSync.sync();
|
||||
var promise = LocalSync.sync(syncOptions);
|
||||
|
||||
if (reportToFetcher) {
|
||||
promise.done(onSyncFinish).fail(onSyncFail);
|
||||
|
@ -48,7 +48,12 @@
|
|||
function onBackgroundFetch() {
|
||||
|
||||
Logger.log('BackgroundFetch initiated');
|
||||
startSync(true);
|
||||
|
||||
startSync(true, {
|
||||
uploadPhotos: false,
|
||||
enableBackgroundTransfer: true,
|
||||
enableNewDownloads: true
|
||||
});
|
||||
}
|
||||
|
||||
function onBackgroundFetchFailed() {
|
||||
|
@ -61,20 +66,46 @@
|
|||
|
||||
setInterval(function () {
|
||||
|
||||
//startSync();
|
||||
startIntervalSync();
|
||||
|
||||
}, syncInterval);
|
||||
|
||||
if (lastStart > 0 && (new Date().getTime() - lastStart) >= syncInterval) {
|
||||
|
||||
setTimeout(function () {
|
||||
//startSync();
|
||||
startIntervalSync();
|
||||
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
Dashboard.ready(restartInterval);
|
||||
function startIntervalSync() {
|
||||
|
||||
startSync(false, {
|
||||
uploadPhotos: true,
|
||||
enableNewDownloads: false,
|
||||
enableBackgroundTransfer: true
|
||||
});
|
||||
}
|
||||
|
||||
function normalizeSyncOptions(options) {
|
||||
|
||||
options.enableBackgroundTransfer = true;
|
||||
|
||||
if (options.enableNewDownloads == null) {
|
||||
options.enableNewDownloads = false;
|
||||
}
|
||||
}
|
||||
|
||||
Dashboard.ready(function () {
|
||||
|
||||
require(['localsync'], function () {
|
||||
|
||||
LocalSync.normalizeSyncOptions = normalizeSyncOptions;
|
||||
});
|
||||
|
||||
restartInterval();
|
||||
});
|
||||
document.addEventListener("resume", restartInterval, false);
|
||||
|
||||
onDeviceReady();
|
||||
|
|
20
dashboard-ui/cordova/localassetmanager.js
vendored
20
dashboard-ui/cordova/localassetmanager.js
vendored
|
@ -472,7 +472,7 @@
|
|||
return filename;
|
||||
}
|
||||
|
||||
function downloadFile(url, localPath, enableBackground) {
|
||||
function downloadFile(url, localPath, enableBackground, enableNewDownloads) {
|
||||
|
||||
if (!enableBackground) {
|
||||
return downloadWithFileTransfer(url, localPath);
|
||||
|
@ -482,7 +482,12 @@
|
|||
|
||||
if (localStorage.getItem('sync-' + url) == '1') {
|
||||
Logger.log('file was downloaded previously');
|
||||
deferred.resolveWith(null, [localPath]);
|
||||
deferred.resolveWith(null, [localPath, false]);
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
if (enableNewDownloads === false) {
|
||||
deferred.resolveWith(null, [localPath, true]);
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
|
@ -504,7 +509,7 @@
|
|||
isResolved = true;
|
||||
// true indicates that it's queued
|
||||
deferred.resolveWith(null, [localPath, true]);
|
||||
}, 1000);
|
||||
}, 700);
|
||||
|
||||
// Start the download and persist the promise to be able to cancel the download.
|
||||
download.startAsync().then(function () {
|
||||
|
@ -512,10 +517,11 @@
|
|||
clearTimeout(timeoutHandle);
|
||||
// on success
|
||||
Logger.log('Downloaded local url: ' + localPath);
|
||||
if (isResolved) {
|
||||
// If we've already moved on, set this property so that we'll see it later
|
||||
localStorage.setItem('sync-' + url, '1');
|
||||
} else {
|
||||
|
||||
// If we've already moved on, set this property so that we'll see it later
|
||||
localStorage.setItem('sync-' + url, '1');
|
||||
|
||||
if (!isResolved) {
|
||||
// true indicates that it's queued
|
||||
deferred.resolveWith(null, [localPath, false]);
|
||||
}
|
||||
|
|
6
dashboard-ui/cordova/registrationservices.js
vendored
6
dashboard-ui/cordova/registrationservices.js
vendored
|
@ -168,12 +168,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (showSupporterInfo) {
|
||||
html += '<p>';
|
||||
html += '<paper-button raised class="submit block btnSignInSupporter"><iron-icon icon="check"></iron-icon><span>' + Globalize.translate('ButtonUnlockWithSupporter') + '</span></paper-button>';
|
||||
html += '</p>';
|
||||
}
|
||||
|
||||
html += '<p>';
|
||||
html += '<paper-button raised class="cancelDark block btnCancel"><iron-icon icon="close"></iron-icon><span>' + Globalize.translate('ButtonCancel') + '</span></paper-button>';
|
||||
html += '</p>';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue