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

View file

@ -254,7 +254,7 @@
options = options || {}; 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) { if (isQueued) {
deferred.resolveWith(null, [true]); deferred.resolveWith(null, [true]);

View file

@ -26,7 +26,7 @@
Dashboard.showLoadingMsg(); Dashboard.showLoadingMsg();
var popup = $('.popupSubtitleViewer', page).popup('open'); var popup = $('.popupSubtitleViewer', page).popup('open');
$('.subtitleContent', page).html('\nLoading...\n\n\n'); $('.subtitleContent', page).html('');
var url = 'Providers/Subtitles/Subtitles/' + id; 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. 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(); lastStart = new Date().getTime();
require(['localsync'], function () { require(['localsync'], function () {
@ -37,7 +37,7 @@
return; return;
} }
var promise = LocalSync.sync(); var promise = LocalSync.sync(syncOptions);
if (reportToFetcher) { if (reportToFetcher) {
promise.done(onSyncFinish).fail(onSyncFail); promise.done(onSyncFinish).fail(onSyncFail);
@ -48,7 +48,12 @@
function onBackgroundFetch() { function onBackgroundFetch() {
Logger.log('BackgroundFetch initiated'); Logger.log('BackgroundFetch initiated');
startSync(true);
startSync(true, {
uploadPhotos: false,
enableBackgroundTransfer: true,
enableNewDownloads: true
});
} }
function onBackgroundFetchFailed() { function onBackgroundFetchFailed() {
@ -61,20 +66,46 @@
setInterval(function () { setInterval(function () {
//startSync(); startIntervalSync();
}, syncInterval); }, syncInterval);
if (lastStart > 0 && (new Date().getTime() - lastStart) >= syncInterval) { if (lastStart > 0 && (new Date().getTime() - lastStart) >= syncInterval) {
setTimeout(function () { setTimeout(function () {
//startSync(); startIntervalSync();
}, 5000); }, 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); document.addEventListener("resume", restartInterval, false);
onDeviceReady(); onDeviceReady();

View file

@ -472,7 +472,7 @@
return filename; return filename;
} }
function downloadFile(url, localPath, enableBackground) { function downloadFile(url, localPath, enableBackground, enableNewDownloads) {
if (!enableBackground) { if (!enableBackground) {
return downloadWithFileTransfer(url, localPath); return downloadWithFileTransfer(url, localPath);
@ -482,7 +482,12 @@
if (localStorage.getItem('sync-' + url) == '1') { if (localStorage.getItem('sync-' + url) == '1') {
Logger.log('file was downloaded previously'); 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(); return deferred.promise();
} }
@ -504,7 +509,7 @@
isResolved = true; isResolved = true;
// true indicates that it's queued // true indicates that it's queued
deferred.resolveWith(null, [localPath, true]); deferred.resolveWith(null, [localPath, true]);
}, 1000); }, 700);
// Start the download and persist the promise to be able to cancel the download. // Start the download and persist the promise to be able to cancel the download.
download.startAsync().then(function () { download.startAsync().then(function () {
@ -512,10 +517,11 @@
clearTimeout(timeoutHandle); clearTimeout(timeoutHandle);
// on success // on success
Logger.log('Downloaded local url: ' + localPath); Logger.log('Downloaded local url: ' + localPath);
if (isResolved) {
// If we've already moved on, set this property so that we'll see it later // If we've already moved on, set this property so that we'll see it later
localStorage.setItem('sync-' + url, '1'); localStorage.setItem('sync-' + url, '1');
} else {
if (!isResolved) {
// true indicates that it's queued // true indicates that it's queued
deferred.resolveWith(null, [localPath, false]); 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 += '<p>';
html += '<paper-button raised class="cancelDark block btnCancel"><iron-icon icon="close"></iron-icon><span>' + Globalize.translate('ButtonCancel') + '</span></paper-button>'; html += '<paper-button raised class="cancelDark block btnCancel"><iron-icon icon="close"></iron-icon><span>' + Globalize.translate('ButtonCancel') + '</span></paper-button>';
html += '</p>'; html += '</p>';

View file

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

View file

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

View file

@ -217,11 +217,11 @@
} }
.channelTimeslotHeader { .channelTimeslotHeader {
border-right: 1px solid #38c; border-right-color: #52B54B;
} }
.channelTimeslotHeader, .timeslotHeader { .channelTimeslotHeader, .timeslotHeader {
background: #38c; background: #52B54B;
} }
.timeslotHeader, .channelTimeslotHeader { .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> <paper-button raised class="submit mini categorySyncButton" data-category="Resume"><iron-icon icon="sync"></iron-icon><span>${ButtonSync}</span></paper-button>
</div> </div>
<div id="resumableItems" class="itemsContainer"> <div id="resumableItems" class="itemsContainer noautoinit">
</div> </div>
</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> <paper-button raised class="submit mini categorySyncButton" data-category="Latest"><iron-icon icon="sync"></iron-icon><span>${ButtonSync}</span></paper-button>
</div> </div>
<div id="recentlyAddedItems" class="itemsContainer"> <div id="recentlyAddedItems" class="itemsContainer noautoinit">
</div> </div>
</div> </div>

View file

@ -32,28 +32,28 @@
<div class="homePageSection"> <div class="homePageSection">
<h1 class="listHeader">${HeaderLatestMusic}</h1> <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> </div>
<div id="playlists" style="display: none;" class="homePageSection"> <div id="playlists" style="display: none;" class="homePageSection">
<h1 class="listHeader">${HeaderPlaylists}</h1> <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> </div>
<div id="recentlyPlayed" style="display: none;" class="homePageSection"> <div id="recentlyPlayed" style="display: none;" class="homePageSection">
<h1 class="listHeader">${HeaderRecentlyPlayed}</h1> <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> </div>
<div id="topPlayed" style="display: none;" class="homePageSection"> <div id="topPlayed" style="display: none;" class="homePageSection">
<h1 class="listHeader">${HeaderFrequentlyPlayed}</h1> <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> </div>
</div> </div>

View file

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

View file

@ -20,9 +20,7 @@
options = options || {}; options = options || {};
if ($.browser.safari) { LocalSync.normalizeSyncOptions(options);
options.enableBackgroundTransfer = true;
}
options.cameraUploadServers = AppSettings.cameraUploadServers(); options.cameraUploadServers = AppSettings.cameraUploadServers();
@ -40,6 +38,10 @@
return deferred.promise(); return deferred.promise();
}, },
normalizeSyncOptions: function (options) {
},
getSyncStatus: function () { getSyncStatus: function () {
if (syncPromise != null) { 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); LibraryBrowser.setLastRefreshed(page);
}); });
} }
@ -219,22 +221,21 @@
if (!recommendations.length) { if (!recommendations.length) {
$('.noItemsMessage', page).show(); $('.noItemsMessage', page).show();
$('.recommendations', page).html(''); page.querySelector('.recommendations').innerHTML = '';
return; return;
} }
var html = recommendations.map(getRecommendationHtml).join(''); var html = recommendations.map(getRecommendationHtml).join('');
$('.noItemsMessage', page).hide(); $('.noItemsMessage', page).hide();
$('.recommendations', page).html(html).lazyChildren();
var recs = page.querySelector('.recommendations');
recs.innerHTML = html;
ImageLoader.lazyChildren(recs);
}); });
} }
function loadSuggestionsTab(page, tabContent) { function initSuggestedTab(page, tabContent) {
var parentId = LibraryMenu.getTopParentId();
var userId = Dashboard.getCurrentUserId();
var containers = tabContent.querySelectorAll('.itemsContainer'); var containers = tabContent.querySelectorAll('.itemsContainer');
if (enableScrollX()) { if (enableScrollX()) {
@ -243,6 +244,15 @@
$(containers).removeClass('hiddenScrollX'); $(containers).removeClass('hiddenScrollX');
} }
$(containers).createCardMenus();
}
function loadSuggestionsTab(page, tabContent) {
var parentId = LibraryMenu.getTopParentId();
var userId = Dashboard.getCurrentUserId();
if (LibraryBrowser.needsRefresh(tabContent)) { if (LibraryBrowser.needsRefresh(tabContent)) {
console.log('loadSuggestionsTab'); console.log('loadSuggestionsTab');
loadResume(tabContent, userId, parentId); loadResume(tabContent, userId, parentId);
@ -265,6 +275,7 @@
switch (index) { switch (index) {
case 0: case 0:
initMethod = 'initSuggestedTab';
renderMethod = 'renderSuggestedTab'; renderMethod = 'renderSuggestedTab';
break; break;
case 1: case 1:
@ -315,6 +326,7 @@
window.MoviesPage = window.MoviesPage || {}; window.MoviesPage = window.MoviesPage || {};
window.MoviesPage.renderSuggestedTab = loadSuggestionsTab; window.MoviesPage.renderSuggestedTab = loadSuggestionsTab;
window.MoviesPage.initSuggestedTab = initSuggestedTab;
pageIdOn('pageinit', "moviesPage", function () { pageIdOn('pageinit', "moviesPage", function () {

View file

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

View file

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

View file

@ -33,16 +33,3 @@
paper-tab { paper-tab {
font-weight: 500 !important; 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> <paper-button raised class="submit mini categorySyncButton" data-category="Resume"><iron-icon icon="sync"></iron-icon><span>${ButtonSync}</span></paper-button>
</div> </div>
<div id="resumableItems" class="itemsContainer"> <div id="resumableItems" class="itemsContainer noautoinit">
</div> </div>
</div> </div>

View file

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