Compare commits

..

No commits in common. "9bc090b6a800852c7998e87d5d75fcae400c81c7" and "8da37f0b24fb04f8864d85fe17eb2266118d9496" have entirely different histories.

9 changed files with 27 additions and 27 deletions

View file

@ -49,7 +49,7 @@ export default definePlugin({
}, },
// Decoration modal module // Decoration modal module
{ {
find: ".decorationGridItem,", find: ".decorationGridItem",
replacement: [ replacement: [
{ {
match: /(?<==)\i=>{let{children.{20,100}decorationGridItem/, match: /(?<==)\i=>{let{children.{20,100}decorationGridItem/,

View file

@ -53,7 +53,7 @@ function useCategory(categoryId: string | null, initalChannelId: string | null)
setCategory({ setCategory({
id: Toasts.genId(), id: Toasts.genId(),
name: `Pin Category ${categories.length + 1}`, name: `Pin Category ${categories.length + 1}`,
color: DEFAULT_COLOR, color: 10070709,
collapsed: false, collapsed: false,
channels: [initalChannelId] channels: [initalChannelId]
}); });

View file

@ -8,7 +8,7 @@ import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/Co
import { Menu } from "@webpack/common"; import { Menu } from "@webpack/common";
import { addChannelToCategory, canMoveChannelInDirection, categories, isPinned, moveChannel, removeChannelFromCategory } from "../data"; import { addChannelToCategory, canMoveChannelInDirection, categories, isPinned, moveChannel, removeChannelFromCategory } from "../data";
import { forceUpdate, PinOrder, settings } from "../index"; import { forceUpdate, settings } from "../index";
import { openCategoryModal } from "./CreateCategoryModal"; import { openCategoryModal } from "./CreateCategoryModal";
function createPinMenuItem(channelId: string) { function createPinMenuItem(channelId: string) {
@ -52,7 +52,7 @@ function createPinMenuItem(channelId: string) {
/> />
{ {
settings.store.pinOrder === PinOrder.Custom && canMoveChannelInDirection(channelId, -1) && ( !settings.store.sortDmsByNewestMessage && canMoveChannelInDirection(channelId, -1) && (
<Menu.MenuItem <Menu.MenuItem
id="move-up" id="move-up"
label="Move Up" label="Move Up"
@ -62,7 +62,7 @@ function createPinMenuItem(channelId: string) {
} }
{ {
settings.store.pinOrder === PinOrder.Custom && canMoveChannelInDirection(channelId, 1) && ( !settings.store.sortDmsByNewestMessage && canMoveChannelInDirection(channelId, 1) && (
<Menu.MenuItem <Menu.MenuItem
id="move-down" id="move-down"
label="Move Down" label="Move Down"

View file

@ -34,19 +34,11 @@ const PrivateChannelSortStore = findStoreLazy("PrivateChannelSortStore") as { ge
export let instance: any; export let instance: any;
export const forceUpdate = () => instance?.props?._forceUpdate?.(); export const forceUpdate = () => instance?.props?._forceUpdate?.();
export const enum PinOrder {
LastMessage,
Custom
}
export const settings = definePluginSettings({ export const settings = definePluginSettings({
pinOrder: { sortDmsByNewestMessage: {
type: OptionType.SELECT, type: OptionType.BOOLEAN,
description: "Which order should pinned DMs be displayed in?", description: "Sort DMs by newest message",
options: [ default: false,
{ label: "Most recent message", value: PinOrder.LastMessage, default: true },
{ label: "Custom (right click channels to reorder)", value: PinOrder.Custom }
],
onChange: () => forceUpdate() onChange: () => forceUpdate()
}, },
@ -69,6 +61,11 @@ export default definePlugin({
{ {
find: ".privateChannelsHeaderContainer,", find: ".privateChannelsHeaderContainer,",
replacement: [ replacement: [
// Init
{
match: /(?<=componentDidMount\(\){).{1,100}scrollToChannel/,
replace: "$self._instance = this;$&"
},
{ {
// Filter out pinned channels from the private channel list // Filter out pinned channels from the private channel list
match: /(?<=\i,{channels:\i,)privateChannelIds:(\i)/, match: /(?<=\i,{channels:\i,)privateChannelIds:(\i)/,
@ -167,15 +164,12 @@ export default definePlugin({
getSections, getSections,
getAllUncollapsedChannels, getAllUncollapsedChannels,
requireSettingsMenu, requireSettingsMenu,
makeProps(instance, { sections }: { sections: number[]; }) { makeProps(instance, { sections }: { sections: number[]; }) {
this._instance = instance;
this.sections = sections; this.sections = sections;
this.sections.splice(1, 0, ...this.getSections()); this.sections.splice(1, 0, ...this.getPinCount(instance.props.privateChannelIds || []));
if (this.instance?.props?.privateChannelIds?.length === 0) { if (this.instance?.props?.privateChannelIds?.length === 0) {
// dont render direct messages header
this.sections[this.sections.length - 1] = 0; this.sections[this.sections.length - 1] = 0;
} }
@ -205,6 +199,10 @@ export default definePlugin({
return (sectionHeaderSizePx + sections.reduce((acc, v) => acc += v + 44, 0) + DEFAULT_CHUNK_SIZE) * 1.5; return (sectionHeaderSizePx + sections.reduce((acc, v) => acc += v + 44, 0) + DEFAULT_CHUNK_SIZE) * 1.5;
}, },
getPinCount(channelIds: string[]) {
return channelIds.length ? this.getSections() : [];
},
isCategoryIndex(sectionIndex: number) { isCategoryIndex(sectionIndex: number) {
return this.sections && sectionIndex > 0 && sectionIndex < this.sections.length - 1; return this.sections && sectionIndex > 0 && sectionIndex < this.sections.length - 1;
}, },
@ -213,7 +211,7 @@ export default definePlugin({
if (settings.store.dmSectioncollapsed && sectionIndex !== 0) if (settings.store.dmSectioncollapsed && sectionIndex !== 0)
return true; return true;
const cat = categories[sectionIndex - 1]; const cat = categories[sectionIndex - 1];
return this.isCategoryIndex(sectionIndex) && (cat?.channels?.length === 0 || cat?.channels[channelIndex]); return this.isCategoryIndex(sectionIndex) && (cat.channels.length === 0 || cat?.channels[channelIndex]);
}, },
isDMSectioncollapsed() { isDMSectioncollapsed() {
@ -221,6 +219,7 @@ export default definePlugin({
}, },
collapseDMList() { collapseDMList() {
// console.log("HI");
settings.store.dmSectioncollapsed = !settings.store.dmSectioncollapsed; settings.store.dmSectioncollapsed = !settings.store.dmSectioncollapsed;
forceUpdate(); forceUpdate();
}, },
@ -351,7 +350,7 @@ export default definePlugin({
getCategoryChannels(category: Category) { getCategoryChannels(category: Category) {
if (category.channels.length === 0) return []; if (category.channels.length === 0) return [];
if (settings.store.pinOrder === PinOrder.LastMessage) { if (settings.store.sortDmsByNewestMessage) {
return PrivateChannelSortStore.getPrivateChannelIds().filter(c => category.channels.includes(c)); return PrivateChannelSortStore.getPrivateChannelIds().filter(c => category.channels.includes(c));
} }

@ -0,0 +1 @@
Subproject commit 9434e3672a815d8ee52c9c193e7088fffae0fb9a

@ -1 +1 @@
Subproject commit 1fa296b337123084964267f8e8864218a445b991 Subproject commit 3bfd6731e0b1522b5e93fb3bf4810032b6b2addf

@ -1 +1 @@
Subproject commit 796eaec844a69c7449bdbaad0c834a3c409a5964 Subproject commit 125072bd14640c1c173f0cd1ee6b16f9a18886e7

@ -1 +1 @@
Subproject commit e6d4d5e3aecbf3d7960bbdf5d4d80ffc835d7d73 Subproject commit d8407fbb772ddddf60ac152100dfa1a806fa910a

@ -1 +1 @@
Subproject commit 8aeb03210eaf6d9e8056ae2a59bfdb8795b83244 Subproject commit 2010808966057997a002448eb249ca2a2c2e3e77