Skip to content

Commit b7db507

Browse files
authored
[fix] add correct account existence check (#254)
1 parent 6e07630 commit b7db507

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/layouts/profile.vue

+16-2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import Footer from '@/components/Footer.vue'
5252
import { createDefaultProfile, getProfile, Profile } from '@/backend/profile'
5353
import { getPhotoFromIPFS } from '@/backend/photos'
5454
import { followChange, getFollowersAndFollowing } from '@/backend/following'
55+
import { getUserInfoNEAR } from '@/backend/near'
5556
5657
interface IData {
5758
myProfile: Profile
@@ -96,9 +97,10 @@ export default Vue.extend({
9697
this.$router.push(`/`)
9798
}
9899
99-
const [myProfile, visitProfile] = await Promise.all([
100+
const [myProfile, visitProfile, profileExists] = await Promise.all([
100101
getProfile(this.$store.state.session.id),
101102
getProfile(this.$route.params.id),
103+
this.checkAccountExists(),
102104
])
103105
// get my profile and avatar
104106
this.myProfile = myProfile || createDefaultProfile(this.$store.state.session.id)
@@ -107,7 +109,7 @@ export default Vue.extend({
107109
this.myAvatar = p
108110
})
109111
}
110-
if (visitProfile === null) {
112+
if (!profileExists) {
111113
this.noProfileFound = true
112114
this.$toastError(`Profile does not exist`)
113115
return
@@ -139,6 +141,18 @@ export default Vue.extend({
139141
this.following = following
140142
this.userIsFollowed = followers.has(this.$store.state.session.id)
141143
},
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+
},
142156
},
143157
})
144158
</script>

0 commit comments

Comments
 (0)