added copy status link

This commit is contained in:
Nicolas Constant 2019-07-03 18:25:35 -04:00
parent 7bdcc6277f
commit a35c7e911d
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
2 changed files with 33 additions and 6 deletions

View File

@ -40,17 +40,17 @@
</ng-template>
<ng-template contextMenuItem divider="true"></ng-template>
<ng-template contextMenuItem (execute)="mentionAccount()">
Mention @account
Mention @{{ this.username }}
</ng-template>
<ng-template contextMenuItem (execute)="dmAccount()">
Direct message @account
Direct message @{{ this.username }}
</ng-template>
<ng-template contextMenuItem divider="true"></ng-template>
<ng-template contextMenuItem (execute)="muteAccount()">
Mute @account
Mute @{{ this.username }}
</ng-template>
<ng-template contextMenuItem (execute)="blockAccount()">
Block @account
Block @{{ this.username }}
</ng-template>
<!-- <ng-template contextMenuItem (execute)="showMessage('Hi, ' + $event.item.name)">
Mute @account

View File

@ -7,7 +7,7 @@ import { faWindowClose as faWindowCloseRegular } from "@fortawesome/free-regular
import { MastodonService } from '../../../../services/mastodon.service';
import { AccountInfo } from '../../../../states/accounts.state';
import { Status } from '../../../../services/models/mastodon.interfaces';
import { Status, Account } from '../../../../services/models/mastodon.interfaces';
import { ToolsService } from '../../../../services/tools.service';
import { NotificationService } from '../../../../services/notification.service';
import { StatusWrapper } from '../../../../models/common.model';
@ -68,6 +68,10 @@ export class ActionBarComponent implements OnInit, OnDestroy {
this.accounts$ = this.store.select(state => state.registeredaccounts.accounts);
}
username: string;
private fullHandle: string;
private displayedStatus: Status;
ngOnInit() {
const status = this.statusWrapper.status;
const account = this.statusWrapper.provider;
@ -75,9 +79,13 @@ export class ActionBarComponent implements OnInit, OnDestroy {
if (status.reblog) {
this.favoriteStatePerAccountId[account.id] = status.reblog.favourited;
this.bootedStatePerAccountId[account.id] = status.reblog.reblogged;
this.extractHandle(status.reblog.account);
this.displayedStatus = status.reblog;
} else {
this.favoriteStatePerAccountId[account.id] = status.favourited;
this.bootedStatePerAccountId[account.id] = status.reblogged;
this.extractHandle(status.account);
this.displayedStatus = status;
}
this.accountSub = this.accounts$.subscribe((accounts: AccountInfo[]) => {
@ -85,6 +93,14 @@ export class ActionBarComponent implements OnInit, OnDestroy {
});
}
private extractHandle(account: Account) {
this.username = account.acct.split('@')[0];
this.fullHandle = account.acct;
if (!this.fullHandle.includes('@')) {
this.fullHandle += `@${account.url.replace('https://', '').split('/')[0]}`;
}
}
ngOnDestroy(): void {
this.accountSub.unsubscribe();
}
@ -239,6 +255,17 @@ export class ActionBarComponent implements OnInit, OnDestroy {
}
copyStatusLink(): boolean {
let selBox = document.createElement('textarea');
selBox.style.position = 'fixed';
selBox.style.left = '0';
selBox.style.top = '0';
selBox.style.opacity = '0';
selBox.value = this.displayedStatus.url;
document.body.appendChild(selBox);
selBox.focus();
selBox.select();
document.execCommand('copy');
document.body.removeChild(selBox);
return false;
}
@ -254,7 +281,7 @@ export class ActionBarComponent implements OnInit, OnDestroy {
}
muteAccount(): boolean {
return false;
}