Add ProfileWrapper class
This commit is contained in:
parent
a0593b6a01
commit
203fb357e6
2 changed files with 21 additions and 5 deletions
|
@ -21,14 +21,12 @@ export interface Profile {
|
|||
note: string | null;
|
||||
avatar: string | null;
|
||||
header: string | null;
|
||||
identity_proofs: ProfileField[],
|
||||
identity_proofs: ProfileField[];
|
||||
fields: ProfileField[];
|
||||
|
||||
followers_count: number;
|
||||
following_count: number;
|
||||
statuses_count: number;
|
||||
|
||||
source: Source | null;
|
||||
}
|
||||
|
||||
export function getVerifiedEthereumAddress(profile: Profile): string | null {
|
||||
|
@ -45,6 +43,23 @@ export interface User extends Profile {
|
|||
wallet_address: string | null;
|
||||
}
|
||||
|
||||
export interface ProfileWrapper extends Profile {}
|
||||
export class ProfileWrapper {
|
||||
|
||||
constructor(source: Profile) {
|
||||
Object.assign(this, source)
|
||||
}
|
||||
|
||||
getDisplayName(): string {
|
||||
return this.display_name || this.username
|
||||
}
|
||||
|
||||
getVerifiedEthereumAddress(): string | null {
|
||||
return getVerifiedEthereumAddress(this)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export interface UserCreateForm {
|
||||
username: string;
|
||||
message: string;
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
<script setup lang="ts">
|
||||
import { $, $ref } from "vue/macros"
|
||||
|
||||
import { getVerifiedEthereumAddress, Profile } from "@/api/users"
|
||||
import { Profile, ProfileWrapper } from "@/api/users"
|
||||
import {
|
||||
cancelSubscription,
|
||||
getSubscriptionInfo,
|
||||
|
@ -59,7 +59,8 @@ const props = defineProps<{
|
|||
|
||||
const { instance } = $(useInstanceInfo())
|
||||
const { connectWallet: connectEthereumWallet } = useWallet()
|
||||
const recipientEthereumAddress = getVerifiedEthereumAddress(props.profile)
|
||||
const recipient = new ProfileWrapper(props.profile)
|
||||
const recipientEthereumAddress = recipient.getVerifiedEthereumAddress()
|
||||
let { walletAddress, walletError } = $(useWallet())
|
||||
let subscriptionConfigured = $ref<boolean | null>(null)
|
||||
let subscription = $ref<Subscription | null>(null)
|
||||
|
|
Loading…
Reference in a new issue