Skip to content

Commit

Permalink
[native] Implement Update screen
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelklehr committed Mar 16, 2022
1 parent 8016256 commit 22cc780
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 25 deletions.
3 changes: 3 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -533,5 +533,8 @@
},
"LabelMobilesettings": {
"message": "Mobile settings"
},
"LabelContinuefloccus":{
"message": "Continue to floccus"
}
}
14 changes: 0 additions & 14 deletions src/lib/native/NativeController.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Storage } from '@capacitor/storage'
import Cryptography from '../Crypto'
import packageJson from '../../../package.json'
import NativeAccountStorage from './NativeAccountStorage'

import PQueue from 'p-queue'
Expand Down Expand Up @@ -49,19 +48,6 @@ export default class NativeController {
this.key = null
}
})

// do some cleaning if this is a new version

Storage.get({key: 'currentVersion'}).then(async({value: currentVersion}) => {
if (packageJson.version === currentVersion) return
await Storage.set({key: 'currentVersion', value: packageJson.version})

const packageVersion = packageJson.version.split('.')
const lastVersion = currentVersion ? currentVersion.split('.') : []
if (packageVersion[0] !== lastVersion[0] || packageVersion[1] !== lastVersion[1]) {
// TODO display '/dist/html/options.html#/update',
}
})
}

setEnabled(enabled) {
Expand Down
5 changes: 5 additions & 0 deletions src/ui/NativeRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ export const router = new Router({
name: routes.NEW_ACCOUNT,
component: NewAccount,
},
{
path: '/update',
name: routes.UPDATE,
component: () => import(/* webpackPrefetch: true */ './views/Update'),
},
{
path: '/newBookmark/:accountId/:url/:text?',
name: routes.ADD_BOOKMARK,
Expand Down
35 changes: 25 additions & 10 deletions src/ui/views/Update.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
:color="'light-blue'"
class="mr-2 mb-2"
target="_blank"
width="48%"
:href="processor.href">
<v-card-title class="white--text">
{{ processor.label }}
Expand All @@ -44,14 +43,22 @@
</v-card>
</div>
</v-card-text>
<v-card-text v-if="!isBrowser">
<v-btn
class="primary mt-2"
target="_blank"
:to="{name: nativeRoutes.HOME }">
{{ t('LabelContinuefloccus') }}
</v-btn>
</v-card-text>
</v-container>
</v-card>
</v-container>
</template>

<script>
import {version as VERSION} from '../../../package.json'
import browser from '../../lib/browser-api'
import { routes } from '../NativeRouter'
export default {
name: 'Update',
Expand All @@ -61,30 +68,33 @@ export default {
paymentOptions: [
{
href: 'https://www.paypal.me/marcelklehr1',
label: browser.i18n.getMessage('LabelPaypal'),
description: browser.i18n.getMessage('DescriptionPaypal')
label: this.t('LabelPaypal'),
description: this.t('DescriptionPaypal')
},
{
href: 'https://opencollective.com/floccus',
label: browser.i18n.getMessage('LabelOpencollective'),
description: browser.i18n.getMessage('DescriptionOpencollective')
label: this.t('LabelOpencollective'),
description: this.t('DescriptionOpencollective')
},
{
href: 'https://liberapay.com/marcelklehr/donate',
label: browser.i18n.getMessage('LabelLiberapay'),
description: browser.i18n.getMessage('DescriptionLiberapay')
label: this.t('LabelLiberapay'),
description: this.t('DescriptionLiberapay')
},
{
href: 'https://github.com/users/marcelklehr/sponsorship',
label: browser.i18n.getMessage('LabelGithubsponsors'),
description: browser.i18n.getMessage('DescriptionGithubsponsors')
label: this.t('LabelGithubsponsors'),
description: this.t('DescriptionGithubsponsors')
}
]
}
},
computed: {
VERSION() {
return VERSION
},
nativeRoutes() {
return routes
}
},
methods: {
Expand All @@ -97,4 +107,9 @@ export default {
max-width: 600px;
margin: 0 auto;
}
@media screen and (min-width: 600px) {
.v-card--flat {
width: 48%
}
}
</style>
15 changes: 14 additions & 1 deletion src/ui/views/native/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { routes } from '../../NativeRouter'
import { SplashScreen } from '@capacitor/splash-screen'
import { SendIntent } from 'send-intent'
import Controller from '../../../lib/Controller'
import packageJson from '../../../../package.json'
import { Storage } from '@capacitor/storage'
export default {
name: 'Home',
Expand All @@ -20,7 +22,18 @@ export default {
SplashScreen.hide()
await this.$store.dispatch(actions.LOAD_ACCOUNTS)
if (Object.keys(this.$store.state.accounts).length) {
const {value: currentVersion} = await Storage.get({key: 'currentVersion'})
if (currentVersion && packageJson.version !== currentVersion) {
await Storage.set({ key: 'currentVersion', value: packageJson.version })
const packageVersion = packageJson.version.split('.')
const lastVersion = currentVersion ? currentVersion.split('.') : []
if (packageVersion[0] !== lastVersion[0] || packageVersion[1] !== lastVersion[1]) {
if (this.$route !== routes.UPDATE) {
this.$router.push({ name: routes.UPDATE })
}
}
} else if (Object.keys(this.$store.state.accounts).length) {
const intentReceived = await this.checkForIntent()
if (!intentReceived) {
const accountId = Object.keys(this.$store.state.accounts)[0]
Expand Down

0 comments on commit 22cc780

Please sign in to comment.