Skip to content

Commit

Permalink
✔ Search ~
Browse files Browse the repository at this point in the history
  • Loading branch information
bifeldy committed Nov 26, 2023
1 parent 86ef2f6 commit 57802c2
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,24 @@ <h5 matLine>
</mat-selection-list>
</div>
</div>
<div class="row" *ngIf="searchResult.rssResults.length > 0">
<div class="col-12">
<h2 class="pt-3 border-bottom-dotted">
<b class="text-bifeldy">RSS</b>
</h2>
</div>
<div class="col-12">
<mat-selection-list class="pt-0" [multiple]="false">
<mat-list-option (click)="openRssFeed(r)" *ngFor="let r of searchResult.rssResults | slice:0:5">
<img matListAvatar src="{{ r.fansub_.image_url }}" class="ms-3" style="border-radius: 0;" />
<h4 matLine>{{ r.title }}</h4>
<h5 matLine>
<span class="text-success">{{ r.created_at | date:'d-MM-y' }}</span>
</h5>
</mat-list-option>
</mat-selection-list>
</div>
</div>
<div class="row" *ngIf="searchResult.berkasResults.length > 0">
<div class="col-12">
<h2 class="pt-3 border-bottom-dotted">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { FansubService } from '../../../services/fansub.service';
import { BerkasService } from '../../../services/berkas.service';
import { UserService } from '../../../services/user.service';
import { LocalStorageService } from '../../../services/local-storage.service';
import { WinboxService } from '../../../services/winbox.service';

@Component({
selector: 'app-search-all',
Expand All @@ -25,6 +26,7 @@ export class SearchAllComponent implements OnInit, OnDestroy {
animeResults: [],
doramaResults: [],
fansubResults: [],
rssResults: [],
berkasResults: [],
penggunaResults: []
};
Expand All @@ -34,6 +36,7 @@ export class SearchAllComponent implements OnInit, OnDestroy {
subsAnime = null;
subsDorama = null;
subsFansub = null;
subsRss = null;
subsBerkas = null;
subsPengguna = null;
subsDialog = null;
Expand All @@ -45,6 +48,7 @@ export class SearchAllComponent implements OnInit, OnDestroy {
timedOut5 = null;
timedOut6 = null;
timedOut7 = null;
timedOut8 = null;

constructor(
private gs: GlobalService,
Expand All @@ -56,7 +60,8 @@ export class SearchAllComponent implements OnInit, OnDestroy {
private fansub: FansubService,
private berkas: BerkasService,
private user: UserService,
private ls: LocalStorageService
private ls: LocalStorageService,
private wb: WinboxService
) {
if (this.gs.isBrowser) {
//
Expand All @@ -65,7 +70,12 @@ export class SearchAllComponent implements OnInit, OnDestroy {

ngOnInit(): void {
if (this.gs.isBrowser) {
this.searchResult = this.ls.getItem(this.gs.localStorageKeys.SearchResults, true) || this.searchResult;
const lsObj = this.ls.getItem(this.gs.localStorageKeys.SearchResults, true);
if (lsObj) {
for (const [key, value] of Object.entries(lsObj)) {
this.searchResult[key] = value;
}
}
}
}

Expand All @@ -76,6 +86,7 @@ export class SearchAllComponent implements OnInit, OnDestroy {
this.subsAnime?.unsubscribe();
this.subsDorama?.unsubscribe();
this.subsFansub?.unsubscribe();
this.subsRss?.unsubscribe();
this.subsBerkas?.unsubscribe();
this.subsPengguna?.unsubscribe();
this.subsDialog?.unsubscribe();
Expand Down Expand Up @@ -107,6 +118,10 @@ export class SearchAllComponent implements OnInit, OnDestroy {
clearTimeout(this.timedOut7);
this.timedOut7 = null;
}
if (this.timedOut8) {
clearTimeout(this.timedOut8);
this.timedOut8 = null;
}
}

applyFilter(event): void {
Expand All @@ -117,6 +132,7 @@ export class SearchAllComponent implements OnInit, OnDestroy {
this.searchResult.animeResults = [];
this.searchResult.doramaResults = [];
this.searchResult.fansubResults = [];
this.searchResult.rssResults = [];
this.searchResult.berkasResults = [];
this.searchResult.penggunaResults = [];
if (this.searchResult.q) {
Expand All @@ -127,6 +143,7 @@ export class SearchAllComponent implements OnInit, OnDestroy {
this.timedOut5 = setTimeout(() => { this.getFansub(); }, 1250);
this.timedOut6 = setTimeout(() => { this.getBerkas(); }, 1500);
this.timedOut7 = setTimeout(() => { this.getPengguna(); }, 1750);
this.timedOut7 = setTimeout(() => { this.getRss(); }, 2000);
}
}

Expand Down Expand Up @@ -270,4 +287,24 @@ export class SearchAllComponent implements OnInit, OnDestroy {
});
}

getRss(): void {
if (this.subsRss) {
this.subsRss.unsubscribe();
}
this.subsRss = this.fansub.getRssFeedFansubAll(null, this.searchResult.q, 1, 5).subscribe({
next: res => {
this.gs.log('[RSS_SEARCH_SUCCESS]', res);
this.searchResult.rssResults = res.results;
},
error: err => {
this.gs.log('[RSS_SEARCH_ERROR]', err, 'error');
}
});
}

openRssFeed(data): void {
this.gs.log('[RSS_FEED_LIST_OPEN_URL]', data);
this.wb.winboxOpenUri(data.link);
}

}

0 comments on commit 57802c2

Please sign in to comment.