fixed capabilities.account when localStorage is disabled
This commit is contained in:
parent
942457b357
commit
7dcf4bcdb9
|
@ -62,9 +62,15 @@ export default async function capabilities() {
|
||||||
const crypto = await checkCrypto();
|
const crypto = await checkCrypto();
|
||||||
const nativeStreams = checkStreams();
|
const nativeStreams = checkStreams();
|
||||||
const polyStreams = nativeStreams ? false : polyfillStreams();
|
const polyStreams = nativeStreams ? false : polyfillStreams();
|
||||||
|
let account = false;
|
||||||
|
try {
|
||||||
|
account = !!localStorage;
|
||||||
|
} catch (e) {
|
||||||
|
// nevermind
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
account: typeof localStorage !== 'undefined',
|
account,
|
||||||
crypto,
|
crypto,
|
||||||
streamUpload: nativeStreams || polyStreams,
|
streamUpload: nativeStreams || polyStreams,
|
||||||
streamDownload:
|
streamDownload:
|
||||||
|
|
|
@ -17,11 +17,15 @@ module.exports = function(state, emit) {
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const counts = [1, 2, 3, 4, 5, 20, 50, 100, 200].filter(
|
||||||
|
i => state.capabilities.account || i <= state.user.maxDownloads
|
||||||
|
);
|
||||||
|
|
||||||
const dlCountSelect = el.querySelector('#dlCount');
|
const dlCountSelect = el.querySelector('#dlCount');
|
||||||
el.replaceChild(
|
el.replaceChild(
|
||||||
selectbox(
|
selectbox(
|
||||||
state.downloadCount || 1,
|
state.downloadCount || 1,
|
||||||
[1, 2, 3, 4, 5, 20, 50, 100, 200],
|
counts,
|
||||||
num => state.translate('downloadCount', { num }),
|
num => state.translate('downloadCount', { num }),
|
||||||
value => {
|
value => {
|
||||||
const max = state.user.maxDownloads;
|
const max = state.user.maxDownloads;
|
||||||
|
@ -36,11 +40,15 @@ module.exports = function(state, emit) {
|
||||||
dlCountSelect
|
dlCountSelect
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const expires = [300, 3600, 86400, 604800].filter(
|
||||||
|
i => state.capabilities.account || i <= state.user.maxExpireSeconds
|
||||||
|
);
|
||||||
|
|
||||||
const timeSelect = el.querySelector('#timespan');
|
const timeSelect = el.querySelector('#timespan');
|
||||||
el.replaceChild(
|
el.replaceChild(
|
||||||
selectbox(
|
selectbox(
|
||||||
state.timeLimit || 86400,
|
state.timeLimit || 86400,
|
||||||
[300, 3600, 86400, 604800],
|
expires,
|
||||||
num => timeLimitText(state.translate, num),
|
num => timeLimitText(state.translate, num),
|
||||||
value => {
|
value => {
|
||||||
const max = state.user.maxExpireSeconds;
|
const max = state.user.maxExpireSeconds;
|
||||||
|
|
Loading…
Reference in New Issue