@@ -20,6 +20,7 @@ export default class profile extends Vue {
20
20
user: User | null = null
21
21
22
22
@StateNamespace .auth .Getter readonly authUser: AuthUser
23
+ @StateNamespace .loading .Action saveLoading: (loading : boolean ) => Promise <void >
23
24
24
25
asyncData ({ params }: Context ) {
25
26
const username = params [RouteParameters .USERNAME ]
@@ -29,7 +30,7 @@ export default class profile extends Vue {
29
30
}
30
31
}
31
32
32
- async created () {
33
+ mounted () {
33
34
this .$subscribeTo (profilePhotoObservable .asObservable (), (image : Image ) => {
34
35
console .log (' profilePhotoObservable called by ' , image )
35
36
if (this .user ) {
@@ -57,26 +58,32 @@ export default class profile extends Vue {
57
58
})
58
59
}
59
60
60
- const user = await this .loadUser ()
61
- .catch (() => sendDangerNotification (this .$store .dispatch , this .$t (' notification.profile.canNotLoad' ))) as User
62
- if (! user ) {
63
- return this .$nuxt .error ({
64
- message: this .$t (' page.notFound' ) as string ,
65
- path: this .$route .fullPath ,
66
- statusCode: 404
67
- })
68
- }
61
+ this .saveLoading (true )
62
+ .then (async () => {
63
+ const user = await this .loadUser ()
64
+ .catch (() => sendDangerNotification (this .$store .dispatch , this .$t (' notification.profile.canNotLoad' )))
69
65
70
- if (this .authUser .username !== this .username &&
71
- ((! user ?.privacy || user .privacy === PrivacyType .PRIVATE ))) {
72
- console .log (' PRIVATE user' )
73
- this .$nuxt .error ({
74
- message: this .$t (' page.notFound' ) as string ,
75
- path: this .$route .fullPath ,
76
- statusCode: 404
66
+ if (! user ) {
67
+ return this .$nuxt .error ({
68
+ message: this .$t (' page.notFound' ) as string ,
69
+ path: this .$route .fullPath ,
70
+ statusCode: 404
71
+ })
72
+ }
73
+
74
+ if (this .authUser .username !== this .username &&
75
+ ((! user ?.privacy || user .privacy === PrivacyType .PRIVATE ))) {
76
+ console .log (' PRIVATE user' )
77
+ this .$nuxt .error ({
78
+ message: this .$t (' page.notFound' ) as string ,
79
+ path: this .$route .fullPath ,
80
+ statusCode: 404
81
+ })
82
+ }
83
+ this .user = user
77
84
})
78
- }
79
- this . user = user
85
+ . catch (( error : Error ) => console . log ( ' profile.create ' , error ))
86
+ . finally (() => this . saveLoading ( false ))
80
87
}
81
88
82
89
async loadUser (): Promise <User > {
0 commit comments