From 5c5853c645c91f1e626095bc567fdca52788591c Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Fri, 24 Jul 2020 22:04:42 -0700 Subject: [PATCH] minor style tweaks and refresh token fixes --- app/ui/modal.js | 2 +- app/ui/signupDialog.js | 8 +++----- app/user.js | 46 ++++++++++++++++++++++-------------------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/app/ui/modal.js b/app/ui/modal.js index 8fa85111..3636af8a 100644 --- a/app/ui/modal.js +++ b/app/ui/modal.js @@ -6,7 +6,7 @@ module.exports = function(state, emit) { class="absolute inset-0 flex items-center justify-center overflow-hidden z-40 bg-white md:rounded-xl md:my-8 dark:bg-grey-90" >
${state.modal(state, emit, close)} diff --git a/app/ui/signupDialog.js b/app/ui/signupDialog.js index 23fe9a66..970150a6 100644 --- a/app/ui/signupDialog.js +++ b/app/ui/signupDialog.js @@ -1,16 +1,15 @@ const html = require('choo/html'); const assets = require('../../common/assets'); -const { bytes, platform } = require('../utils'); +const { bytes } = require('../utils'); const { canceledSignup, submittedSignup } = require('../metrics'); module.exports = function(trigger) { return function(state, emit, close) { const DAYS = Math.floor(state.LIMITS.MAX_EXPIRE_SECONDS / 86400); - const hidden = platform() === 'android' ? 'hidden' : ''; let submitting = false; return html`
  • ${state.translate('accountBenefitSync')}
  • -
  • ${state.translate('accountBenefitMoz')}
  • { + const refreshed = await this.refresh(); + if (refreshed) { + return await this.syncFileList(); + } else { + return { incoming: true }; } - } + }; try { - const encrypted = await getFileList( - this.bearerToken, - this.refreshToken, - kid - ); + const encrypted = await getFileList(this.bearerToken, kid); const decrypted = await streamToArrayBuffer( decryptStream(blobStream(encrypted), key) ); list = JSON.parse(textDecoder.decode(decrypted)); } catch (e) { - return retry(e); + if (e.message === '401') { + return retry(e); + } } changes = await this.storage.merge(list); if (!changes.outgoing) { @@ -307,9 +307,11 @@ export default class User { const encrypted = await streamToArrayBuffer( encryptStream(blobStream(blob), key) ); - await setFileList(this.bearerToken, this.refreshToken, kid, encrypted); + await setFileList(this.bearerToken, kid, encrypted); } catch (e) { - return retry(e); + if (e.message === '401') { + return retry(e); + } } return changes; }