mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
chore: Update activeTab to show first results
Co-authored-by: Alina Beck <alina.beck@mail.com> Co-authored-by: Moriz Wahl <moriz.wahl@gmx.de> Co-authored-by: kachulio1 <jngugi88@gmail.com>
This commit is contained in:
parent
906f1bc0ca
commit
6d531c2cf8
@ -3,12 +3,12 @@
|
|||||||
<tab-navigation :tabs="tabOptions" :activeTab="activeTab" @switchTab="switchTab" />
|
<tab-navigation :tabs="tabOptions" :activeTab="activeTab" @switchTab="switchTab" />
|
||||||
<section>
|
<section>
|
||||||
<p v-if="!activeResources.length">No results found for "{{ search }}"</p>
|
<p v-if="!activeResources.length">No results found for "{{ search }}"</p>
|
||||||
<masonry-grid v-else-if="activeTab === 'posts'">
|
<masonry-grid v-else-if="activeTab === 'Post'">
|
||||||
<masonry-grid-item v-for="resource in activeResources" :key="resource.key">
|
<masonry-grid-item v-for="resource in activeResources" :key="resource.key">
|
||||||
<post-teaser :post="resource" />
|
<post-teaser :post="resource" />
|
||||||
</masonry-grid-item>
|
</masonry-grid-item>
|
||||||
</masonry-grid>
|
</masonry-grid>
|
||||||
<ul v-else-if="activeTab === 'users'">
|
<ul v-else-if="activeTab === 'User'">
|
||||||
<li v-for="resource in activeResources" :key="resource.key" class="list">
|
<li v-for="resource in activeResources" :key="resource.key" class="list">
|
||||||
<base-card :wideContent="true">
|
<base-card :wideContent="true">
|
||||||
<user-teaser :user="resource" />
|
<user-teaser :user="resource" />
|
||||||
@ -41,26 +41,21 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
searchResults: [],
|
posts: [],
|
||||||
activeTab: 'posts',
|
users: [],
|
||||||
|
activeTab: 'Post',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
posts() {
|
|
||||||
return this.searchResults.filter(result => result.__typename === 'Post')
|
|
||||||
},
|
|
||||||
users() {
|
|
||||||
return this.searchResults.filter(result => result.__typename === 'User')
|
|
||||||
},
|
|
||||||
activeResources() {
|
activeResources() {
|
||||||
if (this.activeTab === 'posts') return this.posts
|
if (this.activeTab === 'Post') return this.posts
|
||||||
else if (this.activeTab === 'users') return this.users
|
else if (this.activeTab === 'User') return this.users
|
||||||
else return []
|
else return []
|
||||||
},
|
},
|
||||||
tabOptions() {
|
tabOptions() {
|
||||||
return [
|
return [
|
||||||
{ type: 'posts', title: `${this.posts.length} Posts` },
|
{ type: 'Post', title: `${this.posts.length} Posts` },
|
||||||
{ type: 'users', title: `${this.users.length} Users` },
|
{ type: 'User', title: `${this.users.length} Users` },
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -83,6 +78,11 @@ export default {
|
|||||||
skip() {
|
skip() {
|
||||||
return !this.search
|
return !this.search
|
||||||
},
|
},
|
||||||
|
update({ searchResults }) {
|
||||||
|
this.posts = searchResults.filter(result => result.__typename === 'Post')
|
||||||
|
this.users = searchResults.filter(result => result.__typename === 'User')
|
||||||
|
if (searchResults.length) this.activeTab = searchResults[0].__typename
|
||||||
|
},
|
||||||
fetchPolicy: 'cache-and-network',
|
fetchPolicy: 'cache-and-network',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user