refactoring

This commit is contained in:
Nicolas Constant 2019-03-07 19:50:27 -05:00
parent 9803c06a23
commit 3a606d36f9
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
1 changed files with 21 additions and 22 deletions

View File

@ -47,11 +47,11 @@ export class SearchComponent implements OnInit {
return false;
}
browseThread(openThreadEvent: OpenThreadEvent): boolean{
if(openThreadEvent){
browseThread(openThreadEvent: OpenThreadEvent): boolean {
if (openThreadEvent) {
this.browseThreadEvent.next(openThreadEvent);
}
return false;
return false;
}
browseAccount(accountName: string): boolean {
@ -68,26 +68,25 @@ export class SearchComponent implements OnInit {
this.hashtags.length = 0;
this.isLoading = true;
const enabledAccounts = this.toolsService.getSelectedAccounts();
//First candid implementation
if (enabledAccounts.length > 0) {
this.lastAccountUsed = enabledAccounts[0];
this.mastodonService.search(this.lastAccountUsed, data, true)
.then((results: Results) => {
if (results) {
this.accounts = results.accounts.slice(0, 5);
this.hashtags = results.hashtags;
this.lastAccountUsed = this.toolsService.getSelectedAccounts()[0];
for (let status of results.statuses) {
const statusWrapper = new StatusWrapper(status, this.lastAccountUsed);
this.statuses.push(statusWrapper);
}
this.mastodonService.search(this.lastAccountUsed, data, true)
.then((results: Results) => {
if (results) {
this.accounts = results.accounts.slice(0, 5);
this.hashtags = results.hashtags;
for (let status of results.statuses) {
const statusWrapper = new StatusWrapper(status, this.lastAccountUsed);
this.statuses.push(statusWrapper);
}
})
.catch((err: HttpErrorResponse) => {
this.notificationService.notifyHttpError(err);
})
.then(() => { this.isLoading = false; });
}
}
})
.catch((err: HttpErrorResponse) => {
this.notificationService.notifyHttpError(err);
})
.then(() => { this.isLoading = false; });
}
private
}