From eb84510404513b8d3aed314a5f5dffbf6c2a9fdf Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Thu, 11 Jul 2019 19:55:46 -0400 Subject: [PATCH] added middle click event handling on left-bar --- .../account-icon/account-icon.component.html | 2 +- .../account-icon/account-icon.component.ts | 25 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/app/components/left-side-bar/account-icon/account-icon.component.html b/src/app/components/left-side-bar/account-icon/account-icon.component.html index 59d36ad6..b0f78ef5 100644 --- a/src/app/components/left-side-bar/account-icon/account-icon.component.html +++ b/src/app/components/left-side-bar/account-icon/account-icon.component.html @@ -1,5 +1,5 @@ + href title="{{ account.info.id }}" (click)="toogleAccount()" (auxclick)="openLocalAccount($event)" (contextmenu)="openMenu()"> new diff --git a/src/app/components/left-side-bar/account-icon/account-icon.component.ts b/src/app/components/left-side-bar/account-icon/account-icon.component.ts index 2346d91f..021dba55 100644 --- a/src/app/components/left-side-bar/account-icon/account-icon.component.ts +++ b/src/app/components/left-side-bar/account-icon/account-icon.component.ts @@ -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(); @Output() openMenuNotify = new EventEmitter(); - constructor() { } + private promiseGetUser: Promise; + + 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; + } + } }