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 - nl
- ko - ko
- ru - ru
- pt_BR
- pt_PT
minimumSystemVersion: 10.14.0 minimumSystemVersion: 10.14.0
mas: mas:
entitlements: build/entitlements.mas.plist entitlements: build/entitlements.mas.plist

View File

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

View File

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

View File

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