mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-17 10:27:03 -04:00
Merge Dev
This commit is contained in:
commit
4c5dc32a0b
7 changed files with 70 additions and 30 deletions
|
@ -21,7 +21,7 @@ import { Devs } from "@utils/constants";
|
|||
import { isNonNullish } from "@utils/guards";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { Avatar, ChannelStore, Clickable, IconUtils, RelationshipStore, ScrollerThin, UserStore } from "@webpack/common";
|
||||
import { Avatar, ChannelStore, Clickable, IconUtils, RelationshipStore, ScrollerThin, useMemo, UserStore } from "@webpack/common";
|
||||
import { Channel, User } from "discord-types/general";
|
||||
|
||||
const SelectedChannelActionCreators = findByPropsLazy("selectPrivateChannel");
|
||||
|
@ -39,6 +39,19 @@ function getGroupDMName(channel: Channel) {
|
|||
.join(", ");
|
||||
}
|
||||
|
||||
const getMutualGroupDms = (userId: string) =>
|
||||
ChannelStore.getSortedPrivateChannels()
|
||||
.filter(c => c.isGroupDM() && c.recipients.includes(userId));
|
||||
|
||||
const isBotOrSelf = (user: User) => user.bot || user.id === UserStore.getCurrentUser().id;
|
||||
|
||||
function getMutualGDMCountText(user: User) {
|
||||
const count = getMutualGroupDms(user.id).length;
|
||||
return `${count === 0 ? "No" : count} Mutual Group${count !== 1 ? "s" : ""}`;
|
||||
}
|
||||
|
||||
const IS_PATCHED = Symbol("MutualGroupDMs.Patched");
|
||||
|
||||
export default definePlugin({
|
||||
name: "MutualGroupDMs",
|
||||
description: "Shows mutual group dms in profiles",
|
||||
|
@ -63,8 +76,8 @@ export default definePlugin({
|
|||
find: ".MUTUAL_FRIENDS?(",
|
||||
replacement: [
|
||||
{
|
||||
match: /(?<=onItemSelect:\i,children:)(\i)\.map/,
|
||||
replace: "[...$1, ...($self.isBotOrSelf(arguments[0].user) ? [] : [{section:'MUTUAL_GDMS',text:$self.getMutualGDMCountText(arguments[0].user)}])].map"
|
||||
match: /\i\.useEffect.{0,100}(\i)\[0\]\.section/,
|
||||
replace: "$self.pushSection($1, arguments[0].user);$&"
|
||||
},
|
||||
{
|
||||
match: /\(0,\i\.jsx\)\(\i,\{items:\i,section:(\i)/,
|
||||
|
@ -74,15 +87,23 @@ export default definePlugin({
|
|||
}
|
||||
],
|
||||
|
||||
isBotOrSelf: (user: User) => user.bot || user.id === UserStore.getCurrentUser().id,
|
||||
isBotOrSelf,
|
||||
getMutualGDMCountText,
|
||||
|
||||
getMutualGDMCountText: (user: User) => {
|
||||
const count = ChannelStore.getSortedPrivateChannels().filter(c => c.isGroupDM() && c.recipients.includes(user.id)).length;
|
||||
return `${count === 0 ? "No" : count} Mutual Group${count !== 1 ? "s" : ""}`;
|
||||
pushSection(sections: any[], user: User) {
|
||||
if (isBotOrSelf(user) || sections[IS_PATCHED]) return;
|
||||
|
||||
sections[IS_PATCHED] = true;
|
||||
sections.push({
|
||||
section: "MUTUAL_GDMS",
|
||||
text: getMutualGDMCountText(user)
|
||||
});
|
||||
},
|
||||
|
||||
renderMutualGDMs: ErrorBoundary.wrap(({ user, onClose }: { user: User, onClose: () => void; }) => {
|
||||
const entries = ChannelStore.getSortedPrivateChannels().filter(c => c.isGroupDM() && c.recipients.includes(user.id)).map(c => (
|
||||
const mutualDms = useMemo(() => getMutualGroupDms(user.id), [user.id]);
|
||||
|
||||
const entries = mutualDms.map(c => (
|
||||
<Clickable
|
||||
className={ProfileListClasses.listRow}
|
||||
onClick={() => {
|
||||
|
|
|
@ -55,6 +55,7 @@ interface PlayerState {
|
|||
|
||||
// added by patch
|
||||
actual_repeat: Repeat;
|
||||
shuffle: boolean;
|
||||
}
|
||||
|
||||
interface Device {
|
||||
|
@ -182,6 +183,7 @@ export const SpotifyStore = proxyLazyWebpack(() => {
|
|||
store.isPlaying = e.isPlaying ?? false;
|
||||
store.volume = e.volumePercent ?? 0;
|
||||
store.repeat = e.actual_repeat || "off";
|
||||
store.shuffle = e.shuffle ?? false;
|
||||
store.position = e.position ?? 0;
|
||||
store.isSettingPosition = false;
|
||||
store.emitChange();
|
||||
|
|
|
@ -70,21 +70,20 @@ export default definePlugin({
|
|||
replace: "false",
|
||||
}]
|
||||
},
|
||||
// Discord doesn't give you the repeat kind, only a boolean
|
||||
{
|
||||
find: 'repeat:"off"!==',
|
||||
replacement: {
|
||||
match: /repeat:"off"!==(.{1,3}),/,
|
||||
replace: "actual_repeat:$1,$&"
|
||||
}
|
||||
replacement: [
|
||||
{
|
||||
// Discord doesn't give you shuffle state and the repeat kind, only a boolean
|
||||
match: /repeat:"off"!==(\i),/,
|
||||
replace: "shuffle:arguments[2]?.shuffle_state??false,actual_repeat:$1,$&"
|
||||
},
|
||||
{
|
||||
match: /(?<=artists.filter\(\i=>).{0,10}\i\.id\)&&/,
|
||||
replace: ""
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
find: "artists.filter",
|
||||
replacement: {
|
||||
match: /(?<=artists.filter\(\i=>).{0,10}\i\.id\)&&/,
|
||||
replace: ""
|
||||
}
|
||||
}
|
||||
],
|
||||
|
||||
start: () => toggleHoverControls(Settings.plugins.SpotifyControls.hoverControls),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue