update live tv loading

This commit is contained in:
Luke Pulverenti 2015-05-26 13:48:05 -04:00
parent 28f378f8db
commit f82049f935
7 changed files with 177 additions and 14 deletions

View file

@ -671,7 +671,8 @@
Id: foundServer.Id,
LocalAddress: foundServer.Address,
Name: foundServer.Name,
ManualAddress: convertEndpointAddressToManualAddress(foundServer)
ManualAddress: convertEndpointAddressToManualAddress(foundServer),
DateLastLocalConnection: new Date().getTime()
};
info.LastConnectionMode = info.ManualAddress ? MediaBrowser.ConnectionMode.Manual : MediaBrowser.ConnectionMode.Local;
@ -1223,7 +1224,41 @@
self.getRegistrationInfo = function (feature, apiClient) {
return apiClient.getRegistrationInfo(feature);
var deferred = DeferredBuilder.Deferred();
self.getAvailableServers().done(function (servers) {
var matchedServers = servers.filter(function (s) {
return stringEqualsIgnoreCase(s.Id, apiClient.serverInfo().Id);
});
if (!matchedServers.length) {
deferred.resolveWith(null, [{}]);
return;
}
var match = matchedServers[0];
// 31 days
if ((new Date().getTime() - (match.DateLastLocalConnection || 0)) > 2678400000) {
deferred.resolveWith(null, [{}]);
return;
}
apiClient.getRegistrationInfo(feature).done(function (result) {
deferred.resolveWith(null, [result]);
}).fail(function () {
deferred.reject();
});
}).fail(function () {
deferred.reject();
});
return deferred.promise();
};

View file

@ -83,6 +83,7 @@
if (server.LastConnectionMode != null) {
existing.LastConnectionMode = server.LastConnectionMode;
}
existing.DateLastLocalConnection = Math.max(existing.DateLastLocalConnection || 0, server.DateLastLocalConnection || 0);
return existing;
}