Default to following feed when signed in

This commit is contained in:
styppo 2023-01-28 01:01:37 +00:00
parent ff2cc4d5d9
commit d82f0fdfdb
No known key found for this signature in database
GPG Key ID: 3AAA685C50724C28
2 changed files with 32 additions and 5 deletions

View File

@ -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()

View File

@ -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>