Ignore forEachFeedsCard on non-feeds page

This commit is contained in:
the1812 2024-02-27 08:59:05 +08:00
parent 60b427fdea
commit c2092dc567

View File

@ -1,4 +1,5 @@
import { getCookieValue, matchUrlPattern } from '@/core/utils'
import { feedsUrls } from '@/core/utils/urls'
import { FeedsCardCallback } from '../types'
import { feedsCardCallbacks } from './base'
import { FeedsCardsManagerV1 } from './v1'
@ -28,6 +29,10 @@ export const feedsCardsManager = (() => {
* @param callback
*/
export const forEachFeedsCard = async (callback: FeedsCardCallback) => {
if (feedsUrls.every(url => !matchUrlPattern(url))) {
return null
}
const success = await feedsCardsManager.startWatching()
if (!success) {
console.error('feedsCardsManager.startWatching() failed')