Skip to content

Commit

Permalink
fix: apply biome fixes (#761)
Browse files Browse the repository at this point in the history
  • Loading branch information
afonsojramos authored May 21, 2024
1 parent 5032c0c commit 87b0d27
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 98 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@
"semver": "^7.6.0"
},
"private": true
}
}
112 changes: 46 additions & 66 deletions src/components/Modals/Update/index.tsx
Original file line number Diff line number Diff line change
@@ -1,81 +1,61 @@
import { t } from "i18next";
import React from "react";

import {
LATEST_RELEASE_URL,
MARKETPLACE_VERSION,
RELEASES_URL,
} from "../../../constants";
import { LATEST_RELEASE_URL, MARKETPLACE_VERSION, RELEASES_URL } from "../../../constants";
import { getMarkdownHTML } from "../../../logic/Utils";

async function fetchLatestReleaseInfo(): Promise<{
version: string;
changelog: string | null;
version: string;
changelog: string | null;
} | null> {
try {
const result = await fetch(LATEST_RELEASE_URL);
const resultJson = await result.json();
const { body, tag_name, message } = resultJson;
return body && tag_name && !message
? {
version: tag_name.replace("v", ""),
changelog: await getMarkdownHTML(
body.match(/## What's Changed([\s\S]*?)(\r\n\r|\n\n##)/)[1],
"spicetify",
"marketplace",
),
}
: null;
} catch (error) {
console.error(error);
return null;
}
try {
const result = await fetch(LATEST_RELEASE_URL);
const resultJson = await result.json();
const { body, tag_name, message } = resultJson;
return body && tag_name && !message
? {
version: tag_name.replace("v", ""),
changelog: await getMarkdownHTML(body.match(/## What's Changed([\s\S]*?)(\r\n\r|\n\n##)/)[1], "spicetify", "marketplace")
}
: null;
} catch (error) {
console.error(error);
return null;
}
}

function UpdateModal(): React.ReactElement {
const [releaseInfo, setReleaseInfo] = React.useState<{
version: string;
changelog: string | null;
} | null>(null);
const [releaseInfo, setReleaseInfo] = React.useState<{
version: string;
changelog: string | null;
} | null>(null);

React.useEffect(() => {
fetchLatestReleaseInfo().then((releaseInfo) => setReleaseInfo(releaseInfo));
}, []);
React.useEffect(() => {
fetchLatestReleaseInfo().then((releaseInfo) => setReleaseInfo(releaseInfo));
}, []);

return (
<div id="marketplace-update-container">
<div id="marketplace-update-description">
<h4>{t("updateModal.description")}</h4>
<a href={`${RELEASES_URL}/tag/v${MARKETPLACE_VERSION}`}>
{t("updateModal.currentVersion", { version: MARKETPLACE_VERSION })}
</a>
<a href={`${RELEASES_URL}/tag/v${releaseInfo?.version}`}>
{t("updateModal.latestVersion", { version: releaseInfo?.version })}
</a>
</div>
<hr />
<div id="marketplace-update-whats-changed">
<h3 className="marketplace-update-header">
{t("updateModal.whatsChanged")}
</h3>
<details>
<summary>{t("updateModal.seeChangelog")}</summary>
<ul
dangerouslySetInnerHTML={{ __html: releaseInfo?.changelog ?? "" }}
/>
</details>
</div>
<hr />
<div id="marketplace-update-guide">
<h3 className="marketplace-update-header">
{t("updateModal.howToUpgrade")}
</h3>
<a href="https://github.com/spicetify/marketplace/wiki/Installation">
{t("updateModal.viewGuide")}
</a>
</div>
</div>
);
return (
<div id="marketplace-update-container">
<div id="marketplace-update-description">
<h4>{t("updateModal.description")}</h4>
<a href={`${RELEASES_URL}/tag/v${MARKETPLACE_VERSION}`}>{t("updateModal.currentVersion", { version: MARKETPLACE_VERSION })}</a>
<a href={`${RELEASES_URL}/tag/v${releaseInfo?.version}`}>{t("updateModal.latestVersion", { version: releaseInfo?.version })}</a>
</div>
<hr />
<div id="marketplace-update-whats-changed">
<h3 className="marketplace-update-header">{t("updateModal.whatsChanged")}</h3>
<details>
<summary>{t("updateModal.seeChangelog")}</summary>
<ul dangerouslySetInnerHTML={{ __html: releaseInfo?.changelog ?? "" }} />
</details>
</div>
<hr />
<div id="marketplace-update-guide">
<h3 className="marketplace-update-header">{t("updateModal.howToUpgrade")}</h3>
<a href="https://github.com/spicetify/marketplace/wiki/Installation">{t("updateModal.viewGuide")}</a>
</div>
</div>
);
}

export default UpdateModal;
50 changes: 23 additions & 27 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
import { version } from "../package.json";
import { TabItemConfig } from "./types/marketplace-types";
import type { TabItemConfig } from "./types/marketplace-types";

export const MARKETPLACE_VERSION = version;

const STORAGE_KEY_PREFIX = "marketplace";
export const LOCALSTORAGE_KEYS = {
installedExtensions: `${STORAGE_KEY_PREFIX}:installed-extensions`,
installedSnippets: `${STORAGE_KEY_PREFIX}:installed-snippets`,
installedThemes: `${STORAGE_KEY_PREFIX}:installed-themes`,
activeTab: `${STORAGE_KEY_PREFIX}:active-tab`,
tabs: `${STORAGE_KEY_PREFIX}:tabs`,
sort: `${STORAGE_KEY_PREFIX}:sort`,
// Theme installed store the localsorage key of the theme (e.g. marketplace:installed:NYRI4/Comfy-spicetify/user.css)
themeInstalled: `${STORAGE_KEY_PREFIX}:theme-installed`,
localTheme: `${STORAGE_KEY_PREFIX}:local-theme`,
albumArtBasedColor: `${STORAGE_KEY_PREFIX}:albumArtBasedColors`,
albumArtBasedColorMode: `${STORAGE_KEY_PREFIX}:albumArtBasedColorsMode`,
albumArtBasedColorVibrancy: `${STORAGE_KEY_PREFIX}:albumArtBasedColorsVibrancy`,
colorShift: `${STORAGE_KEY_PREFIX}:colorShift`,
installedExtensions: `${STORAGE_KEY_PREFIX}:installed-extensions`,
installedSnippets: `${STORAGE_KEY_PREFIX}:installed-snippets`,
installedThemes: `${STORAGE_KEY_PREFIX}:installed-themes`,
activeTab: `${STORAGE_KEY_PREFIX}:active-tab`,
tabs: `${STORAGE_KEY_PREFIX}:tabs`,
sort: `${STORAGE_KEY_PREFIX}:sort`,
// Theme installed store the localsorage key of the theme (e.g. marketplace:installed:NYRI4/Comfy-spicetify/user.css)
themeInstalled: `${STORAGE_KEY_PREFIX}:theme-installed`,
localTheme: `${STORAGE_KEY_PREFIX}:local-theme`,
albumArtBasedColor: `${STORAGE_KEY_PREFIX}:albumArtBasedColors`,
albumArtBasedColorMode: `${STORAGE_KEY_PREFIX}:albumArtBasedColorsMode`,
albumArtBasedColorVibrancy: `${STORAGE_KEY_PREFIX}:albumArtBasedColorsVibrancy`,
colorShift: `${STORAGE_KEY_PREFIX}:colorShift`
};

// Initalize topbar tabs
// Data initalized in TabBar.js
export const ALL_TABS: TabItemConfig[] = [
{ name: "Extensions", enabled: true },
{ name: "Themes", enabled: true },
{ name: "Snippets", enabled: true },
{ name: "Apps", enabled: true },
{ name: "Installed", enabled: true },
{ name: "Extensions", enabled: true },
{ name: "Themes", enabled: true },
{ name: "Snippets", enabled: true },
{ name: "Apps", enabled: true },
{ name: "Installed", enabled: true }
];

// Max GitHub API items per page
Expand All @@ -39,16 +39,12 @@ export const CUSTOM_APP_PATH = "/marketplace";
// Used in Card.tsx
export const MAX_TAGS = 4;

export const SNIPPETS_PAGE_URL =
"https://github.com/spicetify/marketplace/blob/main/src/resources/snippets.ts";
export const SNIPPETS_PAGE_URL = "https://github.com/spicetify/marketplace/blob/main/src/resources/snippets.ts";

export const SNIPPETS_URL =
"https://raw.githubusercontent.com/spicetify/marketplace/main/resources/snippets.json";
export const SNIPPETS_URL = "https://raw.githubusercontent.com/spicetify/marketplace/main/resources/snippets.json";

export const BLACKLIST_URL =
"https://raw.githubusercontent.com/spicetify/marketplace/main/resources/blacklist.json";
export const BLACKLIST_URL = "https://raw.githubusercontent.com/spicetify/marketplace/main/resources/blacklist.json";

export const RELEASES_URL = "https://github.com/spicetify/marketplace/releases";

export const LATEST_RELEASE_URL =
"https://api.github.com/repos/spicetify/marketplace/releases/latest";
export const LATEST_RELEASE_URL = "https://api.github.com/repos/spicetify/marketplace/releases/latest";
6 changes: 2 additions & 4 deletions src/logic/FetchRemotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,8 @@ export const fetchCssSnippets = async () => {

// Because the card component looks for an imageURL prop
if (snip.preview) {
snip.imageURL = snip.preview.startsWith("http")
? snip.preview
: `https://raw.githubusercontent.com/spicetify/marketplace/main/${snip.preview}`;
delete snip.preview;
snip.imageURL = snip.preview.startsWith("http") ? snip.preview : `https://raw.githubusercontent.com/spicetify/marketplace/main/${snip.preview}`;
snip.preview = undefined;
}

accum.push(snip);
Expand Down

0 comments on commit 87b0d27

Please sign in to comment.