import spacepack from "@moonlight-mod/wp/spacepack_spacepack"; import { MoonbaseSettingsStore } from "@moonlight-mod/wp/moonbase_stores"; import Notices from "@moonlight-mod/wp/notices_notices"; import { MoonlightBranch } from "@moonlight-mod/types"; import React from "@moonlight-mod/wp/react"; import * as Components from "@moonlight-mod/wp/discord/components/common/index"; // FIXME: not indexed as importable const Constants = spacepack.require("discord/Constants"); const UserSettingsSections = spacepack.findObjectFromKey( Constants, "APPEARANCE_THEME_PICKER" ); const { ThemeDarkIcon } = Components; function plural(str: string, num: number) { return `${str}${num > 1 ? "s" : ""}`; } function listener() { if ( MoonbaseSettingsStore.shouldShowNotice && MoonbaseSettingsStore.getExtensionConfigRaw( "moonbase", "updateBanner", true ) ) { // @ts-expect-error epic type fail MoonbaseSettingsStore.removeChangeListener(listener); const version = MoonbaseSettingsStore.newVersion; const extensionUpdateCount = Object.keys( MoonbaseSettingsStore.updates ).length; const hasExtensionUpdates = extensionUpdateCount > 0; let message; if (version != null) { message = moonlightNode.branch === MoonlightBranch.NIGHTLY ? `A new version of moonlight is available` : `moonlight ${version} is available`; } if (hasExtensionUpdates) { let concat = false; if (message == null) { message = ""; } else { concat = true; message += ", and "; } message += `${extensionUpdateCount} ${concat ? "" : "moonlight "}${plural( "extension", extensionUpdateCount )} can be updated`; } if (message != null) message += "."; Notices.addNotice({ element: (