diff --git a/app/assets/javascripts/app/controllers/search.coffee b/app/assets/javascripts/app/controllers/search.coffee index 4e23027d6..4908bad2e 100644 --- a/app/assets/javascripts/app/controllers/search.coffee +++ b/app/assets/javascripts/app/controllers/search.coffee @@ -122,6 +122,7 @@ class App.Search extends App.Controller App.GlobalSearch.execute( query: @query render: @renderResult + limit: 50 ) renderResult: (result = []) => diff --git a/app/assets/javascripts/app/lib/app_post/global_search.coffee b/app/assets/javascripts/app/lib/app_post/global_search.coffee index 5dcfc1efa..fdbf37301 100644 --- a/app/assets/javascripts/app/lib/app_post/global_search.coffee +++ b/app/assets/javascripts/app/lib/app_post/global_search.coffee @@ -15,12 +15,13 @@ class _globalSearchSingleton extends Spine.Module execute: (params) -> query = params.query render = params.render + limit = params.limit || 10 # use cache for search result if @searchResultCache[query] render(@searchResultCache[query].result) currentTime = new Date - return if @searchResultCache[query].time > currentTime.setSeconds(currentTime.getSeconds() - 20) + return if @searchResultCache[query].limit is limit && @searchResultCache[query].time > currentTime.setSeconds(currentTime.getSeconds() - 20) App.Ajax.request( id: 'search' @@ -28,6 +29,7 @@ class _globalSearchSingleton extends Spine.Module url: "#{@apiPath}/search" data: query: query + limit: limit processData: true, success: (data, status, xhr) => App.Collection.loadAssets(data.assets) @@ -53,6 +55,7 @@ class _globalSearchSingleton extends Spine.Module @searchResultCache[query] = result: result resultRaw: data.result + limit: limit time: new Date # if result hasn't changed, do not rerender