|
|
@ -34,11 +34,19 @@ 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({
|
|
|
|
sortDmsByNewestMessage: {
|
|
|
|
pinOrder: {
|
|
|
|
type: OptionType.BOOLEAN,
|
|
|
|
type: OptionType.SELECT,
|
|
|
|
description: "Sort DMs by newest message",
|
|
|
|
description: "Which order should pinned DMs be displayed in?",
|
|
|
|
default: false,
|
|
|
|
options: [
|
|
|
|
|
|
|
|
{ label: "Most recent message", value: PinOrder.LastMessage, default: true },
|
|
|
|
|
|
|
|
{ label: "Custom (right click channels to reorder)", value: PinOrder.Custom }
|
|
|
|
|
|
|
|
],
|
|
|
|
onChange: () => forceUpdate()
|
|
|
|
onChange: () => forceUpdate()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
@ -61,11 +69,6 @@ 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)/,
|
|
|
@ -164,12 +167,15 @@ 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.getPinCount(instance.props.privateChannelIds || []));
|
|
|
|
this.sections.splice(1, 0, ...this.getSections());
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -199,10 +205,6 @@ 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;
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -211,7 +213,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() {
|
|
|
@ -219,7 +221,6 @@ export default definePlugin({
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
collapseDMList() {
|
|
|
|
collapseDMList() {
|
|
|
|
// console.log("HI");
|
|
|
|
|
|
|
|
settings.store.dmSectioncollapsed = !settings.store.dmSectioncollapsed;
|
|
|
|
settings.store.dmSectioncollapsed = !settings.store.dmSectioncollapsed;
|
|
|
|
forceUpdate();
|
|
|
|
forceUpdate();
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -350,7 +351,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.sortDmsByNewestMessage) {
|
|
|
|
if (settings.store.pinOrder === PinOrder.LastMessage) {
|
|
|
|
return PrivateChannelSortStore.getPrivateChannelIds().filter(c => category.channels.includes(c));
|
|
|
|
return PrivateChannelSortStore.getPrivateChannelIds().filter(c => category.channels.includes(c));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|