|
1 |
| -define(["events", "appStorage", "wakeOnLan"], function(events, appStorage, wakeOnLan) { |
| 1 | +define(["events", "appStorage"], function(events, appStorage) { |
2 | 2 | "use strict";
|
3 | 3 |
|
4 | 4 | function redetectBitrate(instance) {
|
@@ -201,36 +201,6 @@ define(["events", "appStorage", "wakeOnLan"], function(events, appStorage, wakeO
|
201 | 201 | ratio && (options.minScale && (ratio = Math.max(options.minScale, ratio)), options.width && (options.width = Math.round(options.width * ratio)), options.height && (options.height = Math.round(options.height * ratio)), options.maxWidth && (options.maxWidth = Math.round(options.maxWidth * ratio)), options.maxHeight && (options.maxHeight = Math.round(options.maxHeight * ratio))), options.quality = options.quality || instance.getDefaultImageQuality(options.type), instance.normalizeImageOptions && instance.normalizeImageOptions(options)
|
202 | 202 | }
|
203 | 203 |
|
204 |
| - function getCachedWakeOnLanInfo(instance) { |
205 |
| - var serverId = instance.serverId(), |
206 |
| - json = appStorage.getItem("server-" + serverId + "-wakeonlaninfo"); |
207 |
| - return json ? JSON.parse(json) : [] |
208 |
| - } |
209 |
| - |
210 |
| - function refreshWakeOnLanInfoIfNeeded(instance) { |
211 |
| - wakeOnLan.isSupported() && instance.accessToken() && !1 !== instance.enableAutomaticBitrateDetection && (console.log("refreshWakeOnLanInfoIfNeeded"), setTimeout(refreshWakeOnLanInfo.bind(instance), 1e4)) |
212 |
| - } |
213 |
| - |
214 |
| - function refreshWakeOnLanInfo() { |
215 |
| - var instance = this; |
216 |
| - console.log("refreshWakeOnLanInfo"), instance.getWakeOnLanInfo().then(function(info) { |
217 |
| - var serverId = instance.serverId(); |
218 |
| - return appStorage.setItem("server-" + serverId + "-wakeonlaninfo", JSON.stringify(info)), info |
219 |
| - }, function(err) { |
220 |
| - return [] |
221 |
| - }) |
222 |
| - } |
223 |
| - |
224 |
| - function sendNextWakeOnLan(infos, index, resolve) { |
225 |
| - if (index >= infos.length) return void resolve(); |
226 |
| - var info = infos[index]; |
227 |
| - console.log("sending wakeonlan to " + info.MacAddress), wakeOnLan.send(info).then(function(result) { |
228 |
| - sendNextWakeOnLan(infos, index + 1, resolve) |
229 |
| - }, function() { |
230 |
| - sendNextWakeOnLan(infos, index + 1, resolve) |
231 |
| - }) |
232 |
| - } |
233 |
| - |
234 | 204 | function compareVersions(a, b) {
|
235 | 205 | a = a.split("."), b = b.split(".");
|
236 | 206 | for (var i = 0, length = Math.max(a.length, b.length); i < length; i++) {
|
@@ -266,7 +236,7 @@ define(["events", "appStorage", "wakeOnLan"], function(events, appStorage, wakeO
|
266 | 236 | }
|
267 | 237 | return this._serverAddress
|
268 | 238 | }, ApiClient.prototype.onNetworkChange = function() {
|
269 |
| - this.lastDetectedBitrate = 0, this.lastDetectedBitrateTime = 0, setSavedEndpointInfo(this, null), redetectBitrate(this), refreshWakeOnLanInfoIfNeeded(this) |
| 239 | + this.lastDetectedBitrate = 0, this.lastDetectedBitrateTime = 0, setSavedEndpointInfo(this, null), redetectBitrate(this) |
270 | 240 | }, ApiClient.prototype.getUrl = function(name, params, serverAddress) {
|
271 | 241 | if (!name) throw new Error("Url name cannot be empty");
|
272 | 242 | var url = serverAddress || this._serverAddress;
|
@@ -301,7 +271,7 @@ define(["events", "appStorage", "wakeOnLan"], function(events, appStorage, wakeO
|
301 | 271 | }
|
302 | 272 | return this.fetchWithFailover(request, !0)
|
303 | 273 | }, ApiClient.prototype.setAuthenticationInfo = function(accessKey, userId) {
|
304 |
| - this._currentUser = null, this._serverInfo.AccessToken = accessKey, this._serverInfo.UserId = userId, redetectBitrate(this), refreshWakeOnLanInfoIfNeeded(this) |
| 274 | + this._currentUser = null, this._serverInfo.AccessToken = accessKey, this._serverInfo.UserId = userId, redetectBitrate(this) |
305 | 275 | }, ApiClient.prototype.serverInfo = function(info) {
|
306 | 276 | return info && (this._serverInfo = info), this._serverInfo
|
307 | 277 | }, ApiClient.prototype.getCurrentUserId = function() {
|
@@ -360,7 +330,7 @@ define(["events", "appStorage", "wakeOnLan"], function(events, appStorage, wakeO
|
360 | 330 | contentType: "application/json"
|
361 | 331 | }).then(function(result) {
|
362 | 332 | var afterOnAuthenticated = function() {
|
363 |
| - redetectBitrate(instance), refreshWakeOnLanInfoIfNeeded(instance), resolve(result) |
| 333 | + redetectBitrate(instance), resolve(result) |
364 | 334 | };
|
365 | 335 | instance.onAuthenticated ? instance.onAuthenticated(instance, result).then(afterOnAuthenticated) : afterOnAuthenticated()
|
366 | 336 | }, reject)
|
@@ -1579,19 +1549,10 @@ define(["events", "appStorage", "wakeOnLan"], function(events, appStorage, wakeO
|
1579 | 1549 | return this.getJSON(this.getUrl("System/Endpoint")).then(function(endPointInfo) {
|
1580 | 1550 | return setSavedEndpointInfo(instance, endPointInfo), endPointInfo
|
1581 | 1551 | })
|
1582 |
| - }, ApiClient.prototype.getWakeOnLanInfo = function() { |
1583 |
| - return this.getJSON(this.getUrl("System/WakeOnLanInfo")) |
1584 | 1552 | }, ApiClient.prototype.getLatestItems = function(options) {
|
1585 | 1553 | return options = options || {}, this.getJSON(this.getUrl("Users/" + this.getCurrentUserId() + "/Items/Latest", options))
|
1586 | 1554 | }, ApiClient.prototype.getFilters = function(options) {
|
1587 | 1555 | return this.getJSON(this.getUrl("Items/Filters2", options))
|
1588 |
| - }, ApiClient.prototype.supportsWakeOnLan = function() { |
1589 |
| - return !!wakeOnLan.isSupported() && getCachedWakeOnLanInfo(this).length > 0 |
1590 |
| - }, ApiClient.prototype.wakeOnLan = function() { |
1591 |
| - var infos = getCachedWakeOnLanInfo(this); |
1592 |
| - return new Promise(function(resolve, reject) { |
1593 |
| - sendNextWakeOnLan(infos, 0, resolve) |
1594 |
| - }) |
1595 | 1556 | }, ApiClient.prototype.setSystemInfo = function(info) {
|
1596 | 1557 | this._serverVersion = info.Version
|
1597 | 1558 | }, ApiClient.prototype.serverVersion = function() {
|
|
0 commit comments