Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.

Commit afc39e6

Browse files
committed
feat: navigate back on rating success
1 parent 851397b commit afc39e6

File tree

5 files changed

+31
-26
lines changed

5 files changed

+31
-26
lines changed

middleware/redirects.ts renamed to middleware/routerHelperMiddleware.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { Middleware } from '@nuxt/types'
1+
import {Middleware} from '@nuxt/types'
2+
3+
const routerHelperMiddleware: Middleware = function ({store, from, route, redirect}) {
4+
store.commit('app/setIsFirstVisitedRoute', !from)
25

3-
const redirectsMiddleware: Middleware = function ({ route, redirect }) {
46
const redirects = [
57
{
68
from: '/community',
@@ -13,4 +15,4 @@ const redirectsMiddleware: Middleware = function ({ route, redirect }) {
1315
}
1416
}
1517

16-
export default redirectsMiddleware
18+
export default routerHelperMiddleware

nuxt.config.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Configuration as WebpackConfiguration } from 'webpack'
2-
import { NuxtOptionsLoaders, NuxtWebpackEnv } from '@nuxt/types/config/build'
1+
import {Configuration as WebpackConfiguration} from 'webpack'
2+
import {NuxtOptionsLoaders, NuxtWebpackEnv} from '@nuxt/types/config/build'
33

44
const DOTENV_PATH =
55
process.env.NODE_ENV === 'production' ? '.env.production' : '.env.development'
6-
require('dotenv').config({ path: DOTENV_PATH })
6+
require('dotenv').config({path: DOTENV_PATH})
77

88
const title = 'Discover & grow your Aura...'
99
const description = 'Your Aura represents power & influence upon the Auracle.'
@@ -21,15 +21,15 @@ export default {
2121
head: {
2222
title,
2323
meta: [
24-
{ charset: 'utf-8' },
25-
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
24+
{charset: 'utf-8'},
25+
{name: 'viewport', content: 'width=device-width, initial-scale=1'},
2626
{
2727
hid: 'description',
2828
name: 'description',
2929
content: description,
3030
},
3131

32-
{ name: 'twitter:card', content: 'summary_large_image' },
32+
{name: 'twitter:card', content: 'summary_large_image'},
3333
{
3434
name: 'twitter:title',
3535
content: title,
@@ -61,10 +61,10 @@ export default {
6161
name: 'og:title',
6262
content: description,
6363
},
64-
{ hid: 'theme-color', name: 'theme-color', content: '#333333' },
64+
{hid: 'theme-color', name: 'theme-color', content: '#333333'},
6565
],
6666
link: [
67-
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
67+
{rel: 'icon', type: 'image/x-icon', href: '/favicon.ico'},
6868
{
6969
rel: 'dns-prefetch',
7070
href: 'https://fonts.gstatic.com/',
@@ -101,22 +101,22 @@ export default {
101101
// Modules: https://go.nuxtjs.dev/config-modules
102102
modules: [
103103
// https://go.nuxtjs.dev/pwa
104-
['@nuxtjs/dotenv', { filename: DOTENV_PATH }],
104+
['@nuxtjs/dotenv', {filename: DOTENV_PATH}],
105105
'@nuxtjs/pwa',
106106
'@nuxtjs/axios',
107107
'@nuxtjs/date-fns',
108108
],
109109

110-
middleware: ['redirects'],
110+
middleware: ['routerHelperMiddleware'],
111111
router: {
112-
middleware: 'redirects',
112+
middleware: 'routerHelperMiddleware',
113113
},
114114

115115
proxy: {
116116
'/brightid': {
117117
target: 'https://recovery.brightid.org',
118118
changeOrigin: true,
119-
pathRewrite: { '^/brightid': '/' },
119+
pathRewrite: {'^/brightid': '/'},
120120
},
121121
},
122122

pages/profile/_id.vue

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,6 @@ export default {
9797
},
9898
mixins: [transition, unsavedChanges, avatar],
9999
100-
beforeRouteEnter(_to, from, next) {
101-
next(vm => {
102-
vm.fromRoute = from
103-
})
104-
},
105-
106100
data() {
107101
return {
108102
profile: {},
@@ -258,10 +252,10 @@ export default {
258252
}).catch(onError)
259253
},
260254
onAfterSave() {
261-
if (this.fromRoute?.name) {
262-
this.$router.go(-1)
263-
} else {
255+
if (this.$store.getters["app/isFirstVisitedRoute"]) {
264256
this.$router.push('/connections/')
257+
} else {
258+
this.$router.go(-1)
265259
}
266260
},
267261
async loadConnectionProfile() {

store/app.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
import { MutationTree } from 'vuex'
2-
import { AppState } from '~/types/store'
1+
import {GetterTree, MutationTree} from 'vuex'
2+
import {AppState, RootState} from '~/types/store'
33

44
export const state = (): AppState => ({
55
hasUnsavedChanges: false,
66
loading: false,
77
isWebp: false,
88
isAuth: false,
9+
isFirstVisitedRoute: true,
910
})
1011

12+
export const getters: GetterTree<AppState, RootState> = {
13+
isFirstVisitedRoute: state => state.isFirstVisitedRoute
14+
}
15+
1116
export const mutations: MutationTree<AppState> = {
1217
setHasUnsavedChanges(state, value) {
1318
state.hasUnsavedChanges = value
1419
},
20+
setIsFirstVisitedRoute(state, value) {
21+
state.isFirstVisitedRoute = value
22+
},
1523
setLoading(state, value) {
1624
state.loading = value
1725
},

types/store.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export type AppState = {
1919
loading: boolean
2020
isWebp: boolean
2121
isAuth: boolean
22+
isFirstVisitedRoute: boolean
2223
}
2324
export type ConnectionsState = {
2425
connectionsData: AuraConnection[]

0 commit comments

Comments
 (0)