mirror of
https://github.com/styppo/hamstr.git
synced 2024-10-18 05:23:28 +00:00
Default to following feed when signed in
This commit is contained in:
parent
ff2cc4d5d9
commit
d82f0fdfdb
@ -35,6 +35,7 @@ const MAX_ITEMS_VISIBLE = 25
|
||||
|
||||
export default {
|
||||
name: 'Feed',
|
||||
emits: ['load'],
|
||||
components: {
|
||||
ListPlaceholder,
|
||||
Thread,
|
||||
@ -94,6 +95,8 @@ export default {
|
||||
this.visible = items.slice(0, MAX_ITEMS_VISIBLE)
|
||||
this.loading = false
|
||||
|
||||
this.$emit('load', this.feed)
|
||||
|
||||
// Wait a bit before showing the first unreads
|
||||
setTimeout(() => this.recentlyLoaded = false, 5000)
|
||||
})
|
||||
@ -163,7 +166,7 @@ export default {
|
||||
if (note.isRepostOrTag()) return false
|
||||
if (hideBots && note.relatedPubkeys().some(Bots.isBot)) return false
|
||||
return true
|
||||
}
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.init()
|
||||
|
@ -10,8 +10,8 @@
|
||||
size="sm"
|
||||
class="feed-selector"
|
||||
:options="[
|
||||
{value: 'global', icon: 'public'},
|
||||
{value: 'following', icon: 'group'},
|
||||
{value: 'global', icon: 'public'},
|
||||
]"
|
||||
/>
|
||||
</template>
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
<q-tab-panels v-model="activeFeed" keep-alive animated>
|
||||
<q-tab-panel v-for="feed in availableFeeds" :key="feed" :name="feed">
|
||||
<Feed :feed="feedDef(feed)" :ref="feed" />
|
||||
<Feed :feed="feedDef(feed)" :ref="feed" @load="onFeedLoaded" />
|
||||
</q-tab-panel>
|
||||
</q-tab-panels>
|
||||
</q-page>
|
||||
@ -98,13 +98,15 @@ export default defineComponent({
|
||||
data() {
|
||||
return {
|
||||
feeds: {},
|
||||
activeFeed: 'global',
|
||||
activeFeed: this.app.isSignedIn ? 'following' : 'global',
|
||||
initialized: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
availableFeeds() {
|
||||
const feeds = ['global']
|
||||
const feeds = []
|
||||
if (this.app.isSignedIn) feeds.push('following')
|
||||
feeds.push('global')
|
||||
return feeds
|
||||
},
|
||||
contacts() {
|
||||
@ -116,12 +118,34 @@ export default defineComponent({
|
||||
feedDef(feed) {
|
||||
return Feeds[feed]
|
||||
},
|
||||
initFeed() {
|
||||
if (this.initialized) return
|
||||
if (!this.contacts) return
|
||||
this.initialized = true
|
||||
this.activeFeed = this.contacts?.length
|
||||
? 'following'
|
||||
: 'global'
|
||||
},
|
||||
onFeedLoaded(feed) {
|
||||
if (this.activeFeed === 'following'
|
||||
&& feed?.name === this.activeFeed
|
||||
&& !this.contacts?.length
|
||||
&& !this.initialized
|
||||
) {
|
||||
this.activeFeed = 'global'
|
||||
this.initialized = true
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
contacts() {
|
||||
this.initFeed()
|
||||
this.$refs.following?.[0]?.reload()
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.initFeed()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user