Last.fm: GAHH

This commit is contained in:
amsyarasyiq 2023-04-05 17:43:33 +08:00
parent e9ddf54298
commit 9964b31626
5 changed files with 30 additions and 38 deletions

View file

@ -34,7 +34,7 @@ function UpdateButton() {
}
export default function Settings() {
const settings = useProxy(storage) as PluginSettings;
const settings = useProxy(storage) as LFMSettings;
const navigation = NavigationNative.useNavigation();
useEffect(() => {

View file

@ -13,7 +13,7 @@ export const global = {} as {
};
plugin.storage.ignoreSpotify ??= true;
export const currentSettings = { ...plugin.storage } as PluginSettings;
export const currentSettings = { ...plugin.storage } as LFMSettings;
// Discord modules that we need
export const UserStore = findByStoreName("UserStore");

View file

@ -1,36 +0,0 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
type PluginSettings = {
/** Application's name */
appName: string;
/** User's last.fm username */
username: string;
/** Whether or not to show the timestamp */
showTimestamp: boolean;
/** The time interval between each update */
timeInterval: number;
/** Whether or not to show "Listening to" */
listeningTo: boolean;
/** Ignore when Spotify is running */
ignoreSpotify: boolean;
/** Whether or not to show verbose logging */
verboseLogging: boolean;
};
enum ActivityType {
PLAYING = 0,
STREAMING = 1,
LISTENING = 2,
COMPETING = 5
}
// Last.fm track
type Track = {
name: string;
artist: string;
album: string;
albumArt: string;
url: string;
date: string;
nowPlaying: boolean;
loved: boolean;
}

View file

@ -8,6 +8,13 @@ import Constants from "./constants";
const AssetManager = findByProps("getAssetIds");
const PresenceStore = findByStoreName("PresenceStore");
enum ActivityType {
PLAYING = 0,
STREAMING = 1,
LISTENING = 2,
COMPETING = 5
}
/** Fetches the latest user's scrobble */
async function fetchLatestScrobble(): Promise<Track> {
const params = new URLSearchParams({

21
plugins/defs.d.ts vendored
View file

@ -24,3 +24,24 @@ type ActivityAssets = {
small_image?: string;
small_text?: string;
};
type LFMSettings = {
appName: string;
username: string;
showTimestamp: boolean;
timeInterval: number;
listeningTo: boolean;
ignoreSpotify: boolean;
verboseLogging: boolean;
};
type Track = {
name: string;
artist: string;
album: string;
albumArt: string;
url: string;
date: string;
nowPlaying: boolean;
loved: boolean;
}