added middle click event handling on left-bar

This commit is contained in:
Nicolas Constant 2019-07-11 19:55:46 -04:00
parent 03870964f4
commit eb84510404
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
2 changed files with 25 additions and 2 deletions

View File

@ -1,5 +1,5 @@
<a class="account-icon"
href title="{{ account.info.id }}" (click)="toogleAccount()" (contextmenu)="openMenu()">
href title="{{ account.info.id }}" (click)="toogleAccount()" (auxclick)="openLocalAccount($event)" (contextmenu)="openMenu()">
<span class="hasActivity" *ngIf="account.hasActivityNotifications">new</span>
<img class="account-icon__avatar" [class.account-icon__avatar--selected]="account.info.isSelected" src="{{ account.avatar }}" />
</a>

View File

@ -1,7 +1,10 @@
import { Component, OnInit, Input, EventEmitter, Output } from '@angular/core';
import { AccountWrapper } from '../../../models/account.models';
import { Account } from "../../../services/models/mastodon.interfaces";
import { AccountWithNotificationWrapper } from '../left-side-bar.component';
import { ToolsService } from '../../../services/tools.service';
import { NotificationService } from '../../../services/notification.service';
@Component({
selector: 'app-account-icon',
@ -13,9 +16,14 @@ export class AccountIconComponent implements OnInit {
@Output() toogleAccountNotify = new EventEmitter<AccountWrapper>();
@Output() openMenuNotify = new EventEmitter<AccountWrapper>();
constructor() { }
private promiseGetUser: Promise<Account>;
constructor(
private readonly notificationService: NotificationService,
private readonly mastodonTools: ToolsService) { }
ngOnInit() {
this.promiseGetUser = this.mastodonTools.findAccount(this.account.info, `@${this.account.info.username}@${this.account.info.instance}`);
}
toogleAccount(): boolean {
@ -27,4 +35,19 @@ export class AccountIconComponent implements OnInit {
this.openMenuNotify.emit(this.account);
return false;
}
openLocalAccount(e): boolean {
e.preventDefault();
if (e.which == 2) {
this.promiseGetUser
.then((account: Account) => {
window.open(account.url, '_blank');
})
.catch(err => {
this.notificationService.notifyHttpError(err);
});
return false;
}
}
}