Feature/completeUsernameCopy (#1913)
* #1843 Copy icon added to account page to copy Username * #1843 Store an account name with the host forced and bind it to copy button * #1843 tslint correction * #1843 copy to clipboard replaced by ngx-clipboard
This commit is contained in:
parent
b6a1dd4d1b
commit
e379f813d4
3 changed files with 9 additions and 4 deletions
|
@ -7,8 +7,11 @@
|
|||
<div class="actor-info">
|
||||
<div class="actor-names">
|
||||
<div class="actor-display-name">{{ account.displayName }}</div>
|
||||
<div class="actor-name">{{ account.nameWithHost }}</div>
|
||||
|
||||
<div class="actor-name">{{ account.nameWithHost }}
|
||||
<button ngxClipboard [cbContent]="account.nameWithHostForced" type="button" class="btn btn-outline-secondary btn-sm">
|
||||
<span class="glyphicon glyphicon-copy"></span>
|
||||
</button>
|
||||
</div>
|
||||
<span *ngIf="user?.blocked" [ngbTooltip]="user.blockedReason" class="badge badge-danger" i18n>Banned</span>
|
||||
<span *ngIf="account.mutedByUser" class="badge badge-danger" i18n>Muted</span>
|
||||
<span *ngIf="account.mutedServerByUser" class="badge badge-danger" i18n>Muted by your instance</span>
|
||||
|
|
|
@ -5,6 +5,7 @@ export class Account extends Actor implements ServerAccount {
|
|||
displayName: string
|
||||
description: string
|
||||
nameWithHost: string
|
||||
nameWithHostForced: string
|
||||
mutedByUser: boolean
|
||||
mutedByInstance: boolean
|
||||
mutedServerByUser: boolean
|
||||
|
@ -19,6 +20,7 @@ export class Account extends Actor implements ServerAccount {
|
|||
this.description = hash.description
|
||||
this.userId = hash.userId
|
||||
this.nameWithHost = Actor.CREATE_BY_STRING(this.name, this.host)
|
||||
this.nameWithHostForced = Actor.CREATE_BY_STRING(this.name, this.host, true)
|
||||
|
||||
this.mutedByUser = false
|
||||
this.mutedByInstance = false
|
||||
|
|
|
@ -23,11 +23,11 @@ export abstract class Actor implements ActorServer {
|
|||
return window.location.origin + '/client/assets/images/default-avatar.png'
|
||||
}
|
||||
|
||||
static CREATE_BY_STRING (accountName: string, host: string) {
|
||||
static CREATE_BY_STRING (accountName: string, host: string, forceHostname = false) {
|
||||
const absoluteAPIUrl = getAbsoluteAPIUrl()
|
||||
const thisHost = new URL(absoluteAPIUrl).host
|
||||
|
||||
if (host.trim() === thisHost) return accountName
|
||||
if (host.trim() === thisHost && !forceHostname) return accountName
|
||||
|
||||
return accountName + '@' + host
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue