Skip to content

Commit

Permalink
Install embed fixes (#539)
Browse files Browse the repository at this point in the history
* Do not show embeds for non-store addons

* Fix cache for failed to fetch addons
  • Loading branch information
asportnoy authored Aug 23, 2023
1 parent bf451ac commit a62d3b0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/renderer/coremods/installer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ async function injectLinks(): Promise<void> {
if (!match) return null;
const installLink = parseInstallLink(match[1]);
if (!installLink) return null;
if (installLink.source !== "store") return null;
if (!generalSettings.get("addonEmbeds")) return null;
return match;
},
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/coremods/installer/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type InstallerSource = (typeof INSTALLER_SOURCES)[number];

const CACHE_INTERVAL = 1000 * 60 * 60;

const cache: Map<string, { data: CheckResultSuccess; expires: Date }> = new Map();
const cache: Map<string, { data: CheckResultSuccess | null; expires: Date }> = new Map();

export function isValidSource(type: string): type is InstallerSource {
// @ts-expect-error Doesn't matter that it might not be a valid type
Expand All @@ -40,6 +40,10 @@ export async function getInfo(
const info = await RepluggedNative.installer.getInfo(source, identifier, id);
if (!info.success) {
logger.error(`Failed to get info for ${identifier}: ${info.error}`);
cache.set(cacheIdentifier, {
data: null,
expires: new Date(Date.now() + CACHE_INTERVAL),
});
return null;
}
if (info.manifest.type === "replugged") {
Expand Down

0 comments on commit a62d3b0

Please sign in to comment.