fix article switch after loading full content

This commit is contained in:
Bruce Liu 2022-06-09 14:14:33 -07:00
parent 2bba8621ac
commit efb704c597
4 changed files with 21 additions and 8 deletions

View File

@ -30,6 +30,8 @@ mac:
- nl
- ko
- ru
- pt_BR
- pt_PT
minimumSystemVersion: 10.14.0
mas:
entitlements: build/entitlements.mas.plist

View File

@ -27,6 +27,8 @@ mac:
- nl
- ko
- ru
- pt_BR
- pt_PT
win:
target:
- nsis
@ -51,6 +53,8 @@ appx:
- nl
- ko
- ru
- pt-BR
- pt-PT
showNameOnTiles: true
setBuildNumber: true
nsis:

View File

@ -328,17 +328,22 @@ class Article extends React.Component<ArticleProps, ArticleState> {
}
loadFull = async () => {
this.setState({ fullContent: "", loaded: false, error: false })
const link = this.props.item.link
try {
const result = await fetch(this.props.item.link)
const result = await fetch(link)
if (!result || !result.ok) throw new Error()
const html = await decodeFetchResponse(result, true)
this.setState({ fullContent: html })
if (link === this.props.item.link) {
this.setState({ fullContent: html })
}
} catch {
this.setState({
loaded: true,
error: true,
errorDescription: "MERCURY_PARSER_FAILURE",
})
if (link === this.props.item.link) {
this.setState({
loaded: true,
error: true,
errorDescription: "MERCURY_PARSER_FAILURE",
})
}
}
}
@ -467,7 +472,8 @@ class Article extends React.Component<ArticleProps, ArticleState> {
className={this.state.error ? "error" : ""}
key={
this.props.item._id +
(this.state.loadWebpage ? "_" : "")
(this.state.loadWebpage ? "_" : "") +
(this.state.loadFull ? "__" : "")
}
src={
this.state.loadWebpage

View File

@ -135,6 +135,7 @@ class AppTab extends React.Component<AppTabProps, AppTabState> {
{ key: "it", text: "Italiano" },
{ key: "nl", text: "Nederlands" },
{ key: "pt-BR", text: "Português do Brasil" },
{ key: "pt-PT", text: "Português de Portugal" },
{ key: "fi-FI", text: "Suomi" },
{ key: "sv", text: "Svenska" },
{ key: "tr", text: "Türkçe" },