add status display in search

This commit is contained in:
Nicolas Constant 2018-11-03 00:57:39 -04:00
parent 12502a0319
commit 628cb94505
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
3 changed files with 27 additions and 7 deletions

View File

@ -19,14 +19,18 @@
</a>
</div>
<div *ngIf="statuses.length > 0" class="search-results">
<h3 class="search-results__title">Statuses</h3>
</div>
<div *ngIf="hashtags.length > 0" class="search-results">
<h3 class="search-results__title">Hashtags</h3>
<a (click)="addHashtag(hashtag)" href *ngFor="let hashtag of hashtags" class="search-results__hashtag" title="add hashtag column">
#{{ hashtag }}
</a>
</div>
<div *ngIf="statuses.length > 0" class="search-results">
<h3 class="search-results__title">Statuses</h3>
<div class="search-results__status" *ngFor="let statusWrapper of statuses">
<app-status [statusWrapper]="statusWrapper" (browseAccount)="browseAccount($event)" (browseHashtag)="browseHashtag($event)"></app-status>
</div>
</div>
</div>

View File

@ -59,6 +59,13 @@ $button-background-color-hover: lighten($color-primary, 20);
border-bottom: 1px solid $separator-color;
}
}
&__status {
border-top: 1px solid $separator-color;
&:last-of-type {
border-bottom: 1px solid $separator-color;
}
}
}
.account {

View File

@ -4,6 +4,8 @@ import { Store } from '@ngxs/store';
import { MastodonService } from '../../../services/mastodon.service';
import { AccountInfo } from '../../../states/accounts.state';
import { Results, Account, Status } from '../../../services/models/mastodon.interfaces';
import { ToolsService } from '../../../services/tools.service';
import { StatusWrapper } from '../../stream/stream.component';
@Component({
@ -15,13 +17,14 @@ export class SearchComponent implements OnInit {
@Input() searchHandle: string;
accounts: Account[] = [];
statuses: Status[] = [];
statuses: StatusWrapper[] = [];
hashtags: string[] = [];
isLoading: boolean;
constructor(
private readonly store: Store,
private readonly toolsService: ToolsService,
private readonly mastodonService: MastodonService) { }
ngOnInit() {
@ -46,8 +49,7 @@ export class SearchComponent implements OnInit {
console.warn(`search: ${data}`);
const enabledAccounts = this.getRegisteredAccounts().filter(x => x.isSelected);
const enabledAccounts = this.toolsService.getSelectedAccounts();
//First candid implementation
if (enabledAccounts.length > 0) {
const candid_oneAccount = enabledAccounts[0];
@ -57,6 +59,13 @@ export class SearchComponent implements OnInit {
console.warn(results);
this.accounts = results.accounts.slice(0, 5);
this.hashtags = results.hashtags;
for (let status of results.statuses) {
const statusWrapper = new StatusWrapper(status, candid_oneAccount);
this.statuses.push(statusWrapper);
}
}
})
.catch((err) => console.error(err))