added menu to check bookmarks

This commit is contained in:
Nicolas Constant 2020-03-13 21:06:08 -04:00
parent fe9cb7fea1
commit 3a2761eeb1
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
2 changed files with 27 additions and 5 deletions

View File

@ -3,10 +3,15 @@
<div class="account__header">
<a href (click)="browseLocalAccount()" (auxclick)="openLocalAccount()" title="open {{ account.info.id }}">
<img class="account__avatar" src="{{account.avatar}}"/>
<img class="account__avatar" src="{{account.avatar}}" />
</a>
<!-- <a href class="account__header--button"><fa-icon [icon]="faUserPlus"></fa-icon></a> -->
<a *ngIf="isBookmarksAvailable" href class="account__header--button" title="bookmark" (click)="loadSubPanel('bookmarks')"
[ngClass]="{ 'account__header--button--selected': subPanel === 'bookmarks' }">
<fa-icon [icon]="faBookmark"></fa-icon>
</a>
<a href class="account__header--button" title="favorites" (click)="loadSubPanel('favorites')"
[ngClass]="{ 'account__header--button--selected': subPanel === 'favorites' }">
<fa-icon [icon]="faStar"></fa-icon>

View File

@ -1,11 +1,11 @@
import { Component, OnInit, OnDestroy, Input, Output, EventEmitter } from '@angular/core';
import { faAt, faUserPlus } from "@fortawesome/free-solid-svg-icons";
import { faBell, faEnvelope, faUser, faStar } from "@fortawesome/free-regular-svg-icons";
import { faBell, faEnvelope, faUser, faStar, faBookmark } from "@fortawesome/free-regular-svg-icons";
import { Subscription } from 'rxjs';
import { AccountWrapper } from '../../../models/account.models';
import { UserNotificationService, UserNotification } from '../../../services/user-notification.service';
import { OpenThreadEvent, ToolsService } from '../../../services/tools.service';
import { OpenThreadEvent, ToolsService, InstanceInfo } from '../../../services/tools.service';
import { MastodonWrapperService } from '../../../services/mastodon-wrapper.service';
import { Account } from "../../../services/models/mastodon.interfaces";
import { NotificationService } from '../../../services/notification.service';
@ -24,10 +24,12 @@ export class ManageAccountComponent implements OnInit, OnDestroy {
faUser = faUser;
faStar = faStar;
faUserPlus = faUserPlus;
faBookmark = faBookmark;
subPanel: 'account' | 'notifications' | 'mentions' | 'dm' | 'favorites' = 'account';
subPanel: 'account' | 'notifications' | 'mentions' | 'dm' | 'favorites' | 'bookmarks' = 'account';
hasNotifications = false;
hasMentions = false;
isBookmarksAvailable = false;
userAccount: Account;
@ -38,6 +40,7 @@ export class ManageAccountComponent implements OnInit, OnDestroy {
@Input('account')
set account(acc: AccountWrapper) {
this._account = acc;
this.checkIfBookmarksAreAvailable();
this.checkNotifications();
this.getUserUrl(acc.info);
}
@ -54,13 +57,27 @@ export class ManageAccountComponent implements OnInit, OnDestroy {
private readonly notificationService: NotificationService,
private readonly userNotificationService: UserNotificationService) { }
ngOnInit() {
ngOnInit() {
}
ngOnDestroy(): void {
this.userNotificationServiceSub.unsubscribe();
}
private checkIfBookmarksAreAvailable() {
this.toolsService.getInstanceInfo(this.account.info)
.then((instance: InstanceInfo) => {
if (instance.major >= 3 && instance.minor >= 1) {
this.isBookmarksAvailable = true;
} else {
this.isBookmarksAvailable = false;
}
})
.catch(err => {
this.isBookmarksAvailable = false;
});
}
private getUserUrl(account: AccountInfo) {
this.mastodonService.retrieveAccountDetails(this.account.info)
.then((acc: Account) => {