1
0
Fork 0
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:
Luke Pulverenti 2015-09-28 23:35:50 -04:00
parent 6ef418cf8d
commit 09c7da7d48
19 changed files with 138 additions and 95 deletions

View file

@ -8,24 +8,16 @@
var deferred = DeferredBuilder.Deferred();
LocalAssetManager.getCameraPhotos().done(function (photos) {
if (!photos.length) {
deferred.resolve();
return;
}
var apiClient = connectionManager.getApiClient(server.Id);
apiClient.getContentUploadHistory().done(function (result) {
uploadImagesWithHistory(server, result, apiClient, deferred);
}).fail(function () {
deferred.reject();
});
return deferred.promise();
};
function uploadImagesWithHistory(server, uploadHistory, apiClient, deferred) {
require(['localassetmanager', "cryptojs-sha1"], function () {
LocalAssetManager.getCameraPhotos().done(function (photos) {
apiClient.getContentUploadHistory().done(function (uploadHistory) {
photos = getFilesToUpload(photos, uploadHistory);
@ -36,8 +28,13 @@
}).fail(function () {
deferred.reject();
});
}).fail(function () {
deferred.reject();
});
}
return deferred.promise();
};
function getFilesToUpload(files, uploadHistory) {

View file

@ -254,7 +254,7 @@
options = options || {};
LocalAssetManager.downloadFile(url, localPath, options.enableBackgroundTransfer).done(function (path, isQueued) {
LocalAssetManager.downloadFile(url, localPath, options.enableBackgroundTransfer, options.enableNewDownloads).done(function (path, isQueued) {
if (isQueued) {
deferred.resolveWith(null, [true]);

View file

@ -26,7 +26,7 @@
Dashboard.showLoadingMsg();
var popup = $('.popupSubtitleViewer', page).popup('open');
$('.subtitleContent', page).html('\nLoading...\n\n\n');
$('.subtitleContent', page).html('');
var url = 'Providers/Subtitles/Subtitles/' + id;

View file

@ -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();

View file

@ -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 (!isResolved) {
// true indicates that it's queued
deferred.resolveWith(null, [localPath, false]);
}

View file

@ -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>';

View file

@ -18,6 +18,7 @@
.background-theme-b {
background-color: #242424;
background: -webkit-radial-gradient(circle, #282828, #202020);
}
.ui-body-b {
@ -1190,7 +1191,7 @@ span.itemCommunityRating:not(:empty) + .userDataIcons {
.selectedCharacter {
color: #4d90fe !important;
color: #52B54B !important;
}
.itemOverlayHtml {

View file

@ -268,7 +268,7 @@
}
.libraryViewNav .ui-btn-active {
border-bottom-color: #38c;
border-bottom-color: #52B54B;
color: #fff !important;
}

View file

@ -217,11 +217,11 @@
}
.channelTimeslotHeader {
border-right: 1px solid #38c;
border-right-color: #52B54B;
}
.channelTimeslotHeader, .timeslotHeader {
background: #38c;
background: #52B54B;
}
.timeslotHeader, .channelTimeslotHeader {

View file

@ -37,7 +37,7 @@
<paper-button raised class="submit mini categorySyncButton" data-category="Resume"><iron-icon icon="sync"></iron-icon><span>${ButtonSync}</span></paper-button>
</div>
<div id="resumableItems" class="itemsContainer">
<div id="resumableItems" class="itemsContainer noautoinit">
</div>
</div>
@ -47,7 +47,7 @@
<paper-button raised class="submit mini categorySyncButton" data-category="Latest"><iron-icon icon="sync"></iron-icon><span>${ButtonSync}</span></paper-button>
</div>
<div id="recentlyAddedItems" class="itemsContainer">
<div id="recentlyAddedItems" class="itemsContainer noautoinit">
</div>
</div>

View file

@ -32,28 +32,28 @@
<div class="homePageSection">
<h1 class="listHeader">${HeaderLatestMusic}</h1>
<div id="recentlyAddedSongs" class="itemsContainer fullWidthItemsContainer" style="text-align:left;">
<div id="recentlyAddedSongs" class="itemsContainer fullWidthItemsContainer noautoinit" style="text-align:left;">
</div>
</div>
<div id="playlists" style="display: none;" class="homePageSection">
<h1 class="listHeader">${HeaderPlaylists}</h1>
<div class="itemsContainer fullWidthItemsContainer" style="text-align:left;">
<div class="itemsContainer fullWidthItemsContainer noautoinit" style="text-align:left;">
</div>
</div>
<div id="recentlyPlayed" style="display: none;" class="homePageSection">
<h1 class="listHeader">${HeaderRecentlyPlayed}</h1>
<div id="recentlyPlayedSongs" class="itemsContainer fullWidthItemsContainer" style="text-align:left;">
<div id="recentlyPlayedSongs" class="itemsContainer fullWidthItemsContainer noautoinit" style="text-align:left;">
</div>
</div>
<div id="topPlayed" style="display: none;" class="homePageSection">
<h1 class="listHeader">${HeaderFrequentlyPlayed}</h1>
<div id="topPlayedSongs" class="itemsContainer fullWidthItemsContainer" style="text-align:left;">
<div id="topPlayedSongs" class="itemsContainer fullWidthItemsContainer noautoinit" style="text-align:left;">
</div>
</div>
</div>

View file

@ -993,6 +993,7 @@
}
var elems = elem.querySelectorAll('.itemsContainer');
for (var i = 0, length = elems.length; i < length; i++) {
initTapHold(elems[i]);
}
@ -1402,7 +1403,7 @@
$(page).on('click', '.itemWithAction', onItemWithActionClick);
var itemsContainers = page.getElementsByClassName('itemsContainer');
var itemsContainers = page.querySelectorAll('.itemsContainer:not(.noautoinit)');
for (var i = 0, length = itemsContainers.length; i < length; i++) {
$(itemsContainers[i]).createCardMenus();
}

View file

@ -20,9 +20,7 @@
options = options || {};
if ($.browser.safari) {
options.enableBackgroundTransfer = true;
}
LocalSync.normalizeSyncOptions(options);
options.cameraUploadServers = AppSettings.cameraUploadServers();
@ -40,6 +38,10 @@
return deferred.promise();
},
normalizeSyncOptions: function (options) {
},
getSyncStatus: function () {
if (syncPromise != null) {

View file

@ -67,7 +67,9 @@
});
}
$('#recentlyAddedItems', page).html(html).lazyChildren();
var recentlyAddedItems = page.querySelector('#recentlyAddedItems');
recentlyAddedItems.innerHTML = html;
ImageLoader.lazyChildren(recentlyAddedItems);
LibraryBrowser.setLastRefreshed(page);
});
}
@ -219,22 +221,21 @@
if (!recommendations.length) {
$('.noItemsMessage', page).show();
$('.recommendations', page).html('');
page.querySelector('.recommendations').innerHTML = '';
return;
}
var html = recommendations.map(getRecommendationHtml).join('');
$('.noItemsMessage', page).hide();
$('.recommendations', page).html(html).lazyChildren();
var recs = page.querySelector('.recommendations');
recs.innerHTML = html;
ImageLoader.lazyChildren(recs);
});
}
function loadSuggestionsTab(page, tabContent) {
var parentId = LibraryMenu.getTopParentId();
var userId = Dashboard.getCurrentUserId();
function initSuggestedTab(page, tabContent) {
var containers = tabContent.querySelectorAll('.itemsContainer');
if (enableScrollX()) {
@ -243,6 +244,15 @@
$(containers).removeClass('hiddenScrollX');
}
$(containers).createCardMenus();
}
function loadSuggestionsTab(page, tabContent) {
var parentId = LibraryMenu.getTopParentId();
var userId = Dashboard.getCurrentUserId();
if (LibraryBrowser.needsRefresh(tabContent)) {
console.log('loadSuggestionsTab');
loadResume(tabContent, userId, parentId);
@ -265,6 +275,7 @@
switch (index) {
case 0:
initMethod = 'initSuggestedTab';
renderMethod = 'renderSuggestedTab';
break;
case 1:
@ -315,6 +326,7 @@
window.MoviesPage = window.MoviesPage || {};
window.MoviesPage.renderSuggestedTab = loadSuggestionsTab;
window.MoviesPage.initSuggestedTab = initSuggestedTab;
pageIdOn('pageinit', "moviesPage", function () {

View file

@ -186,9 +186,7 @@
});
}
function loadSuggestionsTab(page, tabContent) {
var parentId = LibraryMenu.getTopParentId();
function initSuggestedTab(page, tabContent) {
var containers = tabContent.querySelectorAll('.itemsContainer');
if (enableScrollX()) {
@ -197,6 +195,13 @@
$(containers).removeClass('hiddenScrollX');
}
$(containers).createCardMenus();
}
function loadSuggestionsTab(page, tabContent) {
var parentId = LibraryMenu.getTopParentId();
if (LibraryBrowser.needsRefresh(tabContent)) {
console.log('loadSuggestionsTab');
loadLatest(tabContent, parentId);
@ -217,6 +222,7 @@
switch (index) {
case 0:
initMethod = 'initSuggestedTab';
renderMethod = 'renderSuggestedTab';
break;
case 1:
@ -266,6 +272,7 @@
window.MusicPage = window.MusicPage || {};
window.MusicPage.renderSuggestedTab = loadSuggestionsTab;
window.MusicPage.initSuggestedTab = initSuggestedTab;
$(document).on('pageinit', "#musicRecommendedPage", function () {

View file

@ -105,8 +105,6 @@
var parentId = LibraryMenu.getTopParentId();
var screenWidth = $(window).width();
var limit = 6;
var options = {
@ -169,28 +167,17 @@
});
}
$(document).on('pagebeforeshow', "#tvRecommendedPage", function () {
var page = this;
if (enableScrollX()) {
page.querySelector('#resumableItems').classList.add('hiddenScrollX');
} else {
page.querySelector('#resumableItems').classList.remove('hiddenScrollX');
}
if (LibraryBrowser.needsRefresh(page)) {
reload(page);
}
});
function loadSuggestionsTab(page, tabContent) {
function initSuggestedTab(page, tabContent) {
if (enableScrollX()) {
tabContent.querySelector('#resumableItems').classList.add('hiddenScrollX');
} else {
tabContent.querySelector('#resumableItems').classList.remove('hiddenScrollX');
}
$(tabContent.querySelector('#resumableItems')).createCardMenus();
}
function loadSuggestionsTab(page, tabContent) {
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
@ -208,6 +195,7 @@
switch (index) {
case 0:
initMethod = 'initSuggestedTab';
renderMethod = 'renderSuggestedTab';
break;
case 1:
@ -261,6 +249,7 @@
window.TvPage = window.TvPage || {};
window.TvPage.renderSuggestedTab = loadSuggestionsTab;
window.TvPage.initSuggestedTab = initSuggestedTab;
pageIdOn('pageinit', "tvRecommendedPage", function () {
@ -277,6 +266,13 @@
baseUrl += '?topParentId=' + topParentId;
}
if (enableScrollX()) {
page.querySelector('#resumableItems').classList.add('hiddenScrollX');
} else {
page.querySelector('#resumableItems').classList.remove('hiddenScrollX');
}
$(page.querySelector('#resumableItems')).createCardMenus();
LibraryBrowser.configurePaperLibraryTabs(page, tabs, pages, baseUrl);
$(pages).on('tabchange', function () {
@ -284,6 +280,15 @@
});
});
pageIdOn('pagebeforeshow', "tvRecommendedPage", function () {
var page = this;
if (LibraryBrowser.needsRefresh(page)) {
reload(page);
}
});
pageIdOn('pageshow', "tvRecommendedPage", function () {
var page = this;

View file

@ -33,16 +33,3 @@
paper-tab {
font-weight: 500 !important;
}
.libraryViewNav .ui-btn-active {
border-bottom-color: #52B54B !important;
}
.channelTimeslotHeader {
border-right-color: #52B54B !important;
}
.channelTimeslotHeader, .timeslotHeader {
background: #52B54B !important;
}

View file

@ -39,7 +39,7 @@
<paper-button raised class="submit mini categorySyncButton" data-category="Resume"><iron-icon icon="sync"></iron-icon><span>${ButtonSync}</span></paper-button>
</div>
<div id="resumableItems" class="itemsContainer">
<div id="resumableItems" class="itemsContainer noautoinit">
</div>
</div>

View file

@ -13968,7 +13968,7 @@ is separate from validation, and `allowed-pattern` does not affect how the input
</style>
<template>
<span aria-live$="[[mode]]">[[_text]]</span>
<div aria-live$="[[mode]]">[[_text]]</div>
</template>
<script>