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 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:

View File

@ -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;