From 3a16a59f37b9b637bb4cbc1c3575810a65515cbc Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Thu, 11 Aug 2022 21:56:30 +0300 Subject: navigation refactored, used in mobile nav as well --- src/components/navigation/navigation.js | 61 +++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/components/navigation/navigation.js (limited to 'src/components/navigation/navigation.js') diff --git a/src/components/navigation/navigation.js b/src/components/navigation/navigation.js new file mode 100644 index 00000000..f37d37fe --- /dev/null +++ b/src/components/navigation/navigation.js @@ -0,0 +1,61 @@ +export const TIMELINES = { + home: { + route: 'friends', + anonRoute: 'public-timeline', + icon: 'home', + label: 'nav.home_timeline', + criteria: ['!private'] + }, + public: { + route: 'public-timeline', + anon: true, + icon: 'users', + label: 'nav.public_tl', + criteria: ['!private'] + }, + twkn: { + route: 'public-external-timeline', + anon: true, + icon: 'globe', + label: 'nav.twkn', + criteria: ['!private', 'federating'] + }, + bookmarks: { + route: 'bookmarks', + icon: 'bookmark', + label: 'nav.bookmarks' + }, + dms: { + route: 'dms', + icon: 'envelope', + label: 'nav.dms' + } +} + +export const ROOT_ITEMS = { + interactions: { + route: 'interactions', + icon: 'bell', + label: 'nav.interactions' + }, + chats: { + route: 'chats', + icon: 'comments', + label: 'nav.chats', + badgeGetter: 'unreadChatCount', + criteria: ['chats'] + }, + friendRequests: { + route: 'friend-requests', + icon: 'user-plus', + label: 'nav.friend_requests', + criteria: ['lockedUser'], + badgeGetter: 'followRequestCount' + }, + about: { + route: 'about', + anon: true, + icon: 'info-circle', + label: 'nav.about' + } +} -- cgit v1.2.3-70-g09d2 From 0123872b56ccd2d534913706ae0f27ea8d6481de Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Fri, 12 Aug 2022 00:50:08 +0300 Subject: fixes + fixes for anon users --- src/components/mobile_nav/mobile_nav.vue | 2 +- src/components/nav_panel/nav_panel.js | 13 +++++++++++++ src/components/nav_panel/nav_panel.vue | 2 +- src/components/navigation/navigation.js | 1 - src/components/navigation/navigation_entry.vue | 2 +- src/components/navigation/navigation_pins.js | 7 +++++++ src/components/navigation/navigation_pins.vue | 1 + test/unit/specs/modules/serverSideStorage.spec.js | 4 ++-- 8 files changed, 26 insertions(+), 6 deletions(-) (limited to 'src/components/navigation/navigation.js') diff --git a/src/components/mobile_nav/mobile_nav.vue b/src/components/mobile_nav/mobile_nav.vue index 82e726a4..01a77589 100644 --- a/src/components/mobile_nav/mobile_nav.vue +++ b/src/components/mobile_nav/mobile_nav.vue @@ -86,6 +86,7 @@ grid-template-columns: 2fr auto; width: 100%; box-sizing: border-box; + a { color: var(--topBarLink, $fallback--link); } @@ -175,7 +176,6 @@ .pinned-item { flex-grow: 1; - text-align: center; } } diff --git a/src/components/nav_panel/nav_panel.js b/src/components/nav_panel/nav_panel.js index 7daa5e6a..b4e1ec0b 100644 --- a/src/components/nav_panel/nav_panel.js +++ b/src/components/nav_panel/nav_panel.js @@ -86,6 +86,19 @@ const NavPanel = { pinnedItems: state => new Set(state.serverSideStorage.prefsStorage.collections.pinnedNavItems), collapsed: state => state.serverSideStorage.prefsStorage.simple.collapseNav }), + timelinesItems () { + return filterNavigation( + Object + .entries({ ...TIMELINES }) + .map(([k, v]) => ({ ...v, name: k })), + { + hasChats: this.pleromaChatMessagesAvailable, + isFederating: this.federating, + isPrivate: this.private, + currentUser: this.currentUser + } + ) + }, rootItems () { return filterNavigation( Object diff --git a/src/components/nav_panel/nav_panel.vue b/src/components/nav_panel/nav_panel.vue index 6e89094a..84b000a4 100644 --- a/src/components/nav_panel/nav_panel.vue +++ b/src/components/nav_panel/nav_panel.vue @@ -37,7 +37,7 @@ class="timelines-background" > diff --git a/src/components/navigation/navigation.js b/src/components/navigation/navigation.js index f37d37fe..57db2253 100644 --- a/src/components/navigation/navigation.js +++ b/src/components/navigation/navigation.js @@ -1,7 +1,6 @@ export const TIMELINES = { home: { route: 'friends', - anonRoute: 'public-timeline', icon: 'home', label: 'nav.home_timeline', criteria: ['!private'] diff --git a/src/components/navigation/navigation_entry.vue b/src/components/navigation/navigation_entry.vue index 7d761395..0dcf5d85 100644 --- a/src/components/navigation/navigation_entry.vue +++ b/src/components/navigation/navigation_entry.vue @@ -21,7 +21,7 @@ @click.stop.prevent="togglePin(item.name)" > new Set(state.serverSideStorage.prefsStorage.collections.pinnedNavItems) }), pinnedList () { + if (!this.currentUser) { + return [ + { ...TIMELINES.public, name: 'public' }, + { ...TIMELINES.twkn, name: 'twkn' }, + { ...ROOT_ITEMS.about, name: 'about' } + ] + } return filterNavigation( [ ...Object diff --git a/src/components/navigation/navigation_pins.vue b/src/components/navigation/navigation_pins.vue index 754aad7a..f421b2be 100644 --- a/src/components/navigation/navigation_pins.vue +++ b/src/components/navigation/navigation_pins.vue @@ -46,6 +46,7 @@ position: relative; flex: 0 0 3em; min-width: 2em; + text-align: center; & .svg-inline--fa, & .iconLetter { diff --git a/test/unit/specs/modules/serverSideStorage.spec.js b/test/unit/specs/modules/serverSideStorage.spec.js index ada3b7ca..edb23e8a 100644 --- a/test/unit/specs/modules/serverSideStorage.spec.js +++ b/test/unit/specs/modules/serverSideStorage.spec.js @@ -116,7 +116,7 @@ describe('The serverSideStorage module', () => { expect(state.prefsStorage._journal.length).to.eql(1) expect(state.prefsStorage._journal[0]).to.eql({ path: 'simple.testing', - command: 'set', + operation: 'set', args: [1], // should have A timestamp, we don't really care what it is timestamp: state.prefsStorage._journal[0].timestamp @@ -132,7 +132,7 @@ describe('The serverSideStorage module', () => { expect(state.prefsStorage._journal.length).to.eql(1) expect(state.prefsStorage._journal[0]).to.eql({ path: 'simple.testing', - command: 'set', + operation: 'set', args: [2], // should have A timestamp, we don't really care what it is timestamp: state.prefsStorage._journal[0].timestamp -- cgit v1.2.3-70-g09d2 From 666015c9fa2aaafbb602c449a1a2f7529f9bfb1b Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 23 Aug 2022 22:10:21 +0300 Subject: fix mobile side drawer causing issues --- src/components/navigation/navigation.js | 9 +++++++++ src/components/navigation/navigation_entry.js | 10 +--------- src/components/navigation/navigation_pins.js | 11 +---------- src/components/side_drawer/side_drawer.js | 11 +++++++++-- src/components/side_drawer/side_drawer.vue | 2 +- 5 files changed, 21 insertions(+), 22 deletions(-) (limited to 'src/components/navigation/navigation.js') diff --git a/src/components/navigation/navigation.js b/src/components/navigation/navigation.js index 57db2253..b4bcb05f 100644 --- a/src/components/navigation/navigation.js +++ b/src/components/navigation/navigation.js @@ -1,3 +1,12 @@ +export const USERNAME_ROUTES = new Set([ + 'bookmarks', + 'dms', + 'interactions', + 'notifications', + 'chat', + 'chats' +]) + export const TIMELINES = { home: { route: 'friends', diff --git a/src/components/navigation/navigation_entry.js b/src/components/navigation/navigation_entry.js index a19ee1b4..d8866c12 100644 --- a/src/components/navigation/navigation_entry.js +++ b/src/components/navigation/navigation_entry.js @@ -1,18 +1,10 @@ import { mapState } from 'vuex' +import { USERNAME_ROUTES } from 'src/components/navigation/navigation.js' import { library } from '@fortawesome/fontawesome-svg-core' import { faThumbtack } from '@fortawesome/free-solid-svg-icons' library.add(faThumbtack) -const USERNAME_ROUTES = new Set([ - 'bookmarks', - 'dms', - 'interactions', - 'notifications', - 'chat', - 'chats' -]) - const NavigationEntry = { props: ['item', 'showPin'], methods: { diff --git a/src/components/navigation/navigation_pins.js b/src/components/navigation/navigation_pins.js index f0295c70..57b8d589 100644 --- a/src/components/navigation/navigation_pins.js +++ b/src/components/navigation/navigation_pins.js @@ -1,5 +1,5 @@ import { mapState } from 'vuex' -import { TIMELINES, ROOT_ITEMS } from 'src/components/navigation/navigation.js' +import { TIMELINES, ROOT_ITEMS, USERNAME_ROUTES } from 'src/components/navigation/navigation.js' import { getListEntries, filterNavigation } from 'src/components/navigation/filter.js' import { library } from '@fortawesome/fontawesome-svg-core' @@ -27,15 +27,6 @@ library.add( faList ) -const USERNAME_ROUTES = new Set([ - 'bookmarks', - 'dms', - 'interactions', - 'notifications', - 'chat', - 'chats' -]) - const NavPanel = { props: ['limit'], methods: { diff --git a/src/components/side_drawer/side_drawer.js b/src/components/side_drawer/side_drawer.js index cbfd6b7d..d5dabb72 100644 --- a/src/components/side_drawer/side_drawer.js +++ b/src/components/side_drawer/side_drawer.js @@ -2,6 +2,7 @@ import { mapState, mapGetters } from 'vuex' import UserCard from '../user_card/user_card.vue' import { unseenNotificationsFromStore } from '../../services/notification_utils/notification_utils' import GestureService from '../../services/gesture_service/gesture_service' +import { USERNAME_ROUTES } from 'src/components/navigation/navigation.js' import { library } from '@fortawesome/fontawesome-svg-core' import { faSignInAlt, @@ -82,10 +83,16 @@ const SideDrawer = { return this.$store.state.instance.federating }, timelinesRoute () { + let name if (this.$store.state.interface.lastTimeline) { - return this.$store.state.interface.lastTimeline + name = this.$store.state.interface.lastTimeline + } + name = this.currentUser ? 'friends' : 'public-timeline' + if (USERNAME_ROUTES.has(name)) { + return { name, params: { username: this.currentUser.screen_name }} + } else { + return { name } } - return this.currentUser ? 'friends' : 'public-timeline' }, ...mapState({ pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable diff --git a/src/components/side_drawer/side_drawer.vue b/src/components/side_drawer/side_drawer.vue index 5223fdfa..cbeafdd2 100644 --- a/src/components/side_drawer/side_drawer.vue +++ b/src/components/side_drawer/side_drawer.vue @@ -47,7 +47,7 @@ v-if="currentUser || !privateMode" @click="toggleDrawer" > - + Date: Tue, 30 Aug 2022 00:53:20 +0300 Subject: add a favorites "timeline" shortcut --- src/components/navigation/navigation.js | 8 +++++++- src/components/navigation/navigation_entry.js | 8 +++++--- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src/components/navigation/navigation.js') diff --git a/src/components/navigation/navigation.js b/src/components/navigation/navigation.js index b4bcb05f..f66dd981 100644 --- a/src/components/navigation/navigation.js +++ b/src/components/navigation/navigation.js @@ -4,7 +4,8 @@ export const USERNAME_ROUTES = new Set([ 'interactions', 'notifications', 'chat', - 'chats' + 'chats', + 'user-profile' ]) export const TIMELINES = { @@ -33,6 +34,11 @@ export const TIMELINES = { icon: 'bookmark', label: 'nav.bookmarks' }, + favorites: { + routeObject: { name: 'user-profile', query: { tab: 'favorites' } }, + icon: 'star', + label: 'user_card.favorites' + }, dms: { route: 'dms', icon: 'envelope', diff --git a/src/components/navigation/navigation_entry.js b/src/components/navigation/navigation_entry.js index eb0a9cc4..fe3402fc 100644 --- a/src/components/navigation/navigation_entry.js +++ b/src/components/navigation/navigation_entry.js @@ -23,12 +23,14 @@ const NavigationEntry = { computed: { routeTo () { if (!this.item.route && !this.item.routeObject) return null + let route if (this.item.routeObject) { - return this.item.routeObject + route = this.item.routeObject + } else { + route = { name: (this.item.anon || this.currentUser) ? this.item.route : this.item.anonRoute } } - const route = { name: (this.item.anon || this.currentUser) ? this.item.route : this.item.anonRoute } if (USERNAME_ROUTES.has(route.name)) { - route.params = { username: this.currentUser.screen_name } + route.params = { username: this.currentUser.screen_name, name: this.currentUser.screen_name } } return route }, -- cgit v1.2.3-70-g09d2