From 9e069d9803298c392c11f0191e162054fdd59aa8 Mon Sep 17 00:00:00 2001 From: Julian Gonggrijp Date: Tue, 9 Nov 2021 19:29:33 +0100 Subject: [PATCH] Move route announcement from SearchResultsListView to -Panel This was misfactored in 9f791cd3. #163 #449 #501 --- .../search-result-list-panel.ts | 12 ++++++++++++ .../panel-search-results/search-result-list-view.ts | 13 ------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/frontend/src/panel-search-results/search-result-list-panel.ts b/frontend/src/panel-search-results/search-result-list-panel.ts index 991f5816..4d82adab 100644 --- a/frontend/src/panel-search-results/search-result-list-panel.ts +++ b/frontend/src/panel-search-results/search-result-list-panel.ts @@ -3,11 +3,22 @@ import { extend, get } from 'lodash'; import { CompositeView, ViewOptions as BaseOpt } from '../core/view'; import FlatItem from '../common-adapters/flat-item-model'; import explorerChannel from '../explorer/explorer-radio'; +import { announceRoute } from '../explorer/utilities'; +import SemanticQuery from '../semantic-search/model'; import LoadingSpinner from '../loading-spinner/loading-spinner-view'; import searchResultListTemplate from './search-result-list-template'; import SearchResultListView from './search-result-list-view'; +const announceAnno = announceRoute('item:annotations', ['model', 'id']); +const announceQuery = announceRoute('search:results:semantic', ['model', 'id']); + +function announce(): void { + if (this.model instanceof SemanticQuery) { + this.model.when('id', announceQuery, this); + } else announceAnno.call(this); +} + export interface ViewOptions extends BaseOpt { selectable: boolean; /** @@ -36,6 +47,7 @@ export default class SearchResultListPanel extends CompositeView { promise.then(this.removeSpinner.bind(this)); } this.render(); + this.on('announceRoute', announce); return this; } diff --git a/frontend/src/panel-search-results/search-result-list-view.ts b/frontend/src/panel-search-results/search-result-list-view.ts index d4210861..02becc94 100644 --- a/frontend/src/panel-search-results/search-result-list-view.ts +++ b/frontend/src/panel-search-results/search-result-list-view.ts @@ -3,20 +3,8 @@ import { extend, invokeMap } from 'lodash'; import { CollectionView, ViewOptions as BaseOpt } from '../core/view'; import FlatItem from '../common-adapters/flat-item-model'; -import { announceRoute } from '../explorer/utilities'; -import SemanticQuery from '../semantic-search/model'; - import SearchResultView from './search-result-base-view'; -const announceAnno = announceRoute('item:annotations', ['model', 'id']); -const announceQuery = announceRoute('search:results:semantic', ['model', 'id']); - -function announce(): void { - if (this.model instanceof SemanticQuery) { - this.model.when('id', announceQuery, this); - } else announceAnno.call(this); -} - export interface ViewOptions extends BaseOpt { selectable: boolean; } @@ -38,7 +26,6 @@ class SearchResultListView extends CollectionView { blur: this.onBlur, }); this.listenToOnce(this.collection, 'add', this.render); - this.on('announceRoute', announce); return this; }