Improve profile search accuracy on subscription page

This commit is contained in:
silverpill 2022-09-08 18:34:46 +00:00
parent 376cd9e264
commit 2ebd2bad62

View file

@ -21,15 +21,17 @@
<input <input
type="text" type="text"
v-model="senderAcct" v-model="senderAcct"
placeholder="Enter your fediverse address (user@example.org)" placeholder="Enter your username or fediverse address (user@example.org)"
> >
<button <button
type="submit" type="submit"
class="btn" class="btn"
:disabled="!senderAcct"
@click.prevent="identifySender()" @click.prevent="identifySender()"
> >
Find profile Find profile
</button> </button>
<span class="sender-error">{{ senderError }}</span>
</form> </form>
<div class="info" v-if="subscriptionOption !== null && sender.id !== ''"> <div class="info" v-if="subscriptionOption !== null && sender.id !== ''">
<template v-if="subscriptionPrice"> <template v-if="subscriptionPrice">
@ -115,6 +117,7 @@ const props = defineProps<{
const { currentUser } = $(useCurrentUser()) const { currentUser } = $(useCurrentUser())
const recipient = new ProfileWrapper(props.profile) const recipient = new ProfileWrapper(props.profile)
const senderAcct = $ref("") const senderAcct = $ref("")
let senderError = $ref<string | null>(null)
let sender = $ref<ProfileWrapper>(new ProfileWrapper(currentUser || guest())) let sender = $ref<ProfileWrapper>(new ProfileWrapper(currentUser || guest()))
let subscriptionOption = $ref<ProfilePaymentOption | null>(null) let subscriptionOption = $ref<ProfilePaymentOption | null>(null)
let subscriptionPrice = $ref<number | null>(null) let subscriptionPrice = $ref<number | null>(null)
@ -142,9 +145,16 @@ async function identifySender() {
} }
isLoading = true isLoading = true
const profiles = await searchProfilesByAcct(senderAcct) const profiles = await searchProfilesByAcct(senderAcct)
const profile = profiles[0] if (profiles.length > 1) {
if (profile && profile.id !== recipient.id) { senderError = "Please provide full address"
sender = new ProfileWrapper(profile) } else {
const profile = profiles[0]
if (profile && profile.id !== recipient.id) {
sender = new ProfileWrapper(profile)
senderError = null
} else {
senderError = "Profile not found"
}
} }
isLoading = false isLoading = false
} }