From efb704c597e344c3485497ce696e05b65a292e29 Mon Sep 17 00:00:00 2001 From: Bruce Liu Date: Thu, 9 Jun 2022 14:14:33 -0700 Subject: [PATCH] fix article switch after loading full content --- electron-builder-mas.yml | 2 ++ electron-builder.yml | 4 ++++ src/components/article.tsx | 22 ++++++++++++++-------- src/components/settings/app.tsx | 1 + 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/electron-builder-mas.yml b/electron-builder-mas.yml index 6a2ee24..0390607 100644 --- a/electron-builder-mas.yml +++ b/electron-builder-mas.yml @@ -30,6 +30,8 @@ mac: - nl - ko - ru + - pt_BR + - pt_PT minimumSystemVersion: 10.14.0 mas: entitlements: build/entitlements.mas.plist diff --git a/electron-builder.yml b/electron-builder.yml index dff5552..ee8e1a9 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -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: diff --git a/src/components/article.tsx b/src/components/article.tsx index 1543458..18a640a 100644 --- a/src/components/article.tsx +++ b/src/components/article.tsx @@ -328,17 +328,22 @@ class Article extends React.Component { } 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 { className={this.state.error ? "error" : ""} key={ this.props.item._id + - (this.state.loadWebpage ? "_" : "") + (this.state.loadWebpage ? "_" : "") + + (this.state.loadFull ? "__" : "") } src={ this.state.loadWebpage diff --git a/src/components/settings/app.tsx b/src/components/settings/app.tsx index 9ceec93..5afaf81 100644 --- a/src/components/settings/app.tsx +++ b/src/components/settings/app.tsx @@ -135,6 +135,7 @@ class AppTab extends React.Component { { 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" },