diff --git a/src/api/timelines.js b/src/api/timelines.js index 0679b1eec..568b97a4f 100644 --- a/src/api/timelines.js +++ b/src/api/timelines.js @@ -115,6 +115,7 @@ export const fetchTimeline = ({ publicAndExternal: MASTODON_PUBLIC_TIMELINE, dms: MASTODON_DIRECT_MESSAGES_TIMELINE_URL, user: MASTODON_USER_TIMELINE_URL, + userPinned: MASTODON_USER_TIMELINE_URL, media: MASTODON_USER_TIMELINE_URL, list: MASTODON_LIST_TIMELINE_URL, favorites: MASTODON_USER_FAVORITES_TIMELINE_URL, @@ -130,6 +131,7 @@ export const fetchTimeline = ({ const twoArgs = new Set([ 'user', + 'userPinned', 'media', 'list', 'publicFavorites', @@ -147,6 +149,7 @@ export const fetchTimeline = ({ const id = (() => { switch (timeline) { case 'user': + case 'userPinned': case 'media': return userId case 'list': @@ -163,6 +166,9 @@ export const fetchTimeline = ({ if (timeline === 'media') { params.onlyMedia = true } + if (timeline === 'userPinned') { + params.pinned = true + } if (timeline === 'public') { params.local = true } diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js index 040ae80e7..789e73985 100644 --- a/src/components/timeline/timeline.js +++ b/src/components/timeline/timeline.js @@ -28,12 +28,11 @@ library.add(faCircleNotch, faCog, faMinus, faArrowUp, faCirclePlus, faCheck) const Timeline = { props: { timelineRef: Object, - argument: String, - embedded: Boolean, count: Number, - pinnedStatusIds: Set, - inProfile: Boolean, footerSlipgate: Object, // reference to an element where we should put our footer + embedded: Boolean, + inProfile: Boolean, + skipPinned: Boolean, }, data() { return { @@ -58,17 +57,8 @@ const Timeline = { }, filteredVisibleStatuses() { return [...this.timeline.visibleStatusesIds.keys()] - .filter( - (id) => - this.timelineRef.name !== 'user' || - (id >= this.timeline.minId && id <= this.timeline.maxId), - ) .map((id) => this.timeline.statuses.get(id)) - }, - filteredPinnedStatusIds() { - return (this.pinnedStatusIds || []).filter( - (statusId) => this.timeline.statusesObject[statusId], - ) + .filter(({ pinned }) => this.skipPinned ? !pinned : true) }, newStatusCount() { return this.timeline.newStatusCount @@ -109,17 +99,11 @@ const Timeline = { ), } }, - // id map of statuses which need to be hidden in the main list due to pinning logic - pinnedStatusIdsObject() { - return keyBy(this.pinnedStatusIds) - }, statusesToDisplay() { const amount = this.timeline.visibleStatusesIds.size const statusesPerSide = Math.ceil(Math.max(3, window.innerHeight / 80)) - const nonPinnedIndex = - this.virtualScrollIndex - this.filteredPinnedStatusIds.length - const min = Math.max(0, nonPinnedIndex - statusesPerSide) - const max = Math.min(amount, nonPinnedIndex + statusesPerSide) + const min = Math.max(0, this.virtualScrollIndex - statusesPerSide) + const max = Math.min(amount, this.virtualScrollIndex + statusesPerSide) return new Set( [...this.timeline.visibleStatusesIds.keys()].slice(min, max), ) @@ -159,6 +143,11 @@ const Timeline = { }, methods: { timelineChange(newTimeline, oldTimeline) { + // TODO this might not be necessary if we optimize mergeOrAdd + const sameName = newTimeline?.name === oldTimeline?.name + const sameArgument = newTimeline?.argument === oldTimeline?.argument + if (sameName && sameArgument) return + if (oldTimeline && oldTimeline.name !== 'friends') { useTimelinesStore().clearTimeline(oldTimeline.name) } diff --git a/src/components/timeline/timeline.vue b/src/components/timeline/timeline.vue index 38a2ae144..fec86c228 100644 --- a/src/components/timeline/timeline.vue +++ b/src/components/timeline/timeline.vue @@ -71,17 +71,6 @@ class="timeline" role="feed" > - { + console.log('LOAD', userId) this.userId = userId } @@ -119,10 +119,11 @@ const UserProfile = { if (user) { loadById(user.id) } else { - ;(maybeId - ? this.$store.dispatch('fetchUser', maybeId) - : this.$store.dispatch('fetchUserByName', maybeName) - ) + const promise = maybeId + ? useUsersStore().fetchUser(maybeId) + : useUsersStore().fetchUserByName(maybeName) + + promise .then(({ id }) => loadById(id)) .catch((reason) => { const errorMessage = get(reason, 'error.error') @@ -138,6 +139,7 @@ const UserProfile = { } }, switchUser(userNameOrId) { + console.log('USER SWITCH') this.load(userNameOrId) }, onTabSwitch(tab) { diff --git a/src/components/user_profile/user_profile.vue b/src/components/user_profile/user_profile.vue index e7381937d..ca74de0d6 100644 --- a/src/components/user_profile/user_profile.vue +++ b/src/components/user_profile/user_profile.vue @@ -14,22 +14,32 @@ />
+ +
@@ -71,24 +81,23 @@
diff --git a/src/services/timeline_fetcher/timeline_fetcher.service.js b/src/services/timeline_fetcher/timeline_fetcher.service.js index 84c980556..e056ece94 100644 --- a/src/services/timeline_fetcher/timeline_fetcher.service.js +++ b/src/services/timeline_fetcher/timeline_fetcher.service.js @@ -100,7 +100,7 @@ const fetchAndUpdate = ({ }) } -const timelineFetcher = (timeline, argument, argumentKey, credentials) => { +const timelineFetcher = (timeline, argument, credentials) => { const state = { interval: null } @@ -113,7 +113,6 @@ const timelineFetcher = (timeline, argument, argumentKey, credentials) => { } = {}) => fetchAndUpdate({ timeline, argument, - argumentKey, credentials, }, { maxId, diff --git a/src/stores/timelines.js b/src/stores/timelines.js index 5f78440fd..3ba3cb60b 100644 --- a/src/stores/timelines.js +++ b/src/stores/timelines.js @@ -21,7 +21,7 @@ const emptyTl = (name, argument = null) => { fetcher: null, } - const property = USER_TIMELINES.has(name) ? 'userId' : ARGUMENT_MAP[name] + const property = ARGUMENT_MAP[name] if (property) { result[property] = argument @@ -36,6 +36,9 @@ export const ARGUMENT_MAP = { bookmarks: 'bookmarkFolderId', quotes: 'statusId', search: 'query', + user: 'userId', + userPinned: 'userId', + media: 'userId', } export const defaultState = () => { @@ -58,7 +61,6 @@ export const defaultState = () => { ].map((name) => [name, emptyTl(name)])) } -const USER_TIMELINES = new Set(['user', 'userPinned', 'media', 'favorites']) //const CUSTOM_SORT = new Set(['bookmarks', 'favorites']) export const useTimelinesStore = defineStore('timelines', { @@ -82,7 +84,7 @@ export const useTimelinesStore = defineStore('timelines', { // user. I.e. opening different user profiles makes request which could // return data late after user already viewing different user profile // Same can happen with tags etc. - const property = USER_TIMELINES.has(name) ? 'userId' : ARGUMENT_MAP[name] + const property = ARGUMENT_MAP[name] if (property && timeline[property] !== argument) { return @@ -148,7 +150,6 @@ export const useTimelinesStore = defineStore('timelines', { timeline.fetcher = timelineFetcher( timeline, argument, - ARGUMENT_MAP[timeline.name], useOAuthStore().token, )