From ce05ac8251e044397b63029763d976af3722887b Mon Sep 17 00:00:00 2001 From: chezhe Date: Tue, 22 Mar 2022 12:18:01 +0800 Subject: [PATCH 1/4] chore: fix bugs --- src-tauri/Cargo.lock | 2 +- src/components/AddFeed.tsx | 1 + src/components/Reader.tsx | 9 ++++++++- src/index.css | 11 +++++++++++ src/utils/format.ts | 2 ++ src/utils/network.ts | 12 +++++++++++- 6 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 317abdf..26d82e5 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -36,7 +36,7 @@ dependencies = [ [[package]] name = "aleph" -version = "0.3.0" +version = "0.4.0" dependencies = [ "serde", "serde_json", diff --git a/src/components/AddFeed.tsx b/src/components/AddFeed.tsx index 4125e0c..4438c28 100644 --- a/src/components/AddFeed.tsx +++ b/src/components/AddFeed.tsx @@ -86,6 +86,7 @@ export default function AddFeed({ type: 'feed/update', payload: newFeed, }) + onClose() } else { try { setIsAdding(true) diff --git a/src/components/Reader.tsx b/src/components/Reader.tsx index f120277..0dd8edf 100644 --- a/src/components/Reader.tsx +++ b/src/components/Reader.tsx @@ -14,7 +14,7 @@ import dayjs from 'dayjs' import NoContent from '../assets/no-content.png' import { CirclePlay, Compass, Star } from 'grommet-icons' import { useAppDispatch } from '../store/hooks' -import { useState } from 'react' +import { useEffect, useRef, useState } from 'react' import { stripURL } from '../utils/format' const turndownService = new TurndownService() @@ -39,7 +39,13 @@ export default function Reader({ setPlayingEp: (ep: Episode | undefined) => void }) { const dispatch = useAppDispatch() + const readerContainer = useRef(null) const [isStarred, setIsStarred] = useState(activeItem?.starred ?? false) + useEffect(() => { + if (readerContainer && readerContainer.current) { + ;(readerContainer.current as any).scrollTo(0, 0) + } + }, [activeItem]) if (!activeItem) { return ( @@ -69,6 +75,7 @@ export default function Reader({ height="100vh" background={isDark ? 'dark-2' : '#f3f1eb'} style={{ overflowY: 'scroll', position: 'relative' }} + ref={readerContainer} > {} + export const isPodcast = (item: Episode) => item.podurl export const isContained = (item: Episode, starreds: Episode[]) => { diff --git a/src/utils/network.ts b/src/utils/network.ts index 58ac3c6..e6b1421 100644 --- a/src/utils/network.ts +++ b/src/utils/network.ts @@ -59,12 +59,22 @@ export function formatEpisode(item: any, feed: Feed) { typeof newItem.guid === 'string' ? newItem.guid : newItem.guid['#text'] } + let podurl = '' + console.log(newItem) + if ( + newItem.enclosure && + newItem.enclosure.type && + newItem.enclosure.type.startsWith('audio/') + ) { + podurl = newItem.enclosure.url || '' + } + newItem = { link: newItem.link || guid, author: newItem.author || newItem['itunes:author'] || '', pubDate: newItem.pubDate || '', cover: newItem.cover || '', - podurl: newItem.enclosure?.url || '', + podurl, title: newItem.title || '', description: newItem['content:encoded'] || newItem.description || '', guid: guid || '', From 6acd8e60c097031996410cfa163d8c99f3d6f182 Mon Sep 17 00:00:00 2001 From: chezhe Date: Tue, 22 Mar 2022 15:02:59 +0800 Subject: [PATCH 2/4] fix: xml parse --- src/components/Reader.tsx | 4 ++-- src/utils/network.ts | 32 ++++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/components/Reader.tsx b/src/components/Reader.tsx index 0dd8edf..a274431 100644 --- a/src/components/Reader.tsx +++ b/src/components/Reader.tsx @@ -118,8 +118,8 @@ export default function Reader({ align="center" justify="center" style={{ - WebkitBackdropFilter: 'blur(10px)', - backdropFilter: 'blur(10px)', + WebkitBackdropFilter: 'blur(3px)', + backdropFilter: 'blur(3px)', backgroundColor: 'rgba(255, 255, 255, 0.5)', }} > diff --git a/src/utils/network.ts b/src/utils/network.ts index e6b1421..7dadfd6 100644 --- a/src/utils/network.ts +++ b/src/utils/network.ts @@ -24,9 +24,13 @@ export async function fetchFeed(feed: Feed): Promise { ignoreAttributes: false, }) const jObj = parser.parse(data as string) + const extra = { + image: jObj.rss?.channel?.image, + } return ( - jObj.rss?.channel?.item.map((item: any) => formatEpisode(item, feed)) || - [] + jObj.rss?.channel?.item.map((item: any) => + formatEpisode(item, feed, extra) + ) || [] ) }) .catch((err) => { @@ -35,7 +39,13 @@ export async function fetchFeed(feed: Feed): Promise { }) } -export function formatEpisode(item: any, feed: Feed) { +export function formatEpisode( + item: any, + feed: Feed, + extra: { + image: any + } +) { let newItem = item if (item.enclosure) { newItem = { @@ -47,10 +57,10 @@ export function formatEpisode(item: any, feed: Feed) { }, } } - if (newItem['itunes:image']) { + if (!newItem.image) { newItem = { ...newItem, - cover: newItem['itunes:image']['@_href'], + image: newItem['itunes:image'] || extra.image, } } let guid = '' @@ -60,7 +70,6 @@ export function formatEpisode(item: any, feed: Feed) { } let podurl = '' - console.log(newItem) if ( newItem.enclosure && newItem.enclosure.type && @@ -69,11 +78,18 @@ export function formatEpisode(item: any, feed: Feed) { podurl = newItem.enclosure.url || '' } + let cover = newItem.cover + if (!cover && newItem.image) { + cover = newItem.image.url || newItem.image['@_href'] || '' + } + + const link = `${newItem.link}?${guid}` + newItem = { - link: newItem.link || guid, + link, author: newItem.author || newItem['itunes:author'] || '', pubDate: newItem.pubDate || '', - cover: newItem.cover || '', + cover, podurl, title: newItem.title || '', description: newItem['content:encoded'] || newItem.description || '', From c54f768ee669829fd1a3dbac66da6b3a4d7676e0 Mon Sep 17 00:00:00 2001 From: chezhe Date: Tue, 22 Mar 2022 17:06:56 +0800 Subject: [PATCH 3/4] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1af8129..fe30649 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,6 @@ # Aleph -Aleph (or Aleph or א or 阿莱夫, ˈɑːlɛf) is a RSS reader & podcast client built for the desktop. +Aleph (or א or 阿莱夫, ˈɑːlɛf) is an RSS reader & podcast client built for the desktop. -![Example](https://pbs.twimg.com/media/FOX6Lt8VUAUv9vl?format=jpg&name=medium) +![Example](https://aleph.chezhe.dev/screenshot.png) From 833137f7ac415e3279548e770d6aa9e6efea9033 Mon Sep 17 00:00:00 2001 From: chezhe Date: Tue, 29 Mar 2022 12:44:59 +0800 Subject: [PATCH 4/4] bump: 0.5.0 & polish audio player --- package.json | 3 +- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 2 +- src/components/Playing.tsx | 58 --------------- src/components/PodPlayer.tsx | 140 ++++++++++++++++++++++++++++++++--- yarn.lock | 21 ++---- 6 files changed, 137 insertions(+), 89 deletions(-) delete mode 100644 src/components/Playing.tsx diff --git a/package.json b/package.json index 16ee8f1..24d3422 100644 --- a/package.json +++ b/package.json @@ -12,15 +12,14 @@ "@types/node": "^16.7.13", "@types/react": "^17.0.20", "@types/react-dom": "^17.0.9", - "axios": "^0.26.1", "dayjs": "^1.11.0", "fast-xml-parser": "^4.0.7", "grommet": "^2.21.0", "grommet-icons": "^4.7.0", "lodash": "^4.17.21", "react": "^17.0.2", - "react-audio-player": "^0.17.0", "react-dom": "^17.0.2", + "react-loading": "^2.0.3", "react-redux": "^7.2.6", "react-scripts": "5.0.0", "styled-components": "^5.3.3", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 7e5d8c9..5dbcb25 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "aleph" -version = "0.4.0" +version = "0.5.0" description = "A Tauri App" authors = ["chezhe"] license = "" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 54cb993..90e2a10 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "package": { "productName": "aleph", - "version": "0.4.0" + "version": "0.5.0" }, "build": { "distDir": "../build", diff --git a/src/components/Playing.tsx b/src/components/Playing.tsx deleted file mode 100644 index db9ec0e..0000000 --- a/src/components/Playing.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import { Box, Button, Image } from 'grommet' -import { Close } from 'grommet-icons' -import ReactAudioPlayer from 'react-audio-player' -import { Episode } from '../types' -import { stripURL } from '../utils/format' - -export default function Playing({ - activeItem, - playingEp, - setPlayingEp, -}: { - activeItem: Episode | undefined - playingEp: Episode | undefined - setPlayingEp: (ep: Episode | undefined) => void -}) { - if ( - !playingEp || - (playingEp && activeItem && activeItem?.podurl === playingEp?.podurl) - ) { - return null - } - return ( - - -