Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
akariv committed Oct 11, 2023
1 parent ee0a4ef commit 9497b6b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions projects/srm/src/app/homepage/homepage.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { SearchConfig } from '../search/search-config';
import { Router } from '@angular/router';
import { UntilDestroy } from '@ngneat/until-destroy';
import { timer } from 'rxjs';
import { LayoutService } from '../layout.service';

@UntilDestroy()
@Component({
Expand All @@ -22,7 +23,7 @@ export class HomepageComponent {
searching = false;
examples: Preset[];

constructor(private api: ApiService, private platform: PlatformService, private router: Router) {
constructor(private api: ApiService, private platform: PlatformService, private router: Router, private layout: LayoutService) {
this.searchConfig = new SearchConfig(this, this.router, this.api, this.platform);
this.searchConfig.autoFocus = false;
this.api.getExamples().subscribe((examples) => {
Expand All @@ -43,10 +44,14 @@ export class HomepageComponent {
}

startSearch(query: string) {
this.searching = true;
this.searchConfig.query_ = query;
this.searchConfig.queries.next(query);
this.searchConfig.focus();
if (this.layout.desktop) {
this.searching = true;
this.searchConfig.query_ = query;
this.searchConfig.queries.next(query);
this.searchConfig.focus();
} else {
this.router.navigate(['/q'], {queryParams: {q: query}});
}
}

keydown(event: KeyboardEvent) {
Expand Down

0 comments on commit 9497b6b

Please sign in to comment.