File tree Expand file tree Collapse file tree 3 files changed +18
-5
lines changed
apps/desktop/layer/renderer/src Expand file tree Collapse file tree 3 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import { FeedForm } from "~/modules/discover/FeedForm"
13
13
import type { ListFormDataValuesType } from "~/modules/discover/ListForm"
14
14
import { ListForm } from "~/modules/discover/ListForm"
15
15
import {
16
- getSubscriptionByFeedId ,
16
+ getSubscriptionByFeedIdOrUrl ,
17
17
useFeedSubscriptionCount ,
18
18
useListSubscriptionCount ,
19
19
} from "~/store/subscription"
@@ -73,10 +73,12 @@ export const useFollow = () => {
73
73
} else {
74
74
canFollowMoreInboxAndNotify ( "feed" )
75
75
}
76
- let isFollowed = false
77
- if ( options ?. id ) {
78
- isFollowed = ! ! getSubscriptionByFeedId ( options . id )
79
- }
76
+
77
+ const subscription = getSubscriptionByFeedIdOrUrl ( {
78
+ id : options ?. id ,
79
+ url : options ?. url ,
80
+ } )
81
+ const isFollowed = ! ! subscription
80
82
81
83
present ( {
82
84
title : `${ isFollowed ? `${ t ( "common:words.edit" ) } ` : "" } ${ options ?. isList ? t ( "words.lists" ) : t ( "words.feeds" ) } ` ,
Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import { FeedService } from "~/services"
15
15
import { getSubscriptionByFeedId } from "../subscription"
16
16
import { userActions } from "../user"
17
17
import { createImmerSetter , createTransaction , createZustandStore } from "../utils/helper"
18
+ import { feedByIdOrUrlSelector } from "./selector"
18
19
import type { FeedQueryParams , FeedState } from "./types"
19
20
20
21
export const useFeedStore = createZustandStore < FeedState > ( "feed" ) ( ( ) => ( {
@@ -142,6 +143,9 @@ export const feedActions = new FeedActions()
142
143
143
144
export const getFeedById = ( feedId : string ) : Nullable < FeedOrListRespModel > =>
144
145
useFeedStore . getState ( ) . feeds [ feedId ]
146
+ export const getFeedByIdOrUrl = ( feed : FeedQueryParams ) : Nullable < FeedOrListRespModel > => {
147
+ return feedByIdOrUrlSelector ( feed ) ( get ( ) )
148
+ }
145
149
146
150
export const getPreferredTitle = (
147
151
feed ?: Pick < FeedOrListRespModel , "type" | "id" | "title" > | null ,
Original file line number Diff line number Diff line change 1
1
import type { FeedViewType } from "@follow/constants"
2
2
3
+ import type { FeedQueryParams } from "../feed"
4
+ import { getFeedByIdOrUrl } from "../feed"
3
5
import {
4
6
folderFeedsByFeedIdSelector ,
5
7
subscriptionByViewSelector ,
@@ -12,6 +14,11 @@ export const getSubscriptionByFeedId = (feedId: FeedId) => {
12
14
const state = get ( )
13
15
return state . data [ feedId ]
14
16
}
17
+ export const getSubscriptionByFeedIdOrUrl = ( params : FeedQueryParams ) => {
18
+ const feed = getFeedByIdOrUrl ( params )
19
+ if ( ! feed ) return
20
+ return getSubscriptionByFeedId ( feed . id )
21
+ }
15
22
16
23
export const isListSubscription = ( feedId ?: FeedId ) => {
17
24
if ( ! feedId ) return false
You can’t perform that action at this time.
0 commit comments