Lint Fixes
This commit is contained in:
parent
7d58b287f0
commit
0eaaa9c122
8 changed files with 32 additions and 43 deletions
1
packages/discord-types/src/index.d.ts
vendored
1
packages/discord-types/src/index.d.ts
vendored
|
|
@ -7,5 +7,4 @@ export * from "./menu";
|
|||
export * from "./stores";
|
||||
export * from "./passiveupdatestate";
|
||||
export * from "./utils";
|
||||
export * from "./voicestate";
|
||||
export * as Webpack from "../webpack";
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { VoiceState } from "./voicestate";
|
||||
import { VoiceState } from "./stores";
|
||||
|
||||
export interface PassiveUpdateState {
|
||||
type: string;
|
||||
|
|
|
|||
|
|
@ -14,12 +14,16 @@ export interface VoiceState extends DiscordRecord {
|
|||
selfDeaf: boolean;
|
||||
selfVideo: boolean;
|
||||
selfStream: boolean | undefined;
|
||||
sessionId: string;
|
||||
suppress: boolean;
|
||||
requestToSpeakTimestamp: string | null | undefined;
|
||||
discoverable: boolean;
|
||||
|
||||
isVoiceMuted(): boolean;
|
||||
isVoiceDeafened(): boolean;
|
||||
|
||||
oldChannelId?: string;
|
||||
guildId?: string;
|
||||
}
|
||||
|
||||
export class VoiceStateStore extends FluxStore {
|
||||
|
|
|
|||
21
packages/discord-types/src/voicestate.d.ts
vendored
21
packages/discord-types/src/voicestate.d.ts
vendored
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
export interface VoiceState {
|
||||
userId: string;
|
||||
channelId?: string;
|
||||
oldChannelId?: string;
|
||||
guildId?: string;
|
||||
deaf: boolean;
|
||||
mute: boolean;
|
||||
selfDeaf: boolean;
|
||||
selfMute: boolean;
|
||||
selfStream: boolean;
|
||||
selfVideo: boolean;
|
||||
sessionId: string;
|
||||
suppress: boolean;
|
||||
requestToSpeakTimestamp: string | null;
|
||||
}
|
||||
|
|
@ -149,7 +149,7 @@ export default definePlugin({
|
|||
let { oldChannelId } = state;
|
||||
if (isMe && channelId !== myLastChannelId) {
|
||||
oldChannelId = myLastChannelId;
|
||||
myLastChannelId = channelId;
|
||||
myLastChannelId = channelId ?? undefined;
|
||||
}
|
||||
|
||||
if (channelId !== oldChannelId) {
|
||||
|
|
|
|||
|
|
@ -19,13 +19,13 @@
|
|||
import "./ytmStyles.css";
|
||||
|
||||
import { ImageIcon, LinkIcon, OpenExternalIcon } from "@components/Icons";
|
||||
import { SeekBar } from "@equicordplugins/musicControls/spotify/SeekBar";
|
||||
import { debounce } from "@shared/debounce";
|
||||
import { openImageModal } from "@utils/discord";
|
||||
import { classes, copyWithToast } from "@utils/misc";
|
||||
import { ContextMenuApi, Flex, FluxDispatcher, Forms, Menu, React, useEffect, useState, useStateFromStores } from "@webpack/common";
|
||||
|
||||
import { type Song, type Repeat, YoutubeMusicStore } from "./YtmStore";
|
||||
import { SeekBar } from "@equicordplugins/musicControls/spotify/SeekBar";
|
||||
import { type Repeat, type Song, YoutubeMusicStore } from "./YtmStore";
|
||||
|
||||
const cl = (className: string) => `vc-ytm-${className}`;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ enum MediaType {
|
|||
OtherVideo = "OTHER_VIDEO",
|
||||
}
|
||||
|
||||
export type RepeatMode = 'NONE' | 'ONE' | 'ALL';
|
||||
export type RepeatMode = "NONE" | "ONE" | "ALL";
|
||||
|
||||
|
||||
export interface Song {
|
||||
|
|
@ -49,13 +49,13 @@ export interface Song {
|
|||
}
|
||||
|
||||
enum DataTypes {
|
||||
PlayerInfo = 'PLAYER_INFO',
|
||||
VideoChanged = 'VIDEO_CHANGED',
|
||||
PlayerStateChanged = 'PLAYER_STATE_CHANGED',
|
||||
PositionChanged = 'POSITION_CHANGED',
|
||||
VolumeChanged = 'VOLUME_CHANGED',
|
||||
RepeatChanged = 'REPEAT_CHANGED',
|
||||
ShuffleChanged = 'SHUFFLE_CHANGED',
|
||||
PlayerInfo = "PLAYER_INFO",
|
||||
VideoChanged = "VIDEO_CHANGED",
|
||||
PlayerStateChanged = "PLAYER_STATE_CHANGED",
|
||||
PositionChanged = "POSITION_CHANGED",
|
||||
VolumeChanged = "VOLUME_CHANGED",
|
||||
RepeatChanged = "REPEAT_CHANGED",
|
||||
ShuffleChanged = "SHUFFLE_CHANGED",
|
||||
}
|
||||
|
||||
type PlayerInfo = {
|
||||
|
|
@ -200,7 +200,7 @@ export const YoutubeMusicStore = proxyLazyWebpack(() => {
|
|||
if (message.song) {
|
||||
store.song = message.song;
|
||||
store.isPlaying = !(message.song?.isPaused ?? false);
|
||||
};
|
||||
}
|
||||
if (message.isPlaying != null && !message.song) store.isPlaying = message.isPlaying;
|
||||
if (message.shuffle != null) store.isShuffled = message.shuffle;
|
||||
if (message.position && message.position !== store.position) store.position = message.position ?? 0;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
import { definePluginSettings } from "@api/Settings";
|
||||
import { EquicordDevs } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { VoiceState } from "@vencord/discord-types";
|
||||
import { ChannelStore, FluxDispatcher, GuildMemberStore, Toasts, UserStore, VoiceStateStore } from "@webpack/common";
|
||||
|
||||
interface ChannelState {
|
||||
|
|
@ -78,7 +79,7 @@ const settings = definePluginSettings({
|
|||
});
|
||||
|
||||
let ws: WebSocket | null = null;
|
||||
let currentChannel = null;
|
||||
let currentChannel: string | null = null;
|
||||
|
||||
async function waitForPopulate(fn) {
|
||||
while (true) {
|
||||
|
|
@ -88,7 +89,7 @@ async function waitForPopulate(fn) {
|
|||
}
|
||||
}
|
||||
|
||||
function stateToPayload(guildId: string, state: ChannelState) {
|
||||
function stateToPayload(guildId: string, state: VoiceState) {
|
||||
const user = UserStore.getUser(state.userId);
|
||||
const nickname = GuildMemberStore.getNick(guildId, state.userId);
|
||||
return {
|
||||
|
|
@ -130,9 +131,9 @@ const incoming = payload => {
|
|||
case "STOP_STREAM": {
|
||||
const userId = UserStore.getCurrentUser().id;
|
||||
const voiceState = VoiceStateStore.getVoiceStateForUser(userId);
|
||||
if (!voiceState?.channelId) return;
|
||||
const channel = ChannelStore.getChannel(voiceState.channelId);
|
||||
|
||||
if (!userId || !voiceState || !channel) return;
|
||||
if (!channel) return;
|
||||
|
||||
FluxDispatcher.dispatch({
|
||||
type: "STREAM_STOP",
|
||||
|
|
@ -188,8 +189,14 @@ const createWebsocket = () => {
|
|||
|
||||
ws?.send(JSON.stringify({ cmd: "REGISTER_CONFIG", ...config }));
|
||||
|
||||
if (!config.userId) return;
|
||||
const userVoiceState = VoiceStateStore.getVoiceStateForUser(config.userId);
|
||||
const guildId = ChannelStore.getChannel(userVoiceState.channelId).guild_id;
|
||||
if (!userVoiceState || !userVoiceState.channelId) return;
|
||||
|
||||
const channel = ChannelStore.getChannel(userVoiceState.channelId);
|
||||
if (!channel) return;
|
||||
|
||||
const guildId = channel.guild_id;
|
||||
const channelState = VoiceStateStore.getVoiceStatesForChannel(userVoiceState.channelId);
|
||||
|
||||
if (!guildId || !channelState) return;
|
||||
|
|
@ -197,7 +204,7 @@ const createWebsocket = () => {
|
|||
ws?.send(
|
||||
JSON.stringify({
|
||||
cmd: "CHANNEL_JOINED",
|
||||
states: Object.values(channelState).map(s => stateToPayload(guildId, s as ChannelState)),
|
||||
states: Object.values(channelState).map(s => stateToPayload(guildId, s)),
|
||||
})
|
||||
);
|
||||
|
||||
|
|
@ -236,7 +243,7 @@ export default definePlugin({
|
|||
ws?.send(
|
||||
JSON.stringify({
|
||||
cmd: "CHANNEL_JOINED",
|
||||
states: Object.values(voiceStates).map(s => stateToPayload(guildId, s as ChannelState)),
|
||||
states: Object.values(voiceStates).map(s => stateToPayload(guildId, s as VoiceState)),
|
||||
})
|
||||
);
|
||||
|
||||
|
|
@ -258,7 +265,7 @@ export default definePlugin({
|
|||
ws?.send(
|
||||
JSON.stringify({
|
||||
cmd: "VOICE_STATE_UPDATE",
|
||||
state: stateToPayload(guildId, state as ChannelState),
|
||||
state: stateToPayload(guildId, state),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue