fixed capabilities.account when localStorage is disabled

This commit is contained in:
Danny Coates 2018-09-17 12:05:03 -07:00
parent 942457b357
commit 7dcf4bcdb9
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
2 changed files with 17 additions and 3 deletions

View File

@ -62,9 +62,15 @@ export default async function capabilities() {
const crypto = await checkCrypto();
const nativeStreams = checkStreams();
const polyStreams = nativeStreams ? false : polyfillStreams();
let account = false;
try {
account = !!localStorage;
} catch (e) {
// nevermind
}
return {
account: typeof localStorage !== 'undefined',
account,
crypto,
streamUpload: nativeStreams || polyStreams,
streamDownload:

View File

@ -17,11 +17,15 @@ module.exports = function(state, emit) {
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');
el.replaceChild(
selectbox(
state.downloadCount || 1,
[1, 2, 3, 4, 5, 20, 50, 100, 200],
counts,
num => state.translate('downloadCount', { num }),
value => {
const max = state.user.maxDownloads;
@ -36,11 +40,15 @@ module.exports = function(state, emit) {
dlCountSelect
);
const expires = [300, 3600, 86400, 604800].filter(
i => state.capabilities.account || i <= state.user.maxExpireSeconds
);
const timeSelect = el.querySelector('#timespan');
el.replaceChild(
selectbox(
state.timeLimit || 86400,
[300, 3600, 86400, 604800],
expires,
num => timeLimitText(state.translate, num),
value => {
const max = state.user.maxExpireSeconds;