mirror of
https://github.com/yang991178/fluent-reader.git
synced 2025-02-11 09:10:39 +01:00
tweak inoreader behaviors
This commit is contained in:
parent
324c8c32e9
commit
b8b505b8f7
@ -3,9 +3,9 @@ import intl from "react-intl-universal"
|
|||||||
import { ServiceConfigsTabProps } from "../service"
|
import { ServiceConfigsTabProps } from "../service"
|
||||||
import { GReaderConfigs } from "../../../scripts/models/services/greader"
|
import { GReaderConfigs } from "../../../scripts/models/services/greader"
|
||||||
import { SyncService } from "../../../schema-types"
|
import { SyncService } from "../../../schema-types"
|
||||||
import { Stack, Icon, Label, TextField, PrimaryButton, DefaultButton, Checkbox, MessageBar, MessageBarType, Dropdown, IDropdownOption } from "@fluentui/react"
|
import { Stack, Label, TextField, PrimaryButton, DefaultButton, Checkbox,
|
||||||
|
MessageBar, MessageBarType, Dropdown, IDropdownOption, MessageBarButton } from "@fluentui/react"
|
||||||
import DangerButton from "../../utils/danger-button"
|
import DangerButton from "../../utils/danger-button"
|
||||||
import { urlTest } from "../../../scripts/utils"
|
|
||||||
|
|
||||||
type GReaderConfigsTabState = {
|
type GReaderConfigsTabState = {
|
||||||
existing: boolean
|
existing: boolean
|
||||||
@ -22,6 +22,8 @@ const endpointOptions: IDropdownOption[] = [
|
|||||||
"https://jp.inoreader.com"
|
"https://jp.inoreader.com"
|
||||||
].map(s => ({ key: s, text: s }))
|
].map(s => ({ key: s, text: s }))
|
||||||
|
|
||||||
|
const openSupport = () => window.utils.openExternal("https://github.com/yang991178/fluent-reader/wiki/Support#inoreader")
|
||||||
|
|
||||||
class InoreaderConfigsTab extends React.Component<ServiceConfigsTabProps, GReaderConfigsTabState> {
|
class InoreaderConfigsTab extends React.Component<ServiceConfigsTabProps, GReaderConfigsTabState> {
|
||||||
constructor(props: ServiceConfigsTabProps) {
|
constructor(props: ServiceConfigsTabProps) {
|
||||||
super(props)
|
super(props)
|
||||||
@ -41,8 +43,6 @@ class InoreaderConfigsTab extends React.Component<ServiceConfigsTabProps, GReade
|
|||||||
{ key: 500, text: intl.get("service.fetchLimitNum", { count: 500 }) },
|
{ key: 500, text: intl.get("service.fetchLimitNum", { count: 500 }) },
|
||||||
{ key: 750, text: intl.get("service.fetchLimitNum", { count: 750 }) },
|
{ key: 750, text: intl.get("service.fetchLimitNum", { count: 750 }) },
|
||||||
{ key: 1000, text: intl.get("service.fetchLimitNum", { count: 1000 }) },
|
{ key: 1000, text: intl.get("service.fetchLimitNum", { count: 1000 }) },
|
||||||
{ key: 1500, text: intl.get("service.fetchLimitNum", { count: 1500 }) },
|
|
||||||
{ key: Number.MAX_SAFE_INTEGER, text: intl.get("service.fetchUnlimited") },
|
|
||||||
]
|
]
|
||||||
onFetchLimitOptionChange = (_, option: IDropdownOption) => {
|
onFetchLimitOptionChange = (_, option: IDropdownOption) => {
|
||||||
this.setState({ fetchLimit: option.key as number })
|
this.setState({ fetchLimit: option.key as number })
|
||||||
@ -104,11 +104,16 @@ class InoreaderConfigsTab extends React.Component<ServiceConfigsTabProps, GReade
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
return <>
|
return <>
|
||||||
|
<MessageBar messageBarType={MessageBarType.severeWarning}
|
||||||
|
isMultiline={false}
|
||||||
|
actions={<MessageBarButton text={intl.get("rules.help")} onClick={openSupport} />}>
|
||||||
|
{intl.get("service.rateLimitWarning")}
|
||||||
|
</MessageBar>
|
||||||
{!this.state.existing && (
|
{!this.state.existing && (
|
||||||
<MessageBar messageBarType={MessageBarType.warning}>{intl.get("service.overwriteWarning")}</MessageBar>
|
<MessageBar messageBarType={MessageBarType.warning}>{intl.get("service.overwriteWarning")}</MessageBar>
|
||||||
)}
|
)}
|
||||||
<Stack horizontalAlign="center" style={{marginTop: 48}}>
|
<Stack horizontalAlign="center" style={{marginTop: 48}}>
|
||||||
<Icon iconName="Communications" style={{color: "var(--black)", transform: "rotate(220deg)", fontSize: 32, userSelect: "none"}} />
|
<svg style={{fill: "var(--black)", width: 36, userSelect: "none"}} viewBox="0 0 72 72"><path transform="translate(-1250.000000, -1834.000000)" d="M1286,1834 C1305.88225,1834 1322,1850.11775 1322,1870 C1322,1889.88225 1305.88225,1906 1286,1906 C1266.11775,1906 1250,1889.88225 1250,1870 C1250,1850.11775 1266.11775,1834 1286,1834 Z M1278.01029,1864.98015 C1270.82534,1864.98015 1265,1870.80399 1265,1877.98875 C1265,1885.17483 1270.82534,1891 1278.01029,1891 C1285.19326,1891 1291.01859,1885.17483 1291.01859,1877.98875 C1291.01859,1870.80399 1285.19326,1864.98015 1278.01029,1864.98015 Z M1281.67908,1870.54455 C1283.73609,1870.54455 1285.40427,1872.21533 1285.40427,1874.2703 C1285.40427,1876.33124 1283.73609,1877.9987 1281.67908,1877.9987 C1279.61941,1877.9987 1277.94991,1876.33124 1277.94991,1874.2703 C1277.94991,1872.21533 1279.61941,1870.54455 1281.67908,1870.54455 Z M1278.01003,1855.78714 L1278.01003,1860.47435 C1287.66605,1860.47435 1295.52584,1868.33193 1295.52584,1877.98901 L1295.52584,1877.98901 L1300.21451,1877.98901 C1300.21451,1865.74746 1290.25391,1855.78714 1278.01003,1855.78714 L1278.01003,1855.78714 Z M1278.01009,1846 L1278.01009,1850.68721 C1285.30188,1850.68721 1292.15771,1853.5278 1297.31618,1858.68479 C1302.47398,1863.84179 1305.31067,1870.69942 1305.31067,1877.98901 L1305.31067,1877.98901 L1310,1877.98901 C1310,1869.44534 1306.67162,1861.41192 1300.6293,1855.36845 C1294.58632,1849.32696 1286.55533,1846 1278.01009,1846 L1278.01009,1846 Z"></path></svg>
|
||||||
<Label style={{margin: "8px 0 36px"}}>Inoreader</Label>
|
<Label style={{margin: "8px 0 36px"}}>Inoreader</Label>
|
||||||
<Stack className="login-form" horizontal>
|
<Stack className="login-form" horizontal>
|
||||||
<Stack.Item>
|
<Stack.Item>
|
||||||
|
@ -191,6 +191,7 @@
|
|||||||
"suggest": "Suggest a new service",
|
"suggest": "Suggest a new service",
|
||||||
"overwriteWarning": "Local sources will be deleted if they exist in the service.",
|
"overwriteWarning": "Local sources will be deleted if they exist in the service.",
|
||||||
"groupsWarning": "Groups aren't automatically synced with the service.",
|
"groupsWarning": "Groups aren't automatically synced with the service.",
|
||||||
|
"rateLimitWarning": "If connection errors persist, the app may have been rate limited by the service.",
|
||||||
"endpoint": "Endpoint",
|
"endpoint": "Endpoint",
|
||||||
"username": "Username",
|
"username": "Username",
|
||||||
"password": "Password",
|
"password": "Password",
|
||||||
|
@ -189,6 +189,7 @@
|
|||||||
"suggest": "建议一项新服务",
|
"suggest": "建议一项新服务",
|
||||||
"overwriteWarning": "若本地与服务端存在URL相同的订阅源,则本地订阅源将被删除",
|
"overwriteWarning": "若本地与服务端存在URL相同的订阅源,则本地订阅源将被删除",
|
||||||
"groupsWarning": "分组不会自动与服务端保持同步",
|
"groupsWarning": "分组不会自动与服务端保持同步",
|
||||||
|
"rateLimitWarning": "若反复出现错误,则原因可能是应用被服务限流",
|
||||||
"endpoint": "端点",
|
"endpoint": "端点",
|
||||||
"username": "用户名",
|
"username": "用户名",
|
||||||
"password": "密码",
|
"password": "密码",
|
||||||
|
@ -6,7 +6,7 @@ import { ServiceConfigs, SyncService } from "../../../schema-types"
|
|||||||
import { createSourceGroup } from "../group"
|
import { createSourceGroup } from "../group"
|
||||||
import { RSSSource } from "../source"
|
import { RSSSource } from "../source"
|
||||||
import { RSSItem } from "../item"
|
import { RSSItem } from "../item"
|
||||||
import { domParser } from "../../utils"
|
import { domParser, htmlDecode } from "../../utils"
|
||||||
import { SourceRule } from "../rule"
|
import { SourceRule } from "../rule"
|
||||||
|
|
||||||
const ALL_TAG = "user/-/state/com.google/reading-list"
|
const ALL_TAG = "user/-/state/com.google/reading-list"
|
||||||
@ -156,7 +156,8 @@ export const gReaderServiceHooks: ServiceHooks = {
|
|||||||
let continuation: string
|
let continuation: string
|
||||||
do {
|
do {
|
||||||
try {
|
try {
|
||||||
let params = "/reader/api/0/stream/contents?output=json&n=125"
|
const limit = Math.min(configs.fetchLimit - items.length, 1000)
|
||||||
|
let params = `/reader/api/0/stream/contents?output=json&n=${limit}`
|
||||||
if (configs.lastFetched) params += `&ot=${configs.lastFetched}`
|
if (configs.lastFetched) params += `&ot=${configs.lastFetched}`
|
||||||
if (continuation) params += `&c=${continuation}`
|
if (continuation) params += `&c=${continuation}`
|
||||||
const response = await fetchAPI(configs, params)
|
const response = await fetchAPI(configs, params)
|
||||||
@ -164,7 +165,7 @@ export const gReaderServiceHooks: ServiceHooks = {
|
|||||||
fetchedItems = fetched.items
|
fetchedItems = fetched.items
|
||||||
for (let i of fetchedItems) {
|
for (let i of fetchedItems) {
|
||||||
i.id = compactId(i.id, configs.useInt64)
|
i.id = compactId(i.id, configs.useInt64)
|
||||||
if (i.id === configs.lastId) {
|
if (i.id === configs.lastId || items.length >= configs.fetchLimit) {
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
items.push(i)
|
items.push(i)
|
||||||
@ -174,11 +175,7 @@ export const gReaderServiceHooks: ServiceHooks = {
|
|||||||
} catch {
|
} catch {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} while (
|
} while (continuation && items.length < configs.fetchLimit)
|
||||||
continuation &&
|
|
||||||
fetchedItems && fetchedItems.length >= 125 &&
|
|
||||||
items.length < configs.fetchLimit
|
|
||||||
)
|
|
||||||
if (items.length > 0) {
|
if (items.length > 0) {
|
||||||
configs.lastId = items[0].id
|
configs.lastId = items[0].id
|
||||||
const fidMap = new Map<string, RSSSource>()
|
const fidMap = new Map<string, RSSSource>()
|
||||||
@ -212,13 +209,21 @@ export const gReaderServiceHooks: ServiceHooks = {
|
|||||||
dom.head.append(baseEl)
|
dom.head.append(baseEl)
|
||||||
let img = dom.querySelector("img")
|
let img = dom.querySelector("img")
|
||||||
if (img && img.src) item.thumb = img.src
|
if (img && img.src) item.thumb = img.src
|
||||||
|
if (configs.type == SyncService.Inoreader) item.title = htmlDecode(item.title)
|
||||||
for (let c of i.categories) {
|
for (let c of i.categories) {
|
||||||
if (!item.hasRead && c.endsWith("/state/com.google/read")) item.hasRead = true
|
if (!item.hasRead && c.endsWith("/state/com.google/read")) item.hasRead = true
|
||||||
else if (!item.starred && c.endsWith("/state/com.google/starred")) item.starred = true
|
else if (!item.starred && c.endsWith("/state/com.google/starred")) item.starred = true
|
||||||
}
|
}
|
||||||
// Apply rules and sync back to the service
|
// Apply rules and sync back to the service
|
||||||
if (source.rules) SourceRule.applyAll(source.rules, item)
|
if (source.rules) {
|
||||||
// TODO
|
const hasRead = item.hasRead
|
||||||
|
const starred = item.starred
|
||||||
|
SourceRule.applyAll(source.rules, item)
|
||||||
|
if (item.hasRead !== hasRead)
|
||||||
|
editTag(configs, item.serviceRef, READ_TAG, item.hasRead)
|
||||||
|
if (item.starred !== starred)
|
||||||
|
editTag(configs, item.serviceRef, STAR_TAG, item.starred)
|
||||||
|
}
|
||||||
parsedItems.push(item)
|
parsedItems.push(item)
|
||||||
})
|
})
|
||||||
if (parsedItems.length > 0) {
|
if (parsedItems.length > 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user