diff --git a/src/components/search/search.js b/src/components/search/search.js index b62bc2c5..6347febf 100644 --- a/src/components/search/search.js +++ b/src/components/search/search.js @@ -30,7 +30,11 @@ const Search = { userIds: [], statuses: [], hashtags: [], - currenResultTab: 'statuses' + currenResultTab: 'statuses', + + statusesOffset: 0, + lastStatusFetchCount: 0, + lastQuery: '' } }, computed: { @@ -67,18 +71,26 @@ const Search = { this.loading = true this.userIds = [] - this.statuses = [] this.hashtags = [] this.$refs.searchInput.blur() + if (this.lastQuery !== query) { + this.statuses = [] + this.statusesOffset = 0 + this.lastStatusFetchCount = 0 + } - this.$store.dispatch('search', { q: query, resolve: true }) + this.$store.dispatch('search', { q: query, resolve: true, offset: this.statusesOffset }) .then(data => { this.loading = false this.userIds = map(data.accounts, 'id') - this.statuses = data.statuses + this.statuses = this.statuses.concat(data.statuses) this.hashtags = data.hashtags this.currenResultTab = this.getActiveTab() this.loaded = true + + this.statusesOffset += data.statuses.length + this.lastStatusFetchCount = data.statuses.length + this.lastQuery = query }) }, resultCount (tabName) { diff --git a/src/components/search/search.vue b/src/components/search/search.vue index b7bfc1f3..5d8a6715 100644 --- a/src/components/search/search.vue +++ b/src/components/search/search.vue @@ -55,12 +55,6 @@
-
-

{{ $t('search.no_results') }}

-
+ +
+ +
+
+

+ {{ $t('search.no_results') }} +

+
diff --git a/src/i18n/en.json b/src/i18n/en.json index b31e4880..6026b33e 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -827,7 +827,8 @@ "hashtags": "Hashtags", "person_talking": "{count} person talking", "people_talking": "{count} people talking", - "no_results": "No results" + "no_results": "No results", + "load_more": "Load more results" }, "password_reset": { "forgot_password": "Forgot password?",