mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
some bug fixes after master rebase
This commit is contained in:
parent
3c84773792
commit
a106e23ff8
9 changed files with 748 additions and 89 deletions
|
@ -1,7 +1,8 @@
|
|||
/* eslint-disable indent */
|
||||
import { AppStorage, Events } from 'jellyfin-apiclient';
|
||||
|
||||
function getKey(name, userId) {
|
||||
class AppSettings {
|
||||
#getKey(name, userId) {
|
||||
if (userId) {
|
||||
name = userId + '-' + name;
|
||||
}
|
||||
|
@ -9,46 +10,46 @@ import { AppStorage, Events } from 'jellyfin-apiclient';
|
|||
return name;
|
||||
}
|
||||
|
||||
export function enableAutoLogin(val) {
|
||||
enableAutoLogin(val) {
|
||||
if (val !== undefined) {
|
||||
set('enableAutoLogin', val.toString());
|
||||
this.set('enableAutoLogin', val.toString());
|
||||
}
|
||||
|
||||
return get('enableAutoLogin') !== 'false';
|
||||
return this.get('enableAutoLogin') !== 'false';
|
||||
}
|
||||
|
||||
export function enableSystemExternalPlayers(val) {
|
||||
enableSystemExternalPlayers(val) {
|
||||
if (val !== undefined) {
|
||||
set('enableSystemExternalPlayers', val.toString());
|
||||
this.set('enableSystemExternalPlayers', val.toString());
|
||||
}
|
||||
|
||||
return get('enableSystemExternalPlayers') === 'true';
|
||||
return this.get('enableSystemExternalPlayers') === 'true';
|
||||
}
|
||||
|
||||
export function enableAutomaticBitrateDetection(isInNetwork, mediaType, val) {
|
||||
enableAutomaticBitrateDetection(isInNetwork, mediaType, val) {
|
||||
const key = 'enableautobitratebitrate-' + mediaType + '-' + isInNetwork;
|
||||
if (val !== undefined) {
|
||||
if (isInNetwork && mediaType === 'Audio') {
|
||||
val = true;
|
||||
}
|
||||
|
||||
set(key, val.toString());
|
||||
this.set(key, val.toString());
|
||||
}
|
||||
|
||||
if (isInNetwork && mediaType === 'Audio') {
|
||||
return true;
|
||||
} else {
|
||||
return get(key) !== 'false';
|
||||
return this.get(key) !== 'false';
|
||||
}
|
||||
}
|
||||
|
||||
export function maxStreamingBitrate(isInNetwork, mediaType, val) {
|
||||
maxStreamingBitrate(isInNetwork, mediaType, val) {
|
||||
const key = 'maxbitrate-' + mediaType + '-' + isInNetwork;
|
||||
if (val !== undefined) {
|
||||
if (isInNetwork && mediaType === 'Audio') {
|
||||
// nothing to do, this is always a max value
|
||||
} else {
|
||||
set(key, val);
|
||||
this.set(key, val);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,50 +57,42 @@ import { AppStorage, Events } from 'jellyfin-apiclient';
|
|||
// return a huge number so that it always direct plays
|
||||
return 150000000;
|
||||
} else {
|
||||
return parseInt(get(key) || '0') || 1500000;
|
||||
return parseInt(this.get(key) || '0') || 1500000;
|
||||
}
|
||||
}
|
||||
|
||||
export function maxStaticMusicBitrate(val) {
|
||||
maxStaticMusicBitrate(val) {
|
||||
if (val !== undefined) {
|
||||
set('maxStaticMusicBitrate', val);
|
||||
this.set('maxStaticMusicBitrate', val);
|
||||
}
|
||||
|
||||
const defaultValue = 320000;
|
||||
return parseInt(get('maxStaticMusicBitrate') || defaultValue.toString()) || defaultValue;
|
||||
return parseInt(this.get('maxStaticMusicBitrate') || defaultValue.toString()) || defaultValue;
|
||||
}
|
||||
|
||||
export function maxChromecastBitrate(val) {
|
||||
maxChromecastBitrate(val) {
|
||||
if (val !== undefined) {
|
||||
set('chromecastBitrate1', val);
|
||||
this.set('chromecastBitrate1', val);
|
||||
}
|
||||
|
||||
val = get('chromecastBitrate1');
|
||||
val = this.get('chromecastBitrate1');
|
||||
return val ? parseInt(val) : null;
|
||||
}
|
||||
|
||||
export function set(name, value, userId) {
|
||||
const currentValue = get(name, userId);
|
||||
AppStorage.setItem(getKey(name, userId), value);
|
||||
set(name, value, userId) {
|
||||
const currentValue = this.get(name, userId);
|
||||
AppStorage.setItem(this.#getKey(name, userId), value);
|
||||
|
||||
if (currentValue !== value) {
|
||||
Events.trigger(this, 'change', [name]);
|
||||
}
|
||||
}
|
||||
|
||||
export function get(name, userId) {
|
||||
return AppStorage.getItem(getKey(name, userId));
|
||||
get(name, userId) {
|
||||
return AppStorage.getItem(this.#getKey(name, userId));
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-enable indent */
|
||||
|
||||
export default {
|
||||
enableAutoLogin: enableAutoLogin,
|
||||
enableSystemExternalPlayers: enableSystemExternalPlayers,
|
||||
enableAutomaticBitrateDetection: enableAutomaticBitrateDetection,
|
||||
maxStreamingBitrate: maxStreamingBitrate,
|
||||
maxStaticMusicBitrate: maxStaticMusicBitrate,
|
||||
maxChromecastBitrate: maxChromecastBitrate,
|
||||
set: set,
|
||||
get: get
|
||||
};
|
||||
export default new AppSettings();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue