@@ -52,6 +52,7 @@ import Footer from '@/components/Footer.vue'
52
52
import { createDefaultProfile , getProfile , Profile } from ' @/backend/profile'
53
53
import { getPhotoFromIPFS } from ' @/backend/photos'
54
54
import { followChange , getFollowersAndFollowing } from ' @/backend/following'
55
+ import { getUserInfoNEAR } from ' @/backend/near'
55
56
56
57
interface IData {
57
58
myProfile: Profile
@@ -96,9 +97,10 @@ export default Vue.extend({
96
97
this .$router .push (` / ` )
97
98
}
98
99
99
- const [myProfile, visitProfile] = await Promise .all ([
100
+ const [myProfile, visitProfile, profileExists ] = await Promise .all ([
100
101
getProfile (this .$store .state .session .id ),
101
102
getProfile (this .$route .params .id ),
103
+ this .checkAccountExists (),
102
104
])
103
105
// get my profile and avatar
104
106
this .myProfile = myProfile || createDefaultProfile (this .$store .state .session .id )
@@ -107,7 +109,7 @@ export default Vue.extend({
107
109
this .myAvatar = p
108
110
})
109
111
}
110
- if (visitProfile === null ) {
112
+ if (! profileExists ) {
111
113
this .noProfileFound = true
112
114
this .$toastError (` Profile does not exist ` )
113
115
return
@@ -139,6 +141,18 @@ export default Vue.extend({
139
141
this .following = following
140
142
this .userIsFollowed = followers .has (this .$store .state .session .id )
141
143
},
144
+ async checkAccountExists() {
145
+ try {
146
+ await getUserInfoNEAR (this .$route .params .id )
147
+ return true
148
+ } catch (err : any ) {
149
+ if (err .message === ` Username not found on NEAR! ` ) {
150
+ return false
151
+ }
152
+
153
+ throw err
154
+ }
155
+ },
142
156
},
143
157
})
144
158
</script >
0 commit comments