jellyfin-web/dashboard-ui/scripts/homedownloads.js
2017-06-14 15:55:24 -04:00

1 line
1.1 KiB
JavaScript

define(["apphost","globalize","syncJobList","events","localsync","emby-button","paper-icon-button-light"],function(appHost,globalize,syncJobList,events,localSync){"use strict";return function(view,params,tabContent){function isLocalSyncManagement(){return appHost.supports("sync")&&"offline"==mode}function refreshSyncStatus(page){if(isLocalSyncManagement()){var status=localSync.getSyncStatus();"Active"==status?page.querySelector(".btnSyncNow").classList.add("hide"):page.querySelector(".btnSyncNow").classList.remove("hide")}}function syncNow(page){localSync.sync(),require(["toast"],function(toast){toast(Globalize.translate("MessageSyncStarted"))}),refreshSyncStatus(page)}var self=this,mode="offline";tabContent.querySelector(".btnSyncNow").addEventListener("click",function(){syncNow(tabContent)});var mySyncJobList=new syncJobList({isLocalSync:"offline"===mode,serverId:ApiClient.serverId(),userId:"offline"===mode?null:ApiClient.getCurrentUserId(),element:tabContent.querySelector(".syncActivity"),mode:mode});self.renderTab=function(){refreshSyncStatus(tabContent)},self.destroy=function(){mySyncJobList&&(mySyncJobList.destroy(),mySyncJobList=null)}}});