From e312b486de2b9807952d07d6fbf41b93e6ca26fe Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Wed, 2 Oct 2024 05:54:24 +0000 Subject: [PATCH] fix: pr review changes --- .../nc-gui/components/dashboard/Sidebar/Feed.vue | 14 +++++++++----- .../nc-gui/components/feed/Changelog/index.vue | 4 +--- packages/nc-gui/components/feed/Recents/index.vue | 12 ++++-------- packages/nc-gui/components/feed/Youtube/index.vue | 3 +-- packages/nc-gui/composables/useProductFeed.ts | 12 +++++++++++- packages/nc-gui/lib/types.ts | 2 +- packages/nocodb/src/services/utils.service.ts | 15 +++++++++------ 7 files changed, 36 insertions(+), 26 deletions(-) diff --git a/packages/nc-gui/components/dashboard/Sidebar/Feed.vue b/packages/nc-gui/components/dashboard/Sidebar/Feed.vue index 64812a4d7a..559a51b0d0 100644 --- a/packages/nc-gui/components/dashboard/Sidebar/Feed.vue +++ b/packages/nc-gui/components/dashboard/Sidebar/Feed.vue @@ -2,15 +2,19 @@ import dayjs from 'dayjs' const { navigateToFeed } = useWorkspace() -const { loadFeed } = useProductFeed() +const productFeed = useProductFeed() -const isNewFeedAvailable = ref(true) +const { loadFeed } = productFeed + +const { socialFeed } = toRefs(productFeed) + +const isNewFeedAvailable = ref(false) const checkNewFeed = async () => { - const feed = await loadFeed({ type: 'all', loadMore: false }) - if (!feed.length) return + await loadFeed({ type: 'all', loadMore: false }) + if (!socialFeed.value.length) return - const [latestFeed] = feed + const [latestFeed] = socialFeed.value const lastFeedTime = localStorage.getItem('lastFeedPublishedTime') const lastFeed = dayjs(lastFeedTime) diff --git a/packages/nc-gui/components/feed/Changelog/index.vue b/packages/nc-gui/components/feed/Changelog/index.vue index acc3c442f9..1a21a96d07 100644 --- a/packages/nc-gui/components/feed/Changelog/index.vue +++ b/packages/nc-gui/components/feed/Changelog/index.vue @@ -7,12 +7,10 @@ const { isLoading } = useInfiniteScroll( scrollContainer, async () => { if (isLoading.value) return - const data = await loadFeed({ + await loadFeed({ type: 'github', loadMore: true, }) - - githubFeed.value = [...githubFeed.value, ...data] }, { distance: 1, interval: 2000 }, ) diff --git a/packages/nc-gui/components/feed/Recents/index.vue b/packages/nc-gui/components/feed/Recents/index.vue index 9d22954fbe..e131bfe101 100644 --- a/packages/nc-gui/components/feed/Recents/index.vue +++ b/packages/nc-gui/components/feed/Recents/index.vue @@ -7,14 +7,10 @@ const { isLoading } = useInfiniteScroll( scrollContainer, async () => { if (isLoading.value) return - const data = ( - await loadFeed({ - type: 'all', - loadMore: true, - }) - ).filter((item) => item['Feed Source'] !== 'Twitter') - - socialFeed.value = [...socialFeed.value, ...data] + await loadFeed({ + type: 'all', + loadMore: true, + }) }, { distance: 1, interval: 2000 }, ) diff --git a/packages/nc-gui/components/feed/Youtube/index.vue b/packages/nc-gui/components/feed/Youtube/index.vue index 6eb0f1c3c9..0594aac836 100644 --- a/packages/nc-gui/components/feed/Youtube/index.vue +++ b/packages/nc-gui/components/feed/Youtube/index.vue @@ -7,11 +7,10 @@ const { isLoading } = useInfiniteScroll( scrollContainer, async () => { if (isLoading.value) return - const data = await loadFeed({ + await loadFeed({ type: 'youtube', loadMore: true, }) - youtubeFeed.value = [...youtubeFeed.value, ...data] }, { distance: 1, interval: 2000 }, ) diff --git a/packages/nc-gui/composables/useProductFeed.ts b/packages/nc-gui/composables/useProductFeed.ts index 2c8ae4bd17..197e1a71eb 100644 --- a/packages/nc-gui/composables/useProductFeed.ts +++ b/packages/nc-gui/composables/useProductFeed.ts @@ -45,7 +45,17 @@ export const useProductFeed = createSharedComposable(() => { localStorage.setItem('last_published_at', response[0]['Published Time'] as string) } - return response + switch (type) { + case 'youtube': + youtubeFeed.value = [...youtubeFeed.value, ...response] as ProductFeedItem[] + break + case 'github': + githubFeed.value = [...githubFeed.value, ...response] as ProductFeedItem[] + break + case 'all': + socialFeed.value = [...socialFeed.value, ...response] as ProductFeedItem[] + break + } } catch (error) { switch (type) { case 'youtube': diff --git a/packages/nc-gui/lib/types.ts b/packages/nc-gui/lib/types.ts index 217fc1cb5d..8e18b79a34 100644 --- a/packages/nc-gui/lib/types.ts +++ b/packages/nc-gui/lib/types.ts @@ -281,7 +281,7 @@ interface ProductFeedItem { Id: string Title: string Description: string - ['Feed Source']: 'Youtube' | 'Github' | 'Twitter' + ['Feed Source']: 'Youtube' | 'Github' | 'All' Url: string Tags?: string ['Published Time']: string diff --git a/packages/nocodb/src/services/utils.service.ts b/packages/nocodb/src/services/utils.service.ts index 9f9c6fbaa9..249e8d5260 100644 --- a/packages/nocodb/src/services/utils.service.ts +++ b/packages/nocodb/src/services/utils.service.ts @@ -509,13 +509,16 @@ export class UtilsService { let response; try { - response = await axios.get('https://nocodb.com/api/v1/social/feed', { - params: { - per_page, - page, - type, + response = await axios.get( + 'http://product-feed.nocodb.com/v1/social/feed', + { + params: { + per_page, + page, + type, + }, }, - }); + ); } catch (e) { console.log(e); return [];