+10
-12
src/components/feeds/feed-overflow-menu.tsx
+10
-12
src/components/feeds/feed-overflow-menu.tsx
···
31
31
32
32
const feed = props.feed;
33
33
34
34
-
const isSaved = createMemo(() => {
34
34
+
const saved = createMemo(() => {
35
35
if (!currentAccount) {
36
36
-
return false;
36
36
+
return -1;
37
37
}
38
38
39
39
const feeds = currentAccount.preferences.feeds;
40
40
-
return feeds.some((f) => f.info.uri === feed.uri);
40
40
+
const index = feeds.findIndex((f) => f.type === 'generator' && f.info.uri === feed.uri);
41
41
+
42
42
+
return index;
41
43
});
42
44
43
45
return (
44
46
<Menu.Container anchor={props.anchor}>
45
47
{currentAccount && (
46
48
<Menu.Item
47
47
-
icon={!isSaved() ? AddOutlinedIcon : TrashOutlinedIcon}
48
48
-
label={!isSaved() ? `Save to my feeds` : `Remove from my feeds`}
49
49
+
icon={saved() === -1 ? AddOutlinedIcon : TrashOutlinedIcon}
50
50
+
label={saved() === -1 ? `Save to my feeds` : `Remove from my feeds`}
49
51
onClick={() => {
50
52
close();
51
53
52
54
const feeds = currentAccount.preferences.feeds;
55
55
+
const index = saved();
53
56
54
54
-
if (isSaved()) {
55
55
-
const index = feeds.findIndex((f) => f.info.uri === feed.uri);
57
57
+
if (index !== -1) {
56
58
feeds.splice(index, 1);
57
59
} else {
58
58
-
feeds.push({
59
59
-
type: 'generator',
60
60
-
pinned: false,
61
61
-
info: omit(feed, ['likeCount']),
62
62
-
});
60
60
+
feeds.push({ type: 'generator', pinned: false, info: omit(feed, ['likeCount']) });
63
61
}
64
62
}}
65
63
/>