fix user search on local instance
This commit is contained in:
parent
8d5dea08ff
commit
946382dd73
|
@ -10,7 +10,7 @@ import { Notification, Account } from '../../../../services/models/mastodon.inte
|
|||
import { MastodonService } from '../../../../services/mastodon.service';
|
||||
import { NotificationService } from '../../../../services/notification.service';
|
||||
import { AccountInfo } from '../../../../states/accounts.state';
|
||||
import { OpenThreadEvent } from '../../../../services/tools.service';
|
||||
import { OpenThreadEvent, ToolsService } from '../../../../services/tools.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-notifications',
|
||||
|
@ -46,6 +46,7 @@ export class NotificationsComponent implements OnInit, OnDestroy {
|
|||
private lastId: string;
|
||||
|
||||
constructor(
|
||||
private readonly toolsService: ToolsService,
|
||||
private readonly notificationService: NotificationService,
|
||||
private readonly userNotificationService: UserNotificationService,
|
||||
private readonly mastodonService: MastodonService) { }
|
||||
|
@ -126,10 +127,7 @@ export class NotificationsComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
openAccount(account: Account): boolean {
|
||||
let accountName = account.acct;
|
||||
if (!accountName.includes('@'))
|
||||
accountName += `@${account.url.replace('https://', '').split('/')[0]}`;
|
||||
|
||||
let accountName = this.toolsService.getAccountFullHandle(account);
|
||||
this.browseAccountEvent.next(accountName);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<div *ngIf="accounts.length > 0" class="search-results">
|
||||
<h3 class="search-results__title">Accounts</h3>
|
||||
<a href *ngFor="let account of accounts" class="account" title="open account"
|
||||
(click)="browseAccount(account.acct)">
|
||||
(click)="browseAccount(account)">
|
||||
<img src="{{account.avatar}}" class="account__avatar" />
|
||||
<div class="account__name">{{ account.username }}</div>
|
||||
<div class="account__fullhandle">@{{ account.acct }}</div>
|
||||
|
|
|
@ -54,10 +54,9 @@ export class SearchComponent implements OnInit {
|
|||
return false;
|
||||
}
|
||||
|
||||
browseAccount(accountName: string): boolean {
|
||||
if (accountName) {
|
||||
this.browseAccountEvent.next(accountName);
|
||||
}
|
||||
browseAccount(account: Account): boolean {
|
||||
let accountName = this.toolsService.getAccountFullHandle(account);
|
||||
this.browseAccountEvent.next(accountName);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -88,5 +87,5 @@ export class SearchComponent implements OnInit {
|
|||
.then(() => { this.isLoading = false; });
|
||||
}
|
||||
|
||||
private
|
||||
private
|
||||
}
|
||||
|
|
|
@ -108,11 +108,9 @@ export class ActionBarComponent implements OnInit, OnDestroy {
|
|||
|
||||
private extractHandle(account: Account) {
|
||||
this.username = account.acct.split('@')[0];
|
||||
this.fullHandle = account.acct.toLowerCase();
|
||||
if (!this.fullHandle.includes('@')) {
|
||||
this.fullHandle += `@${account.url.replace('https://', '').split('/')[0]}`;
|
||||
}
|
||||
this.fullHandle = `@${this.fullHandle}`;
|
||||
|
||||
this.fullHandle = this.toolsService.getAccountFullHandle(account);
|
||||
// this.fullHandle = `@${this.fullHandle}`;
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
|
|
|
@ -84,7 +84,8 @@ export class StatusComponent implements OnInit {
|
|||
return this._statusWrapper;
|
||||
}
|
||||
|
||||
constructor() { }
|
||||
constructor(
|
||||
private readonly toolsService: ToolsService) { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
@ -137,10 +138,7 @@ export class StatusComponent implements OnInit {
|
|||
}
|
||||
|
||||
openAccount(account: Account): boolean {
|
||||
let accountName = account.acct;
|
||||
if (!accountName.includes('@'))
|
||||
accountName += `@${account.url.replace('https://', '').split('/')[0]}`;
|
||||
|
||||
let accountName = this.toolsService.getAccountFullHandle(account);
|
||||
this.browseAccountEvent.next(accountName);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import { AccountSettings, SaveAccountSettings } from '../states/settings.state';
|
|||
providedIn: 'root'
|
||||
})
|
||||
export class ToolsService {
|
||||
|
||||
constructor(
|
||||
private readonly mastodonService: MastodonService,
|
||||
private readonly store: Store) { }
|
||||
|
@ -50,8 +49,9 @@ export class ToolsService {
|
|||
|
||||
const foundAccount = result.accounts.find(
|
||||
x => (x.acct.toLowerCase() === accountName.toLowerCase()
|
||||
|| x.acct.toLowerCase().split('@')[0] === accountName.toLowerCase().split('@')[0])
|
||||
&& x.url.replace('https://', '').split('/')[0] === accountName.toLowerCase().split('@')[1]
|
||||
||
|
||||
(x.acct.toLowerCase().split('@')[0] === accountName.toLowerCase().split('@')[0])
|
||||
&& x.url.replace('https://', '').split('/')[0] === accountName.toLowerCase().split('@')[1])
|
||||
);
|
||||
return foundAccount;
|
||||
});
|
||||
|
@ -75,6 +75,13 @@ export class ToolsService {
|
|||
return statusPromise;
|
||||
}
|
||||
|
||||
getAccountFullHandle(account: Account): string {
|
||||
let fullHandle = account.acct.toLowerCase();
|
||||
if (!fullHandle.includes('@')) {
|
||||
fullHandle += `@${account.url.replace('https://', '').split('/')[0]}`;
|
||||
}
|
||||
return `@${fullHandle}`;
|
||||
}
|
||||
}
|
||||
|
||||
export class OpenThreadEvent {
|
||||
|
|
Loading…
Reference in New Issue