native define
This commit is contained in:
parent
d5c6c4d92b
commit
e54678219e
6 changed files with 11 additions and 12 deletions
|
|
@ -95,7 +95,7 @@
|
|||
"typescript-transform-paths": "^3.5.5",
|
||||
"zip-local": "^0.3.5"
|
||||
},
|
||||
"packageManager": "pnpm@10.29.2",
|
||||
"packageManager": "pnpm@10.30.3",
|
||||
"pnpm": {
|
||||
"patchedDependencies": {
|
||||
"@types/less@3.0.8": "patches/@types__less@3.0.8.patch"
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import definePlugin, { OptionType } from "@utils/types";
|
|||
|
||||
import { useAuthorizationStore } from "./lib/stores/AuthorizationStore";
|
||||
import { useSongStore } from "./lib/stores/SongStore";
|
||||
import { clearCache } from "./service";
|
||||
import { Native } from "./service";
|
||||
import Settings from "./ui/settings";
|
||||
import ProfileSongs from "./ui/songs/ProfileSongs";
|
||||
import WidgetSongs from "./ui/songs/WidgetSongs";
|
||||
|
|
@ -80,7 +80,7 @@ export default definePlugin({
|
|||
// only gets cleared on full restart. we don't want that since
|
||||
// audio preview URLs expire very fast, so we just clear it on
|
||||
// plugin restart instead
|
||||
clearCache();
|
||||
Native.clearCache();
|
||||
|
||||
useSongStore.getState().$refresh();
|
||||
useAuthorizationStore.persist.rehydrate();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ export function useRender(song: Song) {
|
|||
useEffect(() => {
|
||||
setFailed(false);
|
||||
setRender(null);
|
||||
renderSong(song)
|
||||
Native.renderSong(song)
|
||||
.catch(() => null)
|
||||
.then(info => info ? setRender(info) : setFailed(true));
|
||||
}, [sid(song)]);
|
||||
|
|
@ -25,5 +25,4 @@ export function useRender(song: Song) {
|
|||
return { failed, render };
|
||||
}
|
||||
|
||||
export const { parseLink, renderSong, validateSong, clearCache } = VencordNative.pluginHelpers
|
||||
.SongSpotlight as PluginNative<typeof import("./native")>;
|
||||
export const Native = VencordNative.pluginHelpers.SongSpotlight as PluginNative<typeof import("./native")>;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
|||
import { Flex } from "@components/Flex";
|
||||
import { PlusIcon } from "@components/Icons";
|
||||
import { cl, logger } from "@equicordplugins/songSpotlight.desktop/lib/utils";
|
||||
import { parseLink } from "@equicordplugins/songSpotlight.desktop/service";
|
||||
import { Native } from "@equicordplugins/songSpotlight.desktop/service";
|
||||
import { parsers } from "@song-spotlight/api/handlers";
|
||||
import { Song } from "@song-spotlight/api/structs";
|
||||
import { closeModal, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, openModal } from "@utils/modal";
|
||||
|
|
@ -60,7 +60,7 @@ function AddSongModal({ modalProps, close, onAdd }: AddSongModalProps) {
|
|||
onClick={async () => {
|
||||
setPending(true);
|
||||
try {
|
||||
const parsed = await parseLink(url);
|
||||
const parsed = await Native.parseLink(url);
|
||||
if (!parsed) {
|
||||
setError("Invalid link");
|
||||
return setPending(false);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import { presentOAuth2Modal } from "@equicordplugins/songSpotlight.desktop/lib/o
|
|||
import { useAuthorizationStore } from "@equicordplugins/songSpotlight.desktop/lib/stores/AuthorizationStore";
|
||||
import { useSongStore } from "@equicordplugins/songSpotlight.desktop/lib/stores/SongStore";
|
||||
import { cl } from "@equicordplugins/songSpotlight.desktop/lib/utils";
|
||||
import { validateSong } from "@equicordplugins/songSpotlight.desktop/service";
|
||||
import { Native } from "@equicordplugins/songSpotlight.desktop/service";
|
||||
import { Spinner } from "@equicordplugins/songSpotlight.desktop/ui/common";
|
||||
import SongList from "@equicordplugins/songSpotlight.desktop/ui/settings/SongList";
|
||||
import { UserData, UserDataSchema } from "@song-spotlight/api/structs";
|
||||
|
|
@ -48,7 +48,7 @@ function ImportButton({ overwrite, pending, setPending, onImport }: ImportButton
|
|||
return showToast("Invalid Song Spotlight data in clipboard!", Toasts.Type.FAILURE);
|
||||
}
|
||||
|
||||
const validated = await Promise.allSettled(data.map(song => validateSong(song)));
|
||||
const validated = await Promise.allSettled(data.map(song => Native.validateSong(song)));
|
||||
if (!validated.every(x => x.status === "fulfilled" && x.value)) {
|
||||
setPending(false);
|
||||
return showToast("One or more imported songs were invalid.", Toasts.Type.FAILURE);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import { Link } from "@components/Link";
|
|||
import { apiConstants } from "@equicordplugins/songSpotlight.desktop/lib/api";
|
||||
import { useSongStore } from "@equicordplugins/songSpotlight.desktop/lib/stores/SongStore";
|
||||
import { cl, formatCoverTooltip, formatDurationMs } from "@equicordplugins/songSpotlight.desktop/lib/utils";
|
||||
import { parseLink, useRender } from "@equicordplugins/songSpotlight.desktop/service";
|
||||
import { Native, useRender } from "@equicordplugins/songSpotlight.desktop/service";
|
||||
import {
|
||||
CardClasses,
|
||||
ExplicitTag,
|
||||
|
|
@ -84,7 +84,7 @@ function SongEntry({ entry, number, isLoaded, isPlaying, big, onClick }: SongEnt
|
|||
return showToast("You don't have enough space!");
|
||||
}
|
||||
|
||||
const song = await parseLink(entry.link);
|
||||
const song = await Native.parseLink(entry.link);
|
||||
if (!song) {
|
||||
return showToast("Uh oh, this song doesn't exist!", Toasts.Type.FAILURE);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue