2222 </a >
2323 </template >
2424 <template v-else >
25- {{ name | toString }}
25+ <span v-if =" showOnchainIdentity" class =" is-inline-flex is-align-items-center" >
26+ {{ shortenedAddress | toString }}
27+ <img v-if =" isFetchingIdentity" src =" /infinity.svg" class =" ml-1 infinity-loader" >
28+ <template v-else >
29+ <span v-if =" identity.display" class =" ml-1" >({{ identity.display }})</span >
30+ </template >
31+ </span >
32+ <span v-else >
33+ {{ name | toString }}
34+ </span >
2635 </template >
2736 </component >
2837</template >
@@ -52,13 +61,17 @@ export default class Identity extends mixins(InlineMixin) {
5261 @Prop (Boolean ) public noOwerflow! : boolean ;
5362 @Prop (Boolean ) public emit! : boolean ;
5463 @Prop (Boolean ) public showTwitter! : boolean ;
64+ @Prop (Boolean ) public showOnchainIdentity! : boolean ;
5565 private identity: IdentityFields = emptyObject <IdentityFields >();
66+ private isFetchingIdentity = false
67+
68+ get shortenedAddress(): Address {
69+ return shortAddress (this .resolveAddress (this .address ))
70+ }
5671
5772 get name(): Address {
5873 const name = this .identity .display
59- return name
60- ? ` ${shortAddress (this .resolveAddress (this .address ))} (${name }) `
61- : shortAddress (this .resolveAddress (this .address ))
74+ return name as string || this .shortenedAddress
6275 }
6376
6477 get twitter(): Address {
@@ -109,12 +122,14 @@ export default class Identity extends mixins(InlineMixin) {
109122 }
110123
111124 protected async fetchIdentity(address : string ): Promise <IdentityFields > {
125+ this .isFetchingIdentity = true
112126 const { api } = Connector .getInstance ()
113127
114128 const optionIdentity = await api ?.query .identity ?.identityOf (address )
115129 const identity = optionIdentity ?.unwrapOrDefault ()
116130
117131 if (! identity ?.size ) {
132+ this .isFetchingIdentity = false
118133 return emptyObject <IdentityFields >()
119134 }
120135
@@ -126,6 +141,7 @@ export default class Identity extends mixins(InlineMixin) {
126141 }, {} as IdentityFields )
127142
128143 update (address , () => final , identityStore )
144+ this .isFetchingIdentity = false
129145
130146 if (this .emit ) {
131147 this .emitIdentityChange (final )
@@ -159,4 +175,8 @@ export default class Identity extends mixins(InlineMixin) {
159175.overflowWrap {
160176 overflow-wrap : break-word ;
161177}
178+
179+ .infinity-loader {
180+ height : 20px
181+ }
162182 </style >
0 commit comments