mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-10 09:56:24 +00:00
Merge branch 'dev' into immediate-finds
This commit is contained in:
commit
3335ec1ac5
8 changed files with 31 additions and 22 deletions
|
@ -165,7 +165,7 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
if (settings.store.attemptToNavigateToHome) {
|
if (settings.store.attemptToNavigateToHome) {
|
||||||
try {
|
try {
|
||||||
NavigationRouter.transitionTo("/channels/@me");
|
NavigationRouter.transitionToGuild("@me");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
CrashHandlerLogger.debug("Failed to navigate to home", err);
|
CrashHandlerLogger.debug("Failed to navigate to home", err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
import * as DataStore from "@api/DataStore";
|
import * as DataStore from "@api/DataStore";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { ChannelStore, NavigationRouter, SelectedChannelStore, SelectedGuildStore } from "@webpack/common";
|
import { ChannelRouter, SelectedChannelStore, SelectedGuildStore } from "@webpack/common";
|
||||||
|
|
||||||
export interface LogoutEvent {
|
export interface LogoutEvent {
|
||||||
type: "LOGOUT";
|
type: "LOGOUT";
|
||||||
|
@ -40,11 +40,6 @@ interface PreviousChannel {
|
||||||
let isSwitchingAccount = false;
|
let isSwitchingAccount = false;
|
||||||
let previousCache: PreviousChannel | undefined;
|
let previousCache: PreviousChannel | undefined;
|
||||||
|
|
||||||
function attemptToNavigateToChannel(guildId: string | null, channelId: string) {
|
|
||||||
if (!ChannelStore.hasChannel(channelId)) return;
|
|
||||||
NavigationRouter.transitionTo(`/channels/${guildId ?? "@me"}/${channelId}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "KeepCurrentChannel",
|
name: "KeepCurrentChannel",
|
||||||
description: "Attempt to navigate to the channel you were in before switching accounts or loading Discord.",
|
description: "Attempt to navigate to the channel you were in before switching accounts or loading Discord.",
|
||||||
|
@ -59,8 +54,9 @@ export default definePlugin({
|
||||||
if (!isSwitchingAccount) return;
|
if (!isSwitchingAccount) return;
|
||||||
isSwitchingAccount = false;
|
isSwitchingAccount = false;
|
||||||
|
|
||||||
if (previousCache?.channelId)
|
if (previousCache?.channelId) {
|
||||||
attemptToNavigateToChannel(previousCache.guildId, previousCache.channelId);
|
ChannelRouter.transitionToChannel(previousCache.channelId);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async CHANNEL_SELECT({ guildId, channelId }: ChannelSelectEvent) {
|
async CHANNEL_SELECT({ guildId, channelId }: ChannelSelectEvent) {
|
||||||
|
@ -84,7 +80,7 @@ export default definePlugin({
|
||||||
|
|
||||||
await DataStore.set("KeepCurrentChannel_previousData", previousCache);
|
await DataStore.set("KeepCurrentChannel_previousData", previousCache);
|
||||||
} else if (previousCache.channelId) {
|
} else if (previousCache.channelId) {
|
||||||
attemptToNavigateToChannel(previousCache.guildId, previousCache.channelId);
|
ChannelRouter.transitionToChannel(previousCache.channelId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -91,7 +91,7 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
find: ".PANEL,interactionType:",
|
find: 'location:"UserProfilePanel"',
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /{profileType:\i\.\i\.PANEL,children:\[/,
|
match: /{profileType:\i\.\i\.PANEL,children:\[/,
|
||||||
replace: "$&$self.BiteSizeReviewsButton({user:arguments[0].user}),"
|
replace: "$&$self.BiteSizeReviewsButton({user:arguments[0].user}),"
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { classNameFactory } from "@api/Styles";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { filters, findByCode, findComponentByCode, findProp, findStore, mapMangledModule } from "@webpack";
|
import { filters, findByCode, findComponentByCode, findProp, findStore, mapMangledModule } from "@webpack";
|
||||||
import { ChannelStore, GuildStore, IconUtils, match, NavigationRouter, P, PermissionsBits, PermissionStore, React, showToast, Text, Toasts, Tooltip, useMemo, UserStore, useStateFromStores } from "@webpack/common";
|
import { ChannelRouter, ChannelStore, GuildStore, IconUtils, match, P, PermissionsBits, PermissionStore, React, showToast, Text, Toasts, Tooltip, useMemo, UserStore, useStateFromStores } from "@webpack/common";
|
||||||
import { Channel } from "discord-types/general";
|
import { Channel } from "discord-types/general";
|
||||||
|
|
||||||
const cl = classNameFactory("vc-uvs-");
|
const cl = classNameFactory("vc-uvs-");
|
||||||
|
@ -74,9 +74,10 @@ function LockedSpeakerIcon(props: IconProps) {
|
||||||
|
|
||||||
interface VoiceChannelTooltipProps {
|
interface VoiceChannelTooltipProps {
|
||||||
channel: Channel;
|
channel: Channel;
|
||||||
|
isLocked: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
function VoiceChannelTooltip({ channel }: VoiceChannelTooltipProps) {
|
function VoiceChannelTooltip({ channel, isLocked }: VoiceChannelTooltipProps) {
|
||||||
const voiceStates = useStateFromStores([VoiceStateStore], () => VoiceStateStore.getVoiceStatesForChannel(channel.id));
|
const voiceStates = useStateFromStores([VoiceStateStore], () => VoiceStateStore.getVoiceStatesForChannel(channel.id));
|
||||||
|
|
||||||
const users = useMemo(
|
const users = useMemo(
|
||||||
|
@ -113,7 +114,7 @@ function VoiceChannelTooltip({ channel }: VoiceChannelTooltipProps) {
|
||||||
<Text variant="text-sm/semibold">{channelName}</Text>
|
<Text variant="text-sm/semibold">{channelName}</Text>
|
||||||
</div>
|
</div>
|
||||||
<div className={cl("vc-members")}>
|
<div className={cl("vc-members")}>
|
||||||
<SpeakerIcon size={18} />
|
{isLocked ? <LockedSpeakerIcon size={18} /> : <SpeakerIcon size={18} />}
|
||||||
<UserSummaryItem
|
<UserSummaryItem
|
||||||
users={users}
|
users={users}
|
||||||
renderIcon={false}
|
renderIcon={false}
|
||||||
|
@ -129,11 +130,12 @@ interface VoiceChannelIndicatorProps {
|
||||||
userId: string;
|
userId: string;
|
||||||
isActionButton?: boolean;
|
isActionButton?: boolean;
|
||||||
isMessageIndicator?: boolean;
|
isMessageIndicator?: boolean;
|
||||||
|
shouldHighlight?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const clickTimers = {} as Record<string, any>;
|
const clickTimers = {} as Record<string, any>;
|
||||||
|
|
||||||
export const VoiceChannelIndicator = ErrorBoundary.wrap(({ userId, isActionButton, isMessageIndicator }: VoiceChannelIndicatorProps) => {
|
export const VoiceChannelIndicator = ErrorBoundary.wrap(({ userId, isActionButton, isMessageIndicator, shouldHighlight }: VoiceChannelIndicatorProps) => {
|
||||||
const channelId = useStateFromStores([VoiceStateStore], () => VoiceStateStore.getVoiceStateForUser(userId)?.channelId as string | undefined);
|
const channelId = useStateFromStores([VoiceStateStore], () => VoiceStateStore.getVoiceStateForUser(userId)?.channelId as string | undefined);
|
||||||
|
|
||||||
const channel = channelId == null ? undefined : ChannelStore.getChannel(channelId);
|
const channel = channelId == null ? undefined : ChannelStore.getChannel(channelId);
|
||||||
|
@ -165,7 +167,7 @@ export const VoiceChannelIndicator = ErrorBoundary.wrap(({ userId, isActionButto
|
||||||
selectVoiceChannel(channelId);
|
selectVoiceChannel(channelId);
|
||||||
} else {
|
} else {
|
||||||
clickTimers[channelId] = setTimeout(() => {
|
clickTimers[channelId] = setTimeout(() => {
|
||||||
NavigationRouter.transitionTo(`/channels/${channel.getGuildId() ?? "@me"}/${channelId}`);
|
ChannelRouter.transitionToChannel(channelId);
|
||||||
delete clickTimers[channelId];
|
delete clickTimers[channelId];
|
||||||
}, 250);
|
}, 250);
|
||||||
}
|
}
|
||||||
|
@ -173,14 +175,14 @@ export const VoiceChannelIndicator = ErrorBoundary.wrap(({ userId, isActionButto
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
text={<VoiceChannelTooltip channel={channel} />}
|
text={<VoiceChannelTooltip channel={channel} isLocked={isLocked} />}
|
||||||
tooltipClassName={cl("tooltip-container")}
|
tooltipClassName={cl("tooltip-container")}
|
||||||
tooltipContentClassName={cl("tooltip-content")}
|
tooltipContentClassName={cl("tooltip-content")}
|
||||||
>
|
>
|
||||||
{props => {
|
{props => {
|
||||||
const iconProps: IconProps = {
|
const iconProps: IconProps = {
|
||||||
...props,
|
...props,
|
||||||
className: isActionButton ? cl("indicator-action-button") : cl("speaker-padding"),
|
className: classes(isActionButton ? cl("indicator-action-button") : cl("speaker-padding"), isMessageIndicator && cl("message-indicator"), shouldHighlight && cl("highlight")),
|
||||||
size: isActionButton ? 20 : undefined,
|
size: isActionButton ? 20 : undefined,
|
||||||
onClick
|
onClick
|
||||||
};
|
};
|
||||||
|
|
|
@ -86,8 +86,8 @@ export default definePlugin({
|
||||||
{
|
{
|
||||||
find: "null!=this.peopleListItemRef.current",
|
find: "null!=this.peopleListItemRef.current",
|
||||||
replacement: {
|
replacement: {
|
||||||
match: /\.actions,children:\[/,
|
match: /\.actions,children:\[(?<=isFocused:(\i).+?)/,
|
||||||
replace: "$&$self.VoiceChannelIndicator({userId:this?.props?.user?.id,isActionButton:true}),"
|
replace: "$&$self.VoiceChannelIndicator({userId:this?.props?.user?.id,isActionButton:true,shouldHighlight:$1}),"
|
||||||
},
|
},
|
||||||
predicate: () => settings.store.showInMemberList
|
predicate: () => settings.store.showInMemberList
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,6 @@
|
||||||
|
|
||||||
.vc-uvs-message-indicator {
|
.vc-uvs-message-indicator {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
top: 2.5px;
|
top: 2.5px;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +31,10 @@
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.vc-uvs-indicator-action-button.vc-uvs-highlight {
|
||||||
|
background-color: var(--background-tertiary);
|
||||||
|
}
|
||||||
|
|
||||||
.vc-uvs-tooltip-container {
|
.vc-uvs-tooltip-container {
|
||||||
max-width: 300px;
|
max-width: 300px;
|
||||||
}
|
}
|
||||||
|
|
5
src/webpack/common/types/utils.d.ts
vendored
5
src/webpack/common/types/utils.d.ts
vendored
|
@ -177,6 +177,11 @@ export interface NavigationRouter {
|
||||||
transitionToGuild(guildId: string, ...args: unknown[]): void;
|
transitionToGuild(guildId: string, ...args: unknown[]): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ChannelRouter {
|
||||||
|
transitionToChannel: (channelId: string) => void;
|
||||||
|
transitionToThread: (channel: Channel) => void;
|
||||||
|
}
|
||||||
|
|
||||||
export interface IconUtils {
|
export interface IconUtils {
|
||||||
getUserAvatarURL(user: User, canAnimate?: boolean, size?: number, format?: string): string;
|
getUserAvatarURL(user: User, canAnimate?: boolean, size?: number, format?: string): string;
|
||||||
getDefaultAvatarURL(id: string, discriminator?: string): string;
|
getDefaultAvatarURL(id: string, discriminator?: string): string;
|
||||||
|
|
|
@ -139,6 +139,10 @@ export const NavigationRouter: t.NavigationRouter = mapMangledModule("Transition
|
||||||
back: filters.byCode("goBack()"),
|
back: filters.byCode("goBack()"),
|
||||||
forward: filters.byCode("goForward()"),
|
forward: filters.byCode("goForward()"),
|
||||||
});
|
});
|
||||||
|
export const ChannelRouter: t.ChannelRouter = mapMangledModule('"Thread must have a parent ID."', {
|
||||||
|
transitionToChannel: filters.byCode(".preload"),
|
||||||
|
transitionToThread: filters.byCode('"Thread must have a parent ID."')
|
||||||
|
});
|
||||||
|
|
||||||
export const SettingsRouter = findByProps("open", "saveAccountChanges");
|
export const SettingsRouter = findByProps("open", "saveAccountChanges");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue