From 42ab3eada48caf7924f8d485ed55fe50e6bd7073 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Wed, 15 Mar 2023 22:20:54 +0000 Subject: [PATCH 1/5] Remove links from navs if we can't see the timeline --- src/boot/after_store.js | 2 ++ src/components/desktop_nav/desktop_nav.js | 6 +++++- src/components/desktop_nav/desktop_nav.vue | 2 ++ src/components/extra_buttons/extra_buttons.js | 3 ++- src/components/nav_panel/nav_panel.js | 2 +- src/components/timeline_menu/timeline_menu_content.js | 3 ++- src/components/timeline_menu/timeline_menu_content.vue | 5 +++-- 7 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/boot/after_store.js b/src/boot/after_store.js index 36b087a5..bba3e597 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -322,6 +322,8 @@ const getNodeInfo = async ({ store }) => { : federation.enabled }) + store.dispatch('setInstanceOption', { name: 'publicTimelineVisibility', value: metadata.publicTimelineVisibility }) + const accountActivationRequired = metadata.accountActivationRequired store.dispatch('setInstanceOption', { name: 'accountActivationRequired', value: accountActivationRequired }) diff --git a/src/components/desktop_nav/desktop_nav.js b/src/components/desktop_nav/desktop_nav.js index f4900c38..4cf5a477 100644 --- a/src/components/desktop_nav/desktop_nav.js +++ b/src/components/desktop_nav/desktop_nav.js @@ -19,6 +19,7 @@ import { faInfoCircle, faUserTie } from '@fortawesome/free-solid-svg-icons' +import { mapState } from 'vuex' library.add( faSignInAlt, @@ -103,7 +104,10 @@ export default { }, showBubbleTimeline () { return this.$store.state.instance.localBubbleInstances.length > 0 - } + }, + ...mapState({ + publicTimelineVisibility: state => state.instance.publicTimelineVisibility, + }) }, methods: { scrollToTop () { diff --git a/src/components/desktop_nav/desktop_nav.vue b/src/components/desktop_nav/desktop_nav.vue index 92d3fa5b..a41e9972 100644 --- a/src/components/desktop_nav/desktop_nav.vue +++ b/src/components/desktop_nav/desktop_nav.vue @@ -46,6 +46,7 @@ state.users.currentUser, privateMode: state => state.instance.private, - federating: state => state.instance.federating + federating: state => state.instance.federating, }), ...mapGetters(['unreadAnnouncementCount']), followRequestCount () { diff --git a/src/components/timeline_menu/timeline_menu_content.js b/src/components/timeline_menu/timeline_menu_content.js index df15030b..ab277d74 100644 --- a/src/components/timeline_menu/timeline_menu_content.js +++ b/src/components/timeline_menu/timeline_menu_content.js @@ -24,7 +24,8 @@ const TimelineMenuContent = { currentUser: state => state.users.currentUser, privateMode: state => state.instance.private, federating: state => state.instance.federating, - showBubbleTimeline: state => (state.instance.localBubbleInstances.length > 0) + showBubbleTimeline: state => (state.instance.localBubbleInstances.length > 0), + publicTimelineVisibility: state => state.instance.publicTimelineVisibility, }) } } diff --git a/src/components/timeline_menu/timeline_menu_content.vue b/src/components/timeline_menu/timeline_menu_content.vue index 27aece22..70af126c 100644 --- a/src/components/timeline_menu/timeline_menu_content.vue +++ b/src/components/timeline_menu/timeline_menu_content.vue @@ -32,7 +32,7 @@ >{{ $t("nav.bubble_timeline") }} -
  • +
  • {{ $t("nav.public_tl") }}
  • -
  • +
  • {{ $t("nav.twkn") }} +
  • From 9f7f9e27985c6a51e3473c682d0766eb830fc302 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Wed, 15 Mar 2023 23:00:31 +0000 Subject: [PATCH 2/5] Remove unused bits and bobs --- index.html | 2 -- src/boot/after_store.js | 3 --- src/modules/users.js | 3 ++- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index fda91b0f..781b0ba3 100644 --- a/index.html +++ b/index.html @@ -4,8 +4,6 @@ Akkoma - - diff --git a/src/boot/after_store.js b/src/boot/after_store.js index bba3e597..b48bfb09 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -398,9 +398,6 @@ const afterStoreSetup = async ({ store, i18n }) => { ]) // Start fetching things that don't need to block the UI - store.dispatch('fetchMutes') - store.dispatch('startFetchingAnnouncements') - store.dispatch('startFetchingReports') getTOS({ store }) getStickers({ store }) diff --git a/src/modules/users.js b/src/modules/users.js index bc1943c8..209d9675 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -637,13 +637,14 @@ const users = { // Get user mutes store.dispatch('fetchMutes') - store.dispatch('setLayoutWidth', windowWidth()) store.dispatch('setLayoutHeight', windowHeight()) store.dispatch('getSupportedTranslationlanguages') store.dispatch('getSettingsProfile') store.dispatch('listSettingsProfiles') store.dispatch('startFetchingConfig') + store.dispatch('startFetchingAnnouncements') + store.dispatch('startFetchingReports') // Fetch our friends store.rootState.api.backendInteractor.fetchFriends({ id: user.id }) From 7361f4e77e1a3f9c863d00f8341c34a47c45cb50 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Thu, 16 Mar 2023 16:41:37 +0000 Subject: [PATCH 3/5] Add checks for currentUser on sidebar --- src/components/timeline_menu/timeline_menu_content.vue | 4 ++-- src/components/timeline_menu_tabs/timeline_menu_tabs.js | 7 ++++++- src/components/timeline_menu_tabs/timeline_menu_tabs.vue | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/timeline_menu/timeline_menu_content.vue b/src/components/timeline_menu/timeline_menu_content.vue index 70af126c..0144f2fd 100644 --- a/src/components/timeline_menu/timeline_menu_content.vue +++ b/src/components/timeline_menu/timeline_menu_content.vue @@ -32,7 +32,7 @@ >{{ $t("nav.bubble_timeline") }}
  • -
  • +
  • {{ $t("nav.public_tl") }}
  • -
  • +
  • state.users.currentUser, + publicTimelineVisibility: state => state.instance.publicTimelineVisibility, + }) }, methods: { timelineName () { diff --git a/src/components/timeline_menu_tabs/timeline_menu_tabs.vue b/src/components/timeline_menu_tabs/timeline_menu_tabs.vue index f017fa1f..e922ffcc 100644 --- a/src/components/timeline_menu_tabs/timeline_menu_tabs.vue +++ b/src/components/timeline_menu_tabs/timeline_menu_tabs.vue @@ -18,6 +18,7 @@ Date: Sat, 18 Mar 2023 20:01:05 +0000 Subject: [PATCH 4/5] add timeline visibility setting parsing --- src/boot/after_store.js | 1 + src/components/desktop_nav/desktop_nav.js | 1 + src/components/desktop_nav/desktop_nav.vue | 4 ++-- src/components/timeline_menu/timeline_menu_content.js | 1 + src/components/timeline_menu/timeline_menu_content.vue | 4 ++-- src/components/timeline_menu_tabs/timeline_menu_content.js | 5 ++++- src/components/timeline_menu_tabs/timeline_menu_content.vue | 4 ++-- src/components/timeline_menu_tabs/timeline_menu_tabs.js | 2 ++ src/components/timeline_menu_tabs/timeline_menu_tabs.vue | 4 ++-- 9 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/boot/after_store.js b/src/boot/after_store.js index b48bfb09..d45584c0 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -323,6 +323,7 @@ const getNodeInfo = async ({ store }) => { }) store.dispatch('setInstanceOption', { name: 'publicTimelineVisibility', value: metadata.publicTimelineVisibility }) + store.dispatch('setInstanceOption', { name: 'federatedTimelineAvailable', value: metadata.federatedTimelineAvailable }) const accountActivationRequired = metadata.accountActivationRequired store.dispatch('setInstanceOption', { name: 'accountActivationRequired', value: accountActivationRequired }) diff --git a/src/components/desktop_nav/desktop_nav.js b/src/components/desktop_nav/desktop_nav.js index 4cf5a477..1978ce8f 100644 --- a/src/components/desktop_nav/desktop_nav.js +++ b/src/components/desktop_nav/desktop_nav.js @@ -107,6 +107,7 @@ export default { }, ...mapState({ publicTimelineVisibility: state => state.instance.publicTimelineVisibility, + federatedTimelineAvailable: state => state.instance.federatedTimelineAvailable, }) }, methods: { diff --git a/src/components/desktop_nav/desktop_nav.vue b/src/components/desktop_nav/desktop_nav.vue index a41e9972..61fd838c 100644 --- a/src/components/desktop_nav/desktop_nav.vue +++ b/src/components/desktop_nav/desktop_nav.vue @@ -56,7 +56,7 @@ /> @@ -70,7 +70,7 @@ state.instance.federating, showBubbleTimeline: state => (state.instance.localBubbleInstances.length > 0), publicTimelineVisibility: state => state.instance.publicTimelineVisibility, + federatedTimelineAvailable: state => state.instance.federatedTimelineAvailable, }) } } diff --git a/src/components/timeline_menu/timeline_menu_content.vue b/src/components/timeline_menu/timeline_menu_content.vue index 0144f2fd..8f636a0e 100644 --- a/src/components/timeline_menu/timeline_menu_content.vue +++ b/src/components/timeline_menu/timeline_menu_content.vue @@ -16,7 +16,7 @@ >{{ $t("nav.home_timeline") }}
  • -
  • +
  • {{ $t("nav.public_tl") }}
  • -
  • +
  • state.users.currentUser, privateMode: state => state.instance.private, - federating: state => state.instance.federating + federating: state => state.instance.federating, + showBubbleTimeline: state => (state.instance.localBubbleInstances.length > 0), + publicTimelineVisibility: state => state.instance.publicTimelineVisibility, + federatedTimelineAvailable: state => state.instance.federatedTimelineAvailable, }) } } diff --git a/src/components/timeline_menu_tabs/timeline_menu_content.vue b/src/components/timeline_menu_tabs/timeline_menu_content.vue index 32548c49..bb54595d 100644 --- a/src/components/timeline_menu_tabs/timeline_menu_content.vue +++ b/src/components/timeline_menu_tabs/timeline_menu_content.vue @@ -16,7 +16,7 @@ >{{ $t("nav.home_timeline") }}
  • -
  • +
  • {{ $t("nav.public_tl") }}
  • -
  • +
  • state.users.currentUser, publicTimelineVisibility: state => state.instance.publicTimelineVisibility, + federatedTimelineAvailable: state => state.instance.federatedTimelineAvailable, + showBubbleTimeline: state => (state.instance.localBubbleInstances.length > 0), }) }, methods: { diff --git a/src/components/timeline_menu_tabs/timeline_menu_tabs.vue b/src/components/timeline_menu_tabs/timeline_menu_tabs.vue index e922ffcc..1f0d47ee 100644 --- a/src/components/timeline_menu_tabs/timeline_menu_tabs.vue +++ b/src/components/timeline_menu_tabs/timeline_menu_tabs.vue @@ -28,7 +28,7 @@ /> @@ -42,7 +42,7 @@ Date: Sat, 18 Mar 2023 20:22:47 +0000 Subject: [PATCH 5/5] simplify timeline vibility checks --- src/components/desktop_nav/desktop_nav.js | 10 ++++++-- src/components/desktop_nav/desktop_nav.vue | 6 ++--- .../timeline_menu/timeline_menu_content.js | 7 +++--- .../timeline_menu/timeline_menu_content.vue | 6 ++--- .../timeline_menu_content.js | 7 +++--- .../timeline_menu_content.vue | 6 ++--- .../timeline_menu_tabs/timeline_menu_tabs.js | 14 ++++++----- .../timeline_menu_tabs/timeline_menu_tabs.vue | 6 ++--- src/lib/timeline_visibility.js | 23 +++++++++++++++++++ 9 files changed, 59 insertions(+), 26 deletions(-) create mode 100644 src/lib/timeline_visibility.js diff --git a/src/components/desktop_nav/desktop_nav.js b/src/components/desktop_nav/desktop_nav.js index 1978ce8f..d7538f5b 100644 --- a/src/components/desktop_nav/desktop_nav.js +++ b/src/components/desktop_nav/desktop_nav.js @@ -1,6 +1,11 @@ import SearchBar from 'components/search_bar/search_bar.vue' import ConfirmModal from '../confirm_modal/confirm_modal.vue' import { library } from '@fortawesome/fontawesome-svg-core' +import { + publicTimelineVisible, + federatedTimelineVisible, + bubbleTimelineVisible, +} from '../../lib/timeline_visibility' import { faSignInAlt, faSignOutAlt, @@ -106,8 +111,9 @@ export default { return this.$store.state.instance.localBubbleInstances.length > 0 }, ...mapState({ - publicTimelineVisibility: state => state.instance.publicTimelineVisibility, - federatedTimelineAvailable: state => state.instance.federatedTimelineAvailable, + publicTimelineVisible, + federatedTimelineVisible, + bubbleTimelineVisible, }) }, methods: { diff --git a/src/components/desktop_nav/desktop_nav.vue b/src/components/desktop_nav/desktop_nav.vue index 61fd838c..f50d1b3e 100644 --- a/src/components/desktop_nav/desktop_nav.vue +++ b/src/components/desktop_nav/desktop_nav.vue @@ -46,7 +46,7 @@ @@ -70,7 +70,7 @@ state.users.currentUser, privateMode: state => state.instance.private, federating: state => state.instance.federating, - showBubbleTimeline: state => (state.instance.localBubbleInstances.length > 0), - publicTimelineVisibility: state => state.instance.publicTimelineVisibility, - federatedTimelineAvailable: state => state.instance.federatedTimelineAvailable, + publicTimelineVisible, + federatedTimelineVisible, + bubbleTimelineVisible, }) } } diff --git a/src/components/timeline_menu/timeline_menu_content.vue b/src/components/timeline_menu/timeline_menu_content.vue index 8f636a0e..bb170b82 100644 --- a/src/components/timeline_menu/timeline_menu_content.vue +++ b/src/components/timeline_menu/timeline_menu_content.vue @@ -16,7 +16,7 @@ >{{ $t("nav.home_timeline") }}
  • -
  • +
  • {{ $t("nav.bubble_timeline") }}
  • -
  • +
  • {{ $t("nav.public_tl") }}
  • -
  • +
  • state.users.currentUser, privateMode: state => state.instance.private, federating: state => state.instance.federating, - showBubbleTimeline: state => (state.instance.localBubbleInstances.length > 0), - publicTimelineVisibility: state => state.instance.publicTimelineVisibility, - federatedTimelineAvailable: state => state.instance.federatedTimelineAvailable, + publicTimelineVisible, + federatedTimelineVisible, + bubbleTimelineVisible, }) } } diff --git a/src/components/timeline_menu_tabs/timeline_menu_content.vue b/src/components/timeline_menu_tabs/timeline_menu_content.vue index bb54595d..28e58714 100644 --- a/src/components/timeline_menu_tabs/timeline_menu_content.vue +++ b/src/components/timeline_menu_tabs/timeline_menu_content.vue @@ -16,7 +16,7 @@ >{{ $t("nav.home_timeline") }}
  • -
  • +
  • {{ $t("nav.bubble_timeline") }}
  • -
  • +
  • {{ $t("nav.public_tl") }}
  • -
  • +
  • state.users.currentUser, - publicTimelineVisibility: state => state.instance.publicTimelineVisibility, - federatedTimelineAvailable: state => state.instance.federatedTimelineAvailable, - showBubbleTimeline: state => (state.instance.localBubbleInstances.length > 0), + publicTimelineVisible, + federatedTimelineVisible, + bubbleTimelineVisible, }) }, methods: { diff --git a/src/components/timeline_menu_tabs/timeline_menu_tabs.vue b/src/components/timeline_menu_tabs/timeline_menu_tabs.vue index 1f0d47ee..96340508 100644 --- a/src/components/timeline_menu_tabs/timeline_menu_tabs.vue +++ b/src/components/timeline_menu_tabs/timeline_menu_tabs.vue @@ -18,7 +18,7 @@ @@ -42,7 +42,7 @@ ( + state.instance.publicTimelineVisibility[timeline] ?? false +); + +const currentUser = (state) => state.users.currentUser; + +const currentUserOrTimelineVisibleUnauthenticated = (state, timeline) => ( + currentUser(state) || timelineVisibleUnauthenticated(state, timeline) +); + +const federatedTimelineAvailable = (state) => state.instance.federatedTimelineAvailable; + +export const federatedTimelineVisible = (state) => ( + federatedTimelineAvailable(state) && currentUserOrTimelineVisibleUnauthenticated(state, 'federated') +); + +export const publicTimelineVisible = (state) => ( + currentUserOrTimelineVisibleUnauthenticated(state, 'local') +); + +export const bubbleTimelineVisible = (state) => ( + state.instance.localBubbleInstances.length > 0 && currentUserOrTimelineVisibleUnauthenticated(state, 'bubble') +);