From 1338d254cf2c22618a5919ca5db3297a2bcd3962 Mon Sep 17 00:00:00 2001 From: David Ralph Date: Fri, 7 Jun 2024 20:45:55 +0100 Subject: [PATCH] fix: apps settings showing by default, changelog formatting --- .../settings/modules/tabs/_changelog.scss | 4 +++ src/features/misc/sections/Changelog.jsx | 31 ++++++++++++------- src/features/navbar/options/AppsOptions.jsx | 2 +- src/features/navbar/options/NavbarOptions.jsx | 2 +- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/components/Elements/MainModal/scss/settings/modules/tabs/_changelog.scss b/src/components/Elements/MainModal/scss/settings/modules/tabs/_changelog.scss index 84ad67fa..c448cb04 100644 --- a/src/components/Elements/MainModal/scss/settings/modules/tabs/_changelog.scss +++ b/src/components/Elements/MainModal/scss/settings/modules/tabs/_changelog.scss @@ -21,4 +21,8 @@ img { max-width: 95%; } + + .changelogAt { + text-decoration: none; + } } diff --git a/src/features/misc/sections/Changelog.jsx b/src/features/misc/sections/Changelog.jsx index fbc02762..8a51f954 100644 --- a/src/features/misc/sections/Changelog.jsx +++ b/src/features/misc/sections/Changelog.jsx @@ -23,21 +23,26 @@ class Changelog extends PureComponent { throw new Error('Input must be a string'); } - // Replace list items - text = text.replace(/^\* (.*$)/gm, '
  • $1
  • '); - - // Wrap list items in - text = text.replace(/((
  • .*<\/li>\s*)+)/g, ''); - - // Replace other markdown syntax + // Replace markdown syntax text = text .replace(/\*\*(.*?)\*\*/g, '$1') .replace(/^## (.*$)/gm, '$1') .replace( /((http|https):\/\/[^\s]+)/g, '$1', + ) + // resolve @ to github user link + .replace( + /@([a-zA-Z0-9-_]+)/g, + '@$1', ); + // Replace list items + text = text.replace(/^\* (.*$)/gm, '
  • $1
  • '); + + // Wrap list items in + text = text.replace(/((
  • .*<\/li>\s*)+)/g, ''); + return text; }; @@ -49,14 +54,18 @@ class Changelog extends PureComponent { }, ); - // 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 === variables.constants.VERSION); - if (this.controller.signal.aborted === true) { return; } + // get the release which tag_name is the same as the current version + const data = await releases.json(); + let release = data.find((release) => release.tag_name === variables.constants.VERSION); + + if (!release) { + release = data[0]; + } + // request the changelog const res = await fetch(release.url, { signal: this.controller.signal }); diff --git a/src/features/navbar/options/AppsOptions.jsx b/src/features/navbar/options/AppsOptions.jsx index e6821356..4a014ea6 100644 --- a/src/features/navbar/options/AppsOptions.jsx +++ b/src/features/navbar/options/AppsOptions.jsx @@ -1,6 +1,6 @@ import variables from 'config/variables'; -import { useState, memo } from 'react'; +import { useState } from 'react'; import Modal from 'react-modal'; import { MdAddLink } from 'react-icons/md'; diff --git a/src/features/navbar/options/NavbarOptions.jsx b/src/features/navbar/options/NavbarOptions.jsx index 29922c87..7c66d586 100644 --- a/src/features/navbar/options/NavbarOptions.jsx +++ b/src/features/navbar/options/NavbarOptions.jsx @@ -16,7 +16,7 @@ function NavbarOptions() { const [showRefreshOptions, setShowRefreshOptions] = useState( localStorage.getItem('refresh') === 'true', ); - const [appsEnabled, setAppsEnabled] = useState(localStorage.getItem('appsEnabled') === 'true'); + const [appsEnabled, setAppsEnabled] = useState(localStorage.getItem('appsEnabled') === 'true' || false); const NAVBAR_SECTION = 'modals.main.settings.sections.appearance.navbar';