Browse Source

Fix initing search by hashtag

master
morethanwords 3 years ago
parent
commit
d479c08bbd
  1. 7
      src/components/appSearch.ts
  2. 40
      src/components/sidebarRight/tabs/search.ts

7
src/components/appSearch.ts

@ -132,9 +132,14 @@ export default class AppSearch {
this.searchPromise = null; this.searchPromise = null;
} }
public beginSearch(peerId = 0, threadId = 0) { public beginSearch(peerId = 0, threadId = 0, query = '') {
this.peerId = peerId; this.peerId = peerId;
this.threadId = threadId; this.threadId = threadId;
if(this.query !== query) {
this.searchInput.inputField.value = query;
}
this.searchInput.input.focus(); this.searchInput.input.focus();
} }

40
src/components/sidebarRight/tabs/search.ts

@ -19,10 +19,11 @@ export default class AppPrivateSearchTab extends SliderSuperTab {
private peerId = 0; private peerId = 0;
private threadId = 0; private threadId = 0;
private query = '';
private onDatePick: (timestamp: number) => void; private onDatePick: (timestamp: number) => void;
onOpenAfterTimeout() { onOpenAfterTimeout() {
this.appSearch.beginSearch(this.peerId, this.threadId); this.appSearch.beginSearch(this.peerId, this.threadId, this.query);
} }
protected init() { protected init() {
@ -44,30 +45,27 @@ export default class AppPrivateSearchTab extends SliderSuperTab {
open(peerId: number, threadId?: number, onDatePick?: AppPrivateSearchTab['onDatePick'], query?: string) { open(peerId: number, threadId?: number, onDatePick?: AppPrivateSearchTab['onDatePick'], query?: string) {
const ret = super.open(); const ret = super.open();
if(this.init) {
this.init();
this.init = null;
}
query && (this.inputSearch.inputField.value = query);
if(this.peerId !== 0) {
this.appSearch.beginSearch(this.peerId, this.threadId);
return ret;
}
this.peerId = peerId; if(!this.peerId) {
this.threadId = threadId; this.query = query;
this.onDatePick = onDatePick; this.peerId = peerId;
this.threadId = threadId;
this.onDatePick = onDatePick;
this.btnPickDate.classList.toggle('hide', !this.onDatePick);
if(this.onDatePick) {
attachClickEvent(this.btnPickDate, () => {
new PopupDatePicker(new Date(), this.onDatePick).show();
});
}
this.btnPickDate.classList.toggle('hide', !this.onDatePick); query && this.appSearch.searchInput.inputField.setValueSilently(query);
if(this.onDatePick) {
attachClickEvent(this.btnPickDate, () => { appSidebarRight.toggleSidebar(true);
new PopupDatePicker(new Date(), this.onDatePick).show(); } else {
}); this.appSearch.beginSearch(this.peerId, this.threadId, query);
} }
appSidebarRight.toggleSidebar(true);
return ret; return ret;
} }
} }

Loading…
Cancel
Save