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,11 +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 as string || shortAddress ( this .resolveAddress ( this . address ))
74+ return name as string || this .shortenedAddress
6075 }
6176
6277 get twitter(): Address {
@@ -107,12 +122,14 @@ export default class Identity extends mixins(InlineMixin) {
107122 }
108123
109124 protected async fetchIdentity(address : string ): Promise <IdentityFields > {
125+ this .isFetchingIdentity = true
110126 const { api } = Connector .getInstance ()
111127
112128 const optionIdentity = await api ?.query .identity ?.identityOf (address )
113129 const identity = optionIdentity ?.unwrapOrDefault ()
114130
115131 if (! identity ?.size ) {
132+ this .isFetchingIdentity = false
116133 return emptyObject <IdentityFields >()
117134 }
118135
@@ -124,6 +141,7 @@ export default class Identity extends mixins(InlineMixin) {
124141 }, {} as IdentityFields )
125142
126143 update (address , () => final , identityStore )
144+ this .isFetchingIdentity = false
127145
128146 if (this .emit ) {
129147 this .emitIdentityChange (final )
@@ -157,4 +175,8 @@ export default class Identity extends mixins(InlineMixin) {
157175.overflowWrap {
158176 overflow-wrap : break-word ;
159177}
178+
179+ .infinity-loader {
180+ height : 20px
181+ }
160182 </style >
0 commit comments