From 73c5e45164cee6929be2a582c69b5152bc7f5b67 Mon Sep 17 00:00:00 2001 From: Franzz Date: Thu, 20 Aug 2026 00:09:12 +0200 Subject: [PATCH] Fix feed post finder (scroll) --- src/components/Project.vue | 3 +- src/components/ProjectFeed.vue | 51 +++++++++++++++++++--------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/components/Project.vue b/src/components/Project.vue index 8408927..fa8d7ca 100644 --- a/src/components/Project.vue +++ b/src/components/Project.vue @@ -186,10 +186,9 @@ export default { onMediaChange: async (oMedia) => { this.hash.items = [this.project.codename, 'media', oMedia.id]; if(oMedia.set == 'post-medias') { - (await this.feed.goToPost('media', oMedia.id))?.panMapToMarker(); + (await this.feed.findPost('media', oMedia.id))?.panMapToMarker(); if(!this.lightbox.hasMediaAfterCurrent()) { await this.feed.getNextFeed(); - await this.$nextTick(); this.lightbox.refreshAlbum(); } } diff --git a/src/components/ProjectFeed.vue b/src/components/ProjectFeed.vue index cdf3d53..f76e41f 100644 --- a/src/components/ProjectFeed.vue +++ b/src/components/ProjectFeed.vue @@ -82,7 +82,7 @@ export default { //Direct link post action await(this.hash.items.length == 3 - ? this.findPost(this.hash.items[1], this.hash.items[2], pMapIsReady) + ? this.findLinkedPost(this.hash.items[1], this.hash.items[2], pMapIsReady) : this.getNextFeed() ); @@ -91,42 +91,46 @@ export default { getScrollElement() { return this.$refs.feedSimpleBar?.scrollElement; }, - async findPost(sPostType, iPostId, pMapIsReady = Promise.resolve()) { - this.loadingPost = true; - let vPost = await this.goToPost(sPostType, iPostId); + async findLinkedPost(sPostType, iPostId, pMapIsReady) { + let vPost = await this.findPost(sPostType, iPostId, true); if(vPost) { await pMapIsReady; await vPost.executeMainAction(0); + return vPost; + } + else return null; + }, + async findPost(sPostType, iPostId, bHidePosts=false) { + if(bHidePosts) this.loadingPost = true; + + let avPosts = this.$refs?.posts?.filter((post) => {return post.postId == sPostType+'-'+iPostId;}); + if(avPosts && avPosts.length > 0) { + let vPost = avPosts[0]; this.loadingPost = false; + + //Force next update to have enough subsequent elements to position the post on top of the page + await this.getNextFeed(); + + //Position the post on top of the page + const $ScrollElement = this.getScrollElement(); + $ScrollElement.scrollTop += Math.round( + vPost.$el.getBoundingClientRect().top + - $ScrollElement.getBoundingClientRect().top + - parseFloat(getComputedStyle(this.$refs.feedSimpleBar.$el).paddingTop) + ); + return vPost; } else if(!this.outOfData) { await this.getNextFeed(); - await this.$nextTick(); - return this.findPost(sPostType, iPostId, pMapIsReady); + return this.findPost(sPostType, iPostId); } else { - console.log('Missing element ID "'+iPostId+'" of type "'+sPostType+'"'); this.loadingPost = false; + console.log('Missing element ID "'+iPostId+'" of type "'+sPostType+'"'); return null; } }, - async goToPost(sPostType, iPostId) { - let avPosts = this.$refs?.posts?.filter((post) => {return post.postId == sPostType+'-'+iPostId;}); - if(!avPosts || avPosts.length == 0) return null; - - //Force next update to have enough subsequent elements to position the post on top of the page - await this.getNextFeed(); - - let vPost = avPosts[0]; - this.getScrollElement().scrollTop += Math.round( - vPost.$el.getBoundingClientRect().top - + window.pageYOffset - - parseFloat(getComputedStyle(this.$refs.feedSimpleBar.$el).paddingTop) - ); - - return vPost; - }, async getNextFeed() { if(!this.project || this.outOfData || this.loadingFeed) return true; @@ -148,6 +152,7 @@ export default { this.loadingFeed = false; this.firstChunk = false; + await this.$nextTick(); return true; }, onFeedScroll(oEvent) {