diff --git a/src/equicordplugins/sidebarChat/index.tsx b/src/equicordplugins/sidebarChat/index.tsx
index fff6ab888..a385a4994 100644
--- a/src/equicordplugins/sidebarChat/index.tsx
+++ b/src/equicordplugins/sidebarChat/index.tsx
@@ -18,6 +18,7 @@ import {
findByPropsLazy,
findComponentByCodeLazy,
findCssClassesLazy,
+ mapMangledModuleLazy,
} from "@webpack";
import {
ChannelActionCreators,
@@ -69,7 +70,9 @@ const ArrowsLeftRightIcon = ({ color, ...rest }) => {
const WindowLaunchIcon = findComponentByCodeLazy("1-1h6a1 1 0 1 0 0-2H5Z");
const XSmallIcon = findComponentByCodeLazy("1.4L12 13.42l5.3 5.3Z");
const Chat = findComponentByCodeLazy("filterAfterTimestamp:", "chatInputType");
-const Resize = findComponentByCodeLazy("sidebarType:", "RESIZE_HANDLE_WIDTH)");
+const SidebarComponents = mapMangledModuleLazy("ChannelChatResizableSidebar", {
+ Resize: (value: unknown) => typeof value === "function"
+});
const ChannelHeader = findComponentByCodeLazy("`channel-${");
const PopoutWindow = findComponentByCodeLazy("Missing guestWindow reference");
const FullChannelView = findComponentByCodeLazy("showFollowButton:");
@@ -104,7 +107,15 @@ function getChannelTitle(channel: Channel | null | undefined) {
function canOpenPopout(channel: Channel) {
if (channel.isPrivate()) return true;
- return !channel.isCategory() && !channel.isDirectory() && !channel.isVocal();
+ return !channel.isCategory() && !channel.isDirectory();
+}
+
+function getMainChatChannelId() {
+ const channelId = SelectedChannelStore.getChannelId();
+ const sidebar = ChannelSectionStore.getSidebarState(channelId);
+ return sidebar && typeof sidebar === "object" && "channelId" in sidebar && typeof sidebar.channelId === "string"
+ ? sidebar.channelId
+ : channelId;
}
function getPopoutMenuLabel(channelId: string) {
@@ -315,11 +326,25 @@ export default definePlugin({
replace: "$&vc_SidebarChat=$self.renderSidebar(),"
},
{
- match: /:(\(0,\i\.jsxs?\)\(\i,{}\))}(?<=default:.{0,300})/,
- replace: ":[$1, vc_SidebarChat]}"
+ match: /(?<=return )null!=\i&&\i\?\(0,\i\.jsx\)\(\i,\{channel:\i\},\i\.id\):\(0,\i\.jsx\)\(\i,\{\}\)(?=\},)/,
+ replace: "[$&,vc_SidebarChat]"
},
],
},
+ {
+ find: "loadComplete: resetting state for channelId=",
+ group: true,
+ replacement: [
+ {
+ match: /truncateTop\(\i\)\{(?=.{0,100}?this\._array\.length-\i;return)/,
+ replace: "$&if($self.hasMultipleChatViews(this.channelId))return this;"
+ },
+ {
+ match: /truncateBottom\(\i\)\{(?=.{0,100}?return this\._array\.length<=\i\?this:this\.mutate\()/,
+ replace: "$&if($self.hasMultipleChatViews(this.channelId))return this;"
+ }
+ ]
+ },
],
managedStyle: style,
settings,
@@ -361,6 +386,16 @@ export default definePlugin({
restorePersistedPopouts();
},
+ hasMultipleChatViews(channelId: string) {
+ const mainChannelId = SelectedChannelStore.getChannelId();
+ const sidebarHidden = ChannelSectionStore.getSidebarState(mainChannelId)
+ || ChannelSectionStore.getGuildSidebarState(SelectedGuildStore.getGuildId() ?? undefined);
+ const views = Number(channelId === mainChannelId || channelId === getMainChatChannelId())
+ + Number(!sidebarHidden && channelId === SidebarStore.getState().channelId)
+ + Number(isPopoutWindowOpen(channelId));
+ return views > 1;
+ },
+
renderSidebar() {
const { guild, channel /* width*/ } = useStateFromStores(
[SidebarStore, GuildStore, ChannelStore], () => {
@@ -436,13 +471,13 @@ export default definePlugin({
return (