diff --git a/src/config/constants.js b/src/config/constants.js
index f69cb60b..b7d266d7 100644
--- a/src/config/constants.js
+++ b/src/config/constants.js
@@ -8,7 +8,6 @@ export const OPENSTREETMAP_URL = 'https://www.openstreetmap.org';
// Mue URLs
export const WEBSITE_URL = 'https://muetab.com';
export const PRIVACY_URL = 'https://muetab.com/privacy';
-export const BLOG_POST = 'https://blog.muetab.com/posts/version-7-0';
export const TRANSLATIONS_URL = 'https://docs.muetab.com/translations/';
export const WEBLATE_URL = 'https://hosted.weblate.org/projects/mue/mue-tab/';
export const REPORT_ITEM =
diff --git a/src/features/misc/sections/About.jsx b/src/features/misc/sections/About.jsx
index eb5c78b8..ecc08de4 100644
--- a/src/features/misc/sections/About.jsx
+++ b/src/features/misc/sections/About.jsx
@@ -131,7 +131,7 @@ class About extends PureComponent {
diff --git a/src/features/misc/sections/Changelog.jsx b/src/features/misc/sections/Changelog.jsx
index 0718dd18..260b694e 100644
--- a/src/features/misc/sections/Changelog.jsx
+++ b/src/features/misc/sections/Changelog.jsx
@@ -18,10 +18,36 @@ class Changelog extends PureComponent {
this.changelog = createRef();
}
+ parseMarkdown = (text) => {
+ text = text.replace(/^\* /gm, '
').replace(/\n/g, '');
+ text = text.replace(/\*\*(.*?)\*\*/g, '
$1');
+ text = text.replace(/^## (.*$)/gm, '
$1
');
+ text = text.replace(
+ /((http|https):\/\/[^\s]+)/g,
+ '
$1',
+ );
+
+ return text;
+ }
+
async getUpdate() {
- const res = await fetch(variables.constants.BLOG_POST + '/index.json', {
- signal: this.controller.signal,
- });
+ const releases = await fetch(
+ `https://api.github.com/repos/${variables.constants.ORG_NAME}/${variables.constants.REPO_NAME}/releases`,
+ {
+ signal: this.controller.signal,
+ },
+ );
+
+ // get the release which tag_name is the same as the current version
+ const data = await releases.json();
+ const release = data.find((release) => release.tag_name === `7.0.0`);
+
+ if (this.controller.signal.aborted === true) {
+ return;
+ }
+
+ // request the changelog
+ const res = await fetch(release.url, { signal: this.controller.signal });
if (res.status === 404) {
this.setState({ error: true });
@@ -32,43 +58,12 @@ class Changelog extends PureComponent {
return;
}
- const data = await res.json();
- let date = new Date(data.date.split(' ')[0]);
- date = date.toLocaleDateString(variables.languagecode.replace('_', '-'), {
- year: 'numeric',
- month: 'long',
- day: 'numeric',
- });
-
+ const changelog = await res.json();
this.setState({
- title: data.title,
- date,
- image: data.featured_image || null,
- author: variables.getMessage('modals.main.settings.sections.changelog.by', {
- author: data.authors.join(', '),
- }),
- content: data.markdown,
+ title: changelog.name,
+ content: this.parseMarkdown(changelog.body),
+ date: new Date(changelog.published_at).toLocaleDateString(),
});
-
- // lightbox etc
- const images = this.changelog.current.getElementsByTagName('img');
- const links = this.changelog.current.getElementsByTagName('a');
-
- for (const img of images) {
- img.draggable = false;
- img.onclick = () => {
- this.setState({
- showLightbox: true,
- lightboxImg: img.src,
- });
- };
- }
-
- // open in new tab
- for (let link = 0; link < links.length; link++) {
- links[link].target = '_blank';
- links[link].rel = 'noopener noreferrer';
- }
}
componentDidMount() {
@@ -129,9 +124,7 @@ class Changelog extends PureComponent {
return (
{this.state.title}
-
- {this.state.author} • {this.state.date}
-
+
Released on {this.state.date}
{this.state.image && (
)}
-
{this.state.content}
+
this.setState({ showLightbox: false })}