diff --git a/src/components/Feed/Feed.vue b/src/components/Feed/Feed.vue index f5ce751..61db869 100644 --- a/src/components/Feed/Feed.vue +++ b/src/components/Feed/Feed.vue @@ -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() diff --git a/src/pages/Feed.vue b/src/pages/Feed.vue index e04c88d..0fc69ca 100644 --- a/src/pages/Feed.vue +++ b/src/pages/Feed.vue @@ -10,8 +10,8 @@ size="sm" class="feed-selector" :options="[ - {value: 'global', icon: 'public'}, {value: 'following', icon: 'group'}, + {value: 'global', icon: 'public'}, ]" /> @@ -23,7 +23,7 @@ - + @@ -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() + } })