|
|
@ -7,25 +7,49 @@ const { navigateToFeed } = workspaceStore |
|
|
|
|
|
|
|
|
|
|
|
const { isFeedPageOpened } = storeToRefs(workspaceStore) |
|
|
|
const { isFeedPageOpened } = storeToRefs(workspaceStore) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { appInfo } = useGlobal() |
|
|
|
|
|
|
|
|
|
|
|
const { loadFeed, socialFeed } = useProductFeed() |
|
|
|
const { loadFeed, socialFeed } = useProductFeed() |
|
|
|
|
|
|
|
|
|
|
|
const isNewFeedAvailable = ref(false) |
|
|
|
const isNewFeedAvailable = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
const checkNewFeed = async () => { |
|
|
|
const checkNewFeed = async () => { |
|
|
|
await loadFeed({ type: 'all', loadMore: false }) |
|
|
|
try { |
|
|
|
if (!socialFeed.value.length) return |
|
|
|
await loadFeed({ type: 'all', loadMore: false }) |
|
|
|
|
|
|
|
if (!socialFeed.value.length) return |
|
|
|
|
|
|
|
|
|
|
|
const [latestFeed] = socialFeed.value |
|
|
|
const [latestFeed] = socialFeed.value |
|
|
|
const lastFeedTime = localStorage.getItem('lastFeedPublishedTime') |
|
|
|
const lastFeedTime = localStorage.getItem('lastFeedPublishedTime') |
|
|
|
const lastFeed = dayjs(lastFeedTime) |
|
|
|
const lastFeed = dayjs(lastFeedTime) |
|
|
|
|
|
|
|
|
|
|
|
if (!lastFeed.isValid() || dayjs(latestFeed['Published Time']).isAfter(lastFeed)) { |
|
|
|
if (!lastFeed.isValid() || dayjs(latestFeed['Published Time']).isAfter(lastFeed)) { |
|
|
|
isNewFeedAvailable.value = true |
|
|
|
isNewFeedAvailable.value = true |
|
|
|
localStorage.setItem('lastFeedPublishedTime', latestFeed['Published Time']) |
|
|
|
localStorage.setItem('lastFeedPublishedTime', latestFeed['Published Time']) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
|
|
console.error('Error while checking new feed', error) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onMounted(checkNewFeed) |
|
|
|
const intervalId = ref() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const checkFeedWithInterval = async () => { |
|
|
|
|
|
|
|
await checkNewFeed() |
|
|
|
|
|
|
|
intervalId.value = setTimeout(checkFeedWithInterval, 3 * 60 * 60 * 1000) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
|
|
|
|
if (appInfo.value.feedEnabled) { |
|
|
|
|
|
|
|
checkFeedWithInterval() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onUnmounted(() => { |
|
|
|
|
|
|
|
if (intervalId.value) { |
|
|
|
|
|
|
|
clearTimeout(intervalId.value) |
|
|
|
|
|
|
|
intervalId.value = null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const gotoFeed = () => navigateToFeed() |
|
|
|
const gotoFeed = () => navigateToFeed() |
|
|
|
</script> |
|
|
|
</script> |
|
|
|