Skip to content

Commit b6c8052

Browse files
authored
Merge pull request yang991178#602 from yang991178/1.1.4
Version 1.1.4
2 parents e6d1883 + 7fcd9e5 commit b6c8052

File tree

10 files changed

+527
-654
lines changed

10 files changed

+527
-654
lines changed

package-lock.json

Lines changed: 478 additions & 622 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fluent-reader",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"description": "Modern desktop RSS reader",
55
"main": "./dist/electron.js",
66
"scripts": {
@@ -25,8 +25,8 @@
2525
"@types/react": "^16.9.35",
2626
"@types/react-dom": "^16.9.8",
2727
"@types/react-redux": "^7.1.9",
28-
"@yang991178/rss-parser": "^3.8.1",
29-
"electron": "^21.0.1",
28+
"rss-parser": "^3.13.0",
29+
"electron": "^27.0.0",
3030
"electron-builder": "^23.0.3",
3131
"electron-react-devtools": "^0.5.3",
3232
"electron-store": "^5.2.0",

src/bridges/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const utilsBridge = {
1717
ipcRenderer.invoke("open-external", url, background)
1818
},
1919

20-
showErrorBox: (title: string, content: string) => {
21-
ipcRenderer.invoke("show-error-box", title, content)
20+
showErrorBox: (title: string, content: string, copy?: string) => {
21+
ipcRenderer.invoke("show-error-box", title, content, copy)
2222
},
2323

2424
showMessageBox: async (

src/components/settings/rules.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ import {
2424
} from "@fluentui/react"
2525
import { SourceRule, RuleActions } from "../../scripts/models/rule"
2626
import { FilterType } from "../../scripts/models/feed"
27-
import { validateRegex } from "../../scripts/utils"
27+
import { MyParserItem, validateRegex } from "../../scripts/utils"
2828
import { RSSItem } from "../../scripts/models/item"
29-
import Parser from "@yang991178/rss-parser"
3029

3130
const actionKeyMap = {
3231
"r-true": "article.markRead",
@@ -337,7 +336,7 @@ class RulesTab extends React.Component<RulesTabProps, RulesTabState> {
337336
testMockItem = () => {
338337
let parsed = { title: this.state.mockTitle }
339338
let source = this.props.sources[parseInt(this.state.sid)]
340-
let item = new RSSItem(parsed as Parser.Item, source)
339+
let item = new RSSItem(parsed as MyParserItem, source)
341340
item.snippet = this.state.mockContent
342341
item.creator = this.state.mockCreator
343342
SourceRule.applyAll(this.getSourceRules(), item)

src/main/utils.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,23 @@ export function setUtilsListeners(manager: WindowManager) {
4545
openExternal(url, background)
4646
})
4747

48-
ipcMain.handle("show-error-box", (_, title, content) => {
49-
dialog.showErrorBox(title, content)
48+
ipcMain.handle("show-error-box", async (_, title, content, copy?: string) => {
49+
if (manager.hasWindow() && copy != null) {
50+
const response = await dialog.showMessageBox(manager.mainWindow, {
51+
type: 'error',
52+
title: title,
53+
message: title,
54+
detail: content,
55+
buttons: ["OK", copy],
56+
cancelId: 0,
57+
defaultId: 0,
58+
})
59+
if (response.response === 1) {
60+
clipboard.writeText(`${title}: ${content}`);
61+
}
62+
} else {
63+
dialog.showErrorBox(title, content)
64+
}
5065
})
5166

5267
ipcMain.handle(
@@ -56,7 +71,8 @@ export function setUtilsListeners(manager: WindowManager) {
5671
let response = await dialog.showMessageBox(manager.mainWindow, {
5772
type: type,
5873
title: title,
59-
message: message,
74+
message: title,
75+
detail: message,
6076
buttons:
6177
process.platform === "win32"
6278
? ["Yes", "No"]

src/scripts/i18n/fr-FR.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
},
7171
"context": {
7272
"share": "Partager",
73-
"read": "Lu",
73+
"read": "Lire",
7474
"copyTitle": "Copier le titre",
7575
"copyURL": "Copier le lien",
7676
"copy": "Copier",

src/scripts/models/group.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ export function importOPML(): AppThunk {
300300
.map(e => {
301301
return e[0] + "\n" + String(e[1])
302302
})
303-
.join("\n")
303+
.join("\n"),
304+
intl.get("context.copy")
304305
)
305306
}
306307
})

src/scripts/models/item.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as db from "../db"
22
import lf from "lovefield"
33
import intl from "react-intl-universal"
4+
import type { MyParserItem } from "../utils"
45
import {
56
domParser,
67
htmlDecode,
@@ -9,15 +10,7 @@ import {
910
platformCtrl,
1011
} from "../utils"
1112
import { RSSSource, updateSource, updateUnreadCounts } from "./source"
12-
import {
13-
FeedActionTypes,
14-
INIT_FEED,
15-
LOAD_MORE,
16-
FilterType,
17-
initFeeds,
18-
dismissItems,
19-
} from "./feed"
20-
import Parser from "@yang991178/rss-parser"
13+
import { FeedActionTypes, INIT_FEED, LOAD_MORE, dismissItems } from "./feed"
2114
import {
2215
pushNotification,
2316
setupAutoFetch,
@@ -48,7 +41,7 @@ export class RSSItem {
4841
notify: boolean
4942
serviceRef?: string
5043

51-
constructor(item: Parser.Item, source: RSSSource) {
44+
constructor(item: MyParserItem, source: RSSSource) {
5245
for (let field of ["title", "link", "creator"]) {
5346
const content = item[field]
5447
if (content && typeof content !== "string") delete item[field]
@@ -65,7 +58,7 @@ export class RSSItem {
6558
this.notify = false
6659
}
6760

68-
static parseContent(item: RSSItem, parsed: Parser.Item) {
61+
static parseContent(item: RSSItem, parsed: MyParserItem) {
6962
for (let field of ["thumb", "content", "fullContent"]) {
7063
const content = parsed[field]
7164
if (content && typeof content !== "string") delete parsed[field]
@@ -79,7 +72,7 @@ export class RSSItem {
7972
}
8073
if (parsed.thumb) {
8174
item.thumb = parsed.thumb
82-
} else if (parsed.image && parsed.image.$ && parsed.image.$.url) {
75+
} else if (parsed.image?.$?.url) {
8376
item.thumb = parsed.image.$.url
8477
} else if (parsed.image && typeof parsed.image === "string") {
8578
item.thumb = parsed.image

src/scripts/models/source.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
import Parser from "@yang991178/rss-parser"
21
import intl from "react-intl-universal"
32
import * as db from "../db"
43
import lf from "lovefield"
5-
import { fetchFavicon, ActionStatus, AppThunk, parseRSS } from "../utils"
4+
import {
5+
fetchFavicon,
6+
ActionStatus,
7+
AppThunk,
8+
parseRSS,
9+
MyParserItem,
10+
} from "../utils"
611
import {
712
RSSItem,
813
insertItems,
@@ -64,7 +69,7 @@ export class RSSSource {
6469

6570
private static async checkItem(
6671
source: RSSSource,
67-
item: Parser.Item
72+
item: MyParserItem
6873
): Promise<RSSItem> {
6974
let i = new RSSItem(item, source)
7075
const items = (await db.itemsDB
@@ -90,7 +95,7 @@ export class RSSSource {
9095

9196
static checkItems(
9297
source: RSSSource,
93-
items: Parser.Item[]
98+
items: MyParserItem[]
9499
): Promise<RSSItem[]> {
95100
return new Promise<RSSItem[]>((resolve, reject) => {
96101
let p = new Array<Promise<RSSItem>>()
@@ -318,7 +323,8 @@ export function addSource(
318323
if (!batch) {
319324
window.utils.showErrorBox(
320325
intl.get("sources.errorAdd"),
321-
String(e)
326+
String(e),
327+
intl.get("context.copy")
322328
)
323329
}
324330
throw e

src/scripts/utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import intl from "react-intl-universal"
22
import { ThunkAction, ThunkDispatch } from "redux-thunk"
33
import { AnyAction } from "redux"
44
import { RootState } from "./reducer"
5-
import Parser from "@yang991178/rss-parser"
5+
import Parser from "rss-parser"
66
import Url from "url"
77
import { SearchEngines } from "../schema-types"
88

@@ -29,9 +29,11 @@ const rssParser = new Parser({
2929
"image",
3030
["content:encoded", "fullContent"],
3131
["media:content", "mediaContent", { keepArray: true }],
32-
] as Parser.CustomFieldItem[],
32+
],
3333
},
3434
})
35+
type extractGeneric<Type> = Type extends Parser<infer _, infer U> ? U : never
36+
export type MyParserItem = extractGeneric<typeof rssParser> & Parser.Item
3537

3638
const CHARSET_RE = /charset=([^()<>@,;:\"/[\]?.=\s]*)/i
3739
const XML_ENCODING_RE = /^<\?xml.+encoding="(.+?)".*?\?>/i

0 commit comments

Comments
 (0)