Move Activity Types
This commit is contained in:
parent
86e9422bb4
commit
f84aa0c92c
10 changed files with 34 additions and 145 deletions
|
|
@ -78,11 +78,3 @@ export interface ActivityViewProps {
|
|||
application?: Application;
|
||||
currentUser: User;
|
||||
}
|
||||
|
||||
export const enum ActivityType {
|
||||
PLAYING = 0,
|
||||
STREAMING = 1,
|
||||
LISTENING = 2,
|
||||
WATCHING = 3,
|
||||
COMPETING = 5
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ export function getApplicationIcons(activities: Activity[], preferSmall = false)
|
|||
|
||||
for (const activity of applications) {
|
||||
const { assets, application_id, platform, id } = activity;
|
||||
if (!application_id && !platform && !id.startsWith("spotify:")) continue;
|
||||
if (!application_id && !platform && !id?.startsWith("spotify:")) continue;
|
||||
|
||||
if (assets) {
|
||||
const { small_image, small_text, large_image, large_text } = assets;
|
||||
|
|
|
|||
|
|
@ -7,9 +7,10 @@
|
|||
import { definePluginSettings } from "@api/Settings";
|
||||
import { Devs, EquicordDevs } from "@utils/constants";
|
||||
import definePlugin, { OptionType, PluginNative, ReporterTestable } from "@utils/types";
|
||||
import { Activity } from "@vencord/discord-types";
|
||||
import { ActivityFlags, ActivityType } from "@vencord/discord-types/enums";
|
||||
import { ApplicationAssetUtils, FluxDispatcher, Forms } from "@webpack/common";
|
||||
|
||||
import { Activity, ActivityFlag, ActivityType } from "./types";
|
||||
|
||||
const Native = VencordNative.pluginHelpers.GensokyoRadioRPC as PluginNative<typeof import("./native")>;
|
||||
|
||||
|
|
@ -96,7 +97,7 @@ export default definePlugin({
|
|||
metadata: { button_urls: undefined },
|
||||
|
||||
type: ActivityType.LISTENING,
|
||||
flags: ActivityFlag.INSTANCE,
|
||||
flags: ActivityFlags.INSTANCE,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -36,15 +36,6 @@ export interface ActivityAssets {
|
|||
small_text?: string;
|
||||
}
|
||||
|
||||
export const enum ActivityType {
|
||||
PLAYING = 0,
|
||||
LISTENING = 2,
|
||||
}
|
||||
|
||||
export const enum ActivityFlag {
|
||||
INSTANCE = 1 << 0
|
||||
}
|
||||
|
||||
export interface TrackData {
|
||||
title: string;
|
||||
album: string;
|
||||
|
|
|
|||
|
|
@ -7,9 +7,11 @@
|
|||
import { CheckedTextInput } from "@components/CheckedTextInput";
|
||||
import { Margins } from "@utils/margins";
|
||||
import { identity } from "@utils/misc";
|
||||
import { Activity } from "@vencord/discord-types";
|
||||
import { ActivityFlags, ActivityType } from "@vencord/discord-types/enums";
|
||||
import { Card, Forms, PresenceStore, React, Select, SnowflakeUtils, Switch, TextInput, UserStore } from "@webpack/common";
|
||||
|
||||
import { Activity, ActivityType, AppIdSetting, makeEmptyAppId } from ".";
|
||||
import { AppIdSetting, makeEmptyAppId } from ".";
|
||||
|
||||
interface SettingsProps {
|
||||
appIds: AppIdSetting[];
|
||||
|
|
@ -28,7 +30,14 @@ export function ReplaceTutorial() {
|
|||
<>
|
||||
<Forms.FormTitle tag="h3">IDs of currently running activities</Forms.FormTitle>
|
||||
{
|
||||
activities.length === 0 ? <Forms.FormText>No running activities</Forms.FormText> : activities.map(activity => { return activity.flags !== 48 ? <Forms.FormText>{activity.name}: {activity.application_id}</Forms.FormText> : null; /* hide spotify */ })
|
||||
activities.length === 0
|
||||
? <Forms.FormText>No running activities</Forms.FormText>
|
||||
: activities.map(activity => {
|
||||
const isSpotify = (activity.flags & (ActivityFlags.SYNC | ActivityFlags.PLAY)) === (ActivityFlags.SYNC | ActivityFlags.PLAY);
|
||||
return !isSpotify
|
||||
? <Forms.FormText>{activity.name}: {activity.application_id}</Forms.FormText>
|
||||
: null;
|
||||
})
|
||||
}
|
||||
<Forms.FormTitle tag="h3" className={Margins.top8}>Available variables</Forms.FormTitle>
|
||||
<Forms.FormText>
|
||||
|
|
|
|||
|
|
@ -9,11 +9,14 @@ import { definePluginSettings } from "@api/Settings";
|
|||
import { Devs } from "@utils/constants";
|
||||
import { useForceUpdater } from "@utils/react";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { Activity } from "@vencord/discord-types";
|
||||
import { ActivityType } from "@vencord/discord-types/enums";
|
||||
import { React } from "@webpack/common";
|
||||
|
||||
import { ReplaceSettings, ReplaceTutorial } from "./ReplaceSettings";
|
||||
|
||||
const APP_IDS_KEY = "ReplaceActivityType_appids";
|
||||
|
||||
export type AppIdSetting = {
|
||||
disableAssets: boolean;
|
||||
disableTimestamps: boolean;
|
||||
|
|
@ -30,40 +33,6 @@ export type AppIdSetting = {
|
|||
newStreamUrl: string;
|
||||
};
|
||||
|
||||
export interface Activity {
|
||||
state: string;
|
||||
details: string;
|
||||
timestamps?: {
|
||||
start?: number;
|
||||
end?: number;
|
||||
};
|
||||
url?: string;
|
||||
assets: ActivityAssets;
|
||||
buttons?: Array<string>;
|
||||
name: string;
|
||||
application_id: string;
|
||||
metadata?: {
|
||||
button_urls?: Array<string>;
|
||||
};
|
||||
type: number;
|
||||
flags: number;
|
||||
}
|
||||
|
||||
interface ActivityAssets {
|
||||
large_image: string;
|
||||
large_text: string;
|
||||
small_image: string;
|
||||
small_text: string;
|
||||
}
|
||||
|
||||
export const enum ActivityType {
|
||||
PLAYING = 0,
|
||||
STREAMING = 1,
|
||||
LISTENING = 2,
|
||||
WATCHING = 3,
|
||||
COMPETING = 5
|
||||
}
|
||||
|
||||
export const makeEmptyAppId: () => AppIdSetting = () => ({
|
||||
appId: "",
|
||||
enabled: true,
|
||||
|
|
@ -124,12 +93,12 @@ export default definePlugin({
|
|||
if (text === "null") return "";
|
||||
return text
|
||||
.replaceAll(":name:", originalActivity.name)
|
||||
.replaceAll(":details:", originalActivity.details)
|
||||
.replaceAll(":state:", originalActivity.state)
|
||||
.replaceAll(":large_image:", originalActivity.assets.large_image)
|
||||
.replaceAll(":large_text:", originalActivity.assets.large_text)
|
||||
.replaceAll(":small_image:", originalActivity.assets.small_image)
|
||||
.replaceAll(":small_text:", originalActivity.assets.small_text);
|
||||
.replaceAll(":details:", originalActivity.details ?? "")
|
||||
.replaceAll(":state:", originalActivity.state ?? "")
|
||||
.replaceAll(":large_image:", originalActivity.assets?.large_image ?? "")
|
||||
.replaceAll(":large_text:", originalActivity.assets?.large_text ?? "")
|
||||
.replaceAll(":small_image:", originalActivity.assets?.small_image ?? "")
|
||||
.replaceAll(":small_text:", originalActivity.assets?.small_text ?? "");
|
||||
},
|
||||
patchActivity(activity: Activity) {
|
||||
if (!activity) return;
|
||||
|
|
@ -141,6 +110,7 @@ export default definePlugin({
|
|||
if (app.newActivityType === ActivityType.STREAMING && app.newStreamUrl) activity.url = app.newStreamUrl;
|
||||
if (app.newDetails) activity.details = this.parseField(app.newDetails, oldActivity);
|
||||
if (app.newState) activity.state = this.parseField(app.newState, oldActivity);
|
||||
if (!activity.assets) activity.assets = {};
|
||||
if (app.newLargeImageText) activity.assets.large_text = this.parseField(app.newLargeImageText, oldActivity);
|
||||
if (app.newLargeImageUrl) activity.assets.large_image = this.parseField(app.newLargeImageUrl, oldActivity);
|
||||
if (app.newSmallImageText) activity.assets.small_text = this.parseField(app.newSmallImageText, oldActivity);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { getUserSettingLazy } from "@api/UserSettings";
|
|||
import { EquicordDevs } from "@utils/constants";
|
||||
import { Logger } from "@utils/Logger";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { ActivityFlags, ActivityType } from "@vencord/discord-types/enums";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { ApplicationAssetUtils, FluxDispatcher, Forms } from "@webpack/common";
|
||||
|
||||
|
|
@ -50,16 +51,6 @@ interface TrackData {
|
|||
imageUrl?: string;
|
||||
}
|
||||
|
||||
// only relevant enum values
|
||||
const enum ActivityType {
|
||||
PLAYING = 0,
|
||||
LISTENING = 2,
|
||||
}
|
||||
|
||||
const enum ActivityFlag {
|
||||
INSTANCE = 1 << 0,
|
||||
}
|
||||
|
||||
const enum NameFormat {
|
||||
StatusName = "status-name",
|
||||
ArtistFirst = "artist-first",
|
||||
|
|
@ -69,8 +60,6 @@ const enum NameFormat {
|
|||
albumsName = "albums"
|
||||
}
|
||||
|
||||
|
||||
|
||||
interface Albums {
|
||||
id: number;
|
||||
image: string;
|
||||
|
|
@ -373,7 +362,7 @@ export default definePlugin({
|
|||
},
|
||||
|
||||
type: settings.store.useListeningStatus ? ActivityType.LISTENING : ActivityType.PLAYING,
|
||||
flags: ActivityFlag.INSTANCE,
|
||||
flags: ActivityFlags.INSTANCE,
|
||||
};
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@
|
|||
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { Activity } from "@vencord/discord-types";
|
||||
import { ActivityType } from "@vencord/discord-types/enums";
|
||||
import { ApplicationAssetUtils, FluxDispatcher } from "@webpack/common";
|
||||
|
||||
import { Activity, ActivityType, BanchoStatusEnum, GameState, Modes, TosuApi, UserLoginStatus } from "./type";
|
||||
import { BanchoStatusEnum, GameState, Modes, TosuApi, UserLoginStatus } from "./type";
|
||||
|
||||
const socketId = "tosu";
|
||||
const OSU_APP_ID = "367827983903490050";
|
||||
|
|
@ -64,6 +66,8 @@ async function onMessage(data: string) {
|
|||
flags: 1 << 0,
|
||||
};
|
||||
|
||||
activity.assets = {};
|
||||
|
||||
switch (profile.mode.number) {
|
||||
case Modes.Osu:
|
||||
activity.assets.small_image = OSU_STARDARD_SMALL_IMAGE;
|
||||
|
|
|
|||
|
|
@ -4,40 +4,6 @@
|
|||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
export interface ActivityAssets {
|
||||
large_image?: string;
|
||||
large_text?: string;
|
||||
small_image?: string;
|
||||
small_text?: string;
|
||||
}
|
||||
|
||||
export interface Activity {
|
||||
state?: string;
|
||||
details?: string;
|
||||
timestamps?: {
|
||||
start?: number;
|
||||
end?: number;
|
||||
};
|
||||
assets: ActivityAssets;
|
||||
buttons?: Array<string>;
|
||||
name: string;
|
||||
application_id: string;
|
||||
metadata?: {
|
||||
button_urls?: Array<string>;
|
||||
};
|
||||
type: ActivityType;
|
||||
url?: string;
|
||||
flags: number;
|
||||
}
|
||||
|
||||
export enum ActivityType {
|
||||
PLAYING = 0,
|
||||
STREAMING = 1,
|
||||
LISTENING = 2,
|
||||
WATCHING = 3,
|
||||
COMPETING = 5
|
||||
}
|
||||
|
||||
export enum BeatmapStatuses {
|
||||
Unknown,
|
||||
NotSubmitted = 1,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ import { definePluginSettings } from "@api/Settings";
|
|||
import { Devs } from "@utils/constants";
|
||||
import { isTruthy } from "@utils/guards";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { Channel, FluxStore } from "@vencord/discord-types";
|
||||
import { Activity, Channel, FluxStore } from "@vencord/discord-types";
|
||||
import { ActivityType } from "@vencord/discord-types/enums";
|
||||
import { findByPropsLazy, findStoreLazy } from "@webpack";
|
||||
import { ApplicationAssetUtils, ChannelStore, FluxDispatcher, GuildStore, IconUtils, PresenceStore, RelationshipStore, SelectedChannelStore, SelectedGuildStore, UserStore } from "@webpack/common";
|
||||
|
||||
|
|
@ -26,40 +27,6 @@ async function getApplicationAsset(key: string): Promise<string> {
|
|||
return (await ApplicationAssetUtils.fetchAssetIds(settings.store.appID!, [key]))[0];
|
||||
}
|
||||
|
||||
interface ActivityAssets {
|
||||
large_image?: string;
|
||||
large_text?: string;
|
||||
small_image?: string;
|
||||
small_text?: string;
|
||||
}
|
||||
|
||||
interface Activity {
|
||||
state?: string;
|
||||
details?: string;
|
||||
timestamps?: {
|
||||
start?: number;
|
||||
end?: number;
|
||||
};
|
||||
assets?: ActivityAssets;
|
||||
buttons?: Array<string>;
|
||||
name: string;
|
||||
application_id: string;
|
||||
metadata?: {
|
||||
button_urls?: Array<string>;
|
||||
};
|
||||
type: ActivityType;
|
||||
url?: string;
|
||||
flags: number;
|
||||
}
|
||||
|
||||
const enum ActivityType {
|
||||
PLAYING = 0,
|
||||
STREAMING = 1,
|
||||
LISTENING = 2,
|
||||
WATCHING = 3,
|
||||
COMPETING = 5
|
||||
}
|
||||
|
||||
const enum TimestampMode {
|
||||
NONE,
|
||||
NOW,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue