Skip to content

Commit

Permalink
Automatic eslint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ferferga committed Feb 12, 2021
1 parent f08f13a commit 073b10a
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 48 deletions.
8 changes: 4 additions & 4 deletions src/components/fetchhelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,19 @@ function fetchWithTimeout(
timeoutMs: number
): Promise<Response> {
console.log('fetchWithTimeout: timeoutMs: ' + timeoutMs + ', url: ' + url);
return new Promise(function (resolve, reject) {
return new Promise((resolve, reject) => {
const timeout = setTimeout(reject, timeoutMs);
options = options || {};
options.credentials = 'same-origin';
fetch(url, options).then(
function (response) {
(response) => {
clearTimeout(timeout);
console.log(
'fetchWithTimeout: succeeded connecting to url: ' + url
);
resolve(response);
},
function () {
() => {
clearTimeout(timeout);
console.log(
'fetchWithTimeout: timed out connecting to url: ' + url
Expand Down Expand Up @@ -127,7 +127,7 @@ export function ajax(request: any): Promise<any> {
return response;
}
},
function (err) {
(err) => {
console.log('request failed to url: ' + request.url);
throw err;
}
Expand Down
40 changes: 30 additions & 10 deletions src/components/jellyfinActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function restartPingInterval(
stopPingInterval();

if (reportingParams.PlayMethod == 'Transcode') {
pingInterval = <any>setInterval(function () {
pingInterval = <any>setInterval(() => {
pingTranscoder(reportingParams);
}, 1000);
}
Expand Down Expand Up @@ -179,7 +179,7 @@ export function pingTranscoder(
// 10s is the timeout value, so use half that to report often enough
if (now - lastTranscoderPing < 5000) {
console.debug('Skipping ping due to recent progress check-in');
return new Promise(function (resolve) {
return new Promise((resolve) => {
resolve();
});
}
Expand Down Expand Up @@ -218,7 +218,7 @@ export function startBackdropInterval(): void {

setRandomUserBackdrop();

backdropInterval = <any>setInterval(function () {
backdropInterval = <any>setInterval(() => {
setRandomUserBackdrop();
}, 30000);
}
Expand All @@ -242,7 +242,7 @@ function setRandomUserBackdrop(): Promise<void> {
// not everyone will want to see adult backdrops rotating on their TV.
MaxOfficialRating: 'PG-13'
}
}).then(function (result: BaseItemDtoQueryResult) {
}).then((result: BaseItemDtoQueryResult) => {
let url = '';
if (result.Items && result.Items[0]) {
url = getBackdropUrl(result.Items[0]) || '';
Expand Down Expand Up @@ -366,7 +366,7 @@ export function play($scope: GlobalScope): void {
$scope.status == 'playing' ||
$scope.status == 'audio'
) {
setTimeout(function () {
setTimeout(() => {
window.mediaManager.play();

setAppStatus('playing-with-controls');
Expand All @@ -381,11 +381,21 @@ export function play($scope: GlobalScope): void {
* Don't actually stop, just show the idle view after 20ms
*/
export function stop(): void {
setTimeout(function () {
setTimeout(() => {
setAppStatus('waiting');
}, 20);
}

/**
* @param item
* @param maxBitrate
* @param deviceProfile
* @param startPosition
* @param mediaSourceId
* @param audioStreamIndex
* @param subtitleStreamIndex
* @param liveStreamId
*/
export function getPlaybackInfo(
item: BaseItemDto,
maxBitrate: number,
Expand Down Expand Up @@ -429,6 +439,16 @@ export function getPlaybackInfo(
});
}

/**
* @param item
* @param playSessionId
* @param maxBitrate
* @param deviceProfile
* @param startPosition
* @param mediaSource
* @param audioStreamIndex
* @param subtitleStreamIndex
*/
export function getLiveStream(
item: BaseItemDto,
playSessionId: string,
Expand Down Expand Up @@ -485,11 +505,11 @@ export function getDownloadSpeed(byteSize: number): Promise<number> {
type: 'GET',
timeout: 5000
})
.then(function (response) {
.then((response) => {
// Need to wait for the whole response before calculating speed
return response.blob();
})
.then(function () {
.then(() => {
const responseTimeSeconds = (new Date().getTime() - now) / 1000;
const bytesPerSecond = byteSize / responseTimeSeconds;
const bitrate = Math.round(bytesPerSecond * 8);
Expand All @@ -506,12 +526,12 @@ export function getDownloadSpeed(byteSize: number): Promise<number> {
*/
export function detectBitrate(): Promise<number> {
// First try a small amount so that we don't hang up their mobile connection
return getDownloadSpeed(1000000).then(function (bitrate) {
return getDownloadSpeed(1000000).then((bitrate) => {
if (bitrate < 1000000) {
return Math.round(bitrate * 0.8);
} else {
// If that produced a fairly high speed, try again with a larger size to get a more accurate result
return getDownloadSpeed(2400000).then(function (bitrate) {
return getDownloadSpeed(2400000).then((bitrate) => {
return Math.round(bitrate * 0.8);
});
}
Expand Down
Loading

0 comments on commit 073b10a

Please sign in to comment.