2023-07-09 08:50:00 +08:00
|
|
|
import { FluxDispatcher } from "@vendetta/metro/common";
|
|
|
|
|
|
2023-07-18 23:58:27 +08:00
|
|
|
import { pluginState } from "..";
|
2023-07-09 08:50:00 +08:00
|
|
|
import { Activity } from "../../../defs";
|
|
|
|
|
import Constants from "../constants";
|
2023-07-18 23:58:27 +08:00
|
|
|
import { flush } from "../manager";
|
2023-07-09 08:50:00 +08:00
|
|
|
import { AssetManager } from "../modules";
|
|
|
|
|
|
|
|
|
|
/** Clears the user's activity */
|
|
|
|
|
export function clearActivity() {
|
|
|
|
|
return sendRequest(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Sends the activity details to Discord */
|
|
|
|
|
export function sendRequest(activity: Activity) {
|
|
|
|
|
if (pluginState.pluginStopped) {
|
2023-07-18 23:58:27 +08:00
|
|
|
flush(true);
|
2023-07-09 08:50:00 +08:00
|
|
|
activity = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pluginState.lastActivity = activity;
|
|
|
|
|
|
|
|
|
|
FluxDispatcher.dispatch({
|
|
|
|
|
type: "LOCAL_ACTIVITY_UPDATE",
|
|
|
|
|
activity: activity,
|
|
|
|
|
pid: 2312,
|
|
|
|
|
socketId: "Last.fm@Vendetta"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Fetches a Discord application's asset */
|
|
|
|
|
export async function fetchAsset(asset: string[], appId: string = Constants.APPLICATION_ID): Promise<string[]> {
|
|
|
|
|
if (!asset) return [];
|
|
|
|
|
|
|
|
|
|
return await AssetManager.fetchAssetIds(appId, asset);
|
|
|
|
|
}
|