personal web client for Bluesky
typescript solidjs bluesky atcute

fix: properly check if saved feed is generator

mary.my.id 529e4dbc a83805dd

verified
Changed files
+10 -12
src
components
+10 -12
src/components/feeds/feed-overflow-menu.tsx
··· 31 31 32 32 const feed = props.feed; 33 33 34 - const isSaved = createMemo(() => { 34 + const saved = createMemo(() => { 35 35 if (!currentAccount) { 36 - return false; 36 + return -1; 37 37 } 38 38 39 39 const feeds = currentAccount.preferences.feeds; 40 - return feeds.some((f) => f.info.uri === feed.uri); 40 + const index = feeds.findIndex((f) => f.type === 'generator' && f.info.uri === feed.uri); 41 + 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 - icon={!isSaved() ? AddOutlinedIcon : TrashOutlinedIcon} 48 - label={!isSaved() ? `Save to my feeds` : `Remove from my feeds`} 49 + icon={saved() === -1 ? AddOutlinedIcon : TrashOutlinedIcon} 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 + const index = saved(); 53 56 54 - if (isSaved()) { 55 - const index = feeds.findIndex((f) => f.info.uri === feed.uri); 57 + if (index !== -1) { 56 58 feeds.splice(index, 1); 57 59 } else { 58 - feeds.push({ 59 - type: 'generator', 60 - pinned: false, 61 - info: omit(feed, ['likeCount']), 62 - }); 60 + feeds.push({ type: 'generator', pinned: false, info: omit(feed, ['likeCount']) }); 63 61 } 64 62 }} 65 63 />