mirror of
https://github.com/Equicord/Equicord.git
synced 2025-03-10 04:00:24 -04:00
Merge branch 'dev'
This commit is contained in:
commit
7013d24c46
4 changed files with 59 additions and 7 deletions
|
@ -5,9 +5,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { getCurrentChannel } from "@utils/discord";
|
import { getCurrentChannel } from "@utils/discord";
|
||||||
|
import { isObjectEmpty } from "@utils/misc";
|
||||||
import { SelectedChannelStore, Tooltip, useEffect, useStateFromStores } from "@webpack/common";
|
import { SelectedChannelStore, Tooltip, useEffect, useStateFromStores } from "@webpack/common";
|
||||||
|
|
||||||
import { ChannelMemberStore, cl, GuildMemberCountStore, numberFormat } from ".";
|
import { ChannelMemberStore, cl, GuildMemberCountStore, numberFormat, ThreadMemberListStore } from ".";
|
||||||
import { OnlineMemberCountStore } from "./OnlineMemberCountStore";
|
import { OnlineMemberCountStore } from "./OnlineMemberCountStore";
|
||||||
|
|
||||||
export function MemberCount({ isTooltip, tooltipGuildId }: { isTooltip?: true; tooltipGuildId?: string; }) {
|
export function MemberCount({ isTooltip, tooltipGuildId }: { isTooltip?: true; tooltipGuildId?: string; }) {
|
||||||
|
@ -30,10 +31,19 @@ export function MemberCount({ isTooltip, tooltipGuildId }: { isTooltip?: true; t
|
||||||
() => ChannelMemberStore.getProps(guildId, currentChannel?.id)
|
() => ChannelMemberStore.getProps(guildId, currentChannel?.id)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const threadGroups = useStateFromStores(
|
||||||
|
[ThreadMemberListStore],
|
||||||
|
() => ThreadMemberListStore.getMemberListSections(currentChannel.id)
|
||||||
|
);
|
||||||
|
|
||||||
if (!isTooltip && (groups.length >= 1 || groups[0].id !== "unknown")) {
|
if (!isTooltip && (groups.length >= 1 || groups[0].id !== "unknown")) {
|
||||||
onlineCount = groups.reduce((total, curr) => total + (curr.id === "offline" ? 0 : curr.count), 0);
|
onlineCount = groups.reduce((total, curr) => total + (curr.id === "offline" ? 0 : curr.count), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isTooltip && threadGroups && !isObjectEmpty(threadGroups)) {
|
||||||
|
onlineCount = Object.values(threadGroups).reduce((total, curr) => total + (curr.sectionId === "offline" ? 0 : curr.userIds.length), 0);
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
OnlineMemberCountStore.ensureCount(guildId);
|
OnlineMemberCountStore.ensureCount(guildId);
|
||||||
}, [guildId]);
|
}, [guildId]);
|
||||||
|
|
|
@ -32,6 +32,10 @@ export const GuildMemberCountStore = findStoreLazy("GuildMemberCountStore") as F
|
||||||
export const ChannelMemberStore = findStoreLazy("ChannelMemberStore") as FluxStore & {
|
export const ChannelMemberStore = findStoreLazy("ChannelMemberStore") as FluxStore & {
|
||||||
getProps(guildId: string, channelId: string): { groups: { count: number; id: string; }[]; };
|
getProps(guildId: string, channelId: string): { groups: { count: number; id: string; }[]; };
|
||||||
};
|
};
|
||||||
|
export const ThreadMemberListStore = findStoreLazy("ThreadMemberListStore") as FluxStore & {
|
||||||
|
getMemberListSections(channelId: string): { [sectionId: string]: { sectionId: string; userIds: string[]; }; };
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const settings = definePluginSettings({
|
const settings = definePluginSettings({
|
||||||
toolTip: {
|
toolTip: {
|
||||||
|
|
|
@ -20,16 +20,18 @@ import "./style.css";
|
||||||
|
|
||||||
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
|
import { NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||||
import ErrorBoundary from "@components/ErrorBoundary";
|
import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
|
import { ExpandableHeader } from "@components/ExpandableHeader";
|
||||||
import { NotesIcon, OpenExternalIcon } from "@components/Icons";
|
import { NotesIcon, OpenExternalIcon } from "@components/Icons";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import definePlugin from "@utils/types";
|
import definePlugin from "@utils/types";
|
||||||
import { findByPropsLazy } from "@webpack";
|
import { findByPropsLazy } from "@webpack";
|
||||||
import { Alerts, Button, Menu, Parser, TooltipContainer } from "@webpack/common";
|
import { Alerts, Button, Menu, Parser, TooltipContainer, useState } from "@webpack/common";
|
||||||
import { Guild, User } from "discord-types/general";
|
import { Guild, User } from "discord-types/general";
|
||||||
|
|
||||||
import { Auth, initAuth, updateAuth } from "./auth";
|
import { Auth, initAuth, updateAuth } from "./auth";
|
||||||
import { openReviewsModal } from "./components/ReviewModal";
|
import { openReviewsModal } from "./components/ReviewModal";
|
||||||
|
import ReviewsView from "./components/ReviewsView";
|
||||||
import { NotificationType } from "./entities";
|
import { NotificationType } from "./entities";
|
||||||
import { getCurrentUserInfo, readNotification } from "./reviewDbApi";
|
import { getCurrentUserInfo, readNotification } from "./reviewDbApi";
|
||||||
import { settings } from "./settings";
|
import { settings } from "./settings";
|
||||||
|
@ -76,6 +78,21 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
|
|
||||||
patches: [
|
patches: [
|
||||||
|
{
|
||||||
|
find: "showBorder:null",
|
||||||
|
replacement: {
|
||||||
|
match: /user:(\i),setNote:\i,canDM.+?\}\)/,
|
||||||
|
replace: "$&,$self.getReviewsComponent($1)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: /inline:!1,profileViewedAnalytics:\i}\),/,
|
||||||
|
replacement: {
|
||||||
|
match: /currentUser:\i,guild:\i}\)(?<=user:(\i),bio:null==\i\?.+?)/,
|
||||||
|
replace: "$&,$self.getReviewsComponent($1)"
|
||||||
|
},
|
||||||
|
predicate: () => !settings.store.preferButtonOverDropdown
|
||||||
|
},
|
||||||
{
|
{
|
||||||
find: ".BITE_SIZE,user:",
|
find: ".BITE_SIZE,user:",
|
||||||
replacement: {
|
replacement: {
|
||||||
|
@ -140,6 +157,31 @@ export default definePlugin({
|
||||||
}, 4000);
|
}, 4000);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getReviewsComponent: ErrorBoundary.wrap((user: User) => {
|
||||||
|
const [reviewCount, setReviewCount] = useState<number>();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ExpandableHeader
|
||||||
|
headerText="User Reviews"
|
||||||
|
onMoreClick={() => openReviewsModal(user.id, user.username)}
|
||||||
|
moreTooltipText={
|
||||||
|
reviewCount && reviewCount > 50
|
||||||
|
? `View all ${reviewCount} reviews`
|
||||||
|
: "Open Review Modal"
|
||||||
|
}
|
||||||
|
onDropDownClick={state => settings.store.reviewsDropdownState = !state}
|
||||||
|
defaultState={settings.store.reviewsDropdownState}
|
||||||
|
>
|
||||||
|
<ReviewsView
|
||||||
|
discordId={user.id}
|
||||||
|
name={user.username}
|
||||||
|
onFetchReviews={r => setReviewCount(r.reviewCount)}
|
||||||
|
showInput
|
||||||
|
/>
|
||||||
|
</ExpandableHeader>
|
||||||
|
);
|
||||||
|
}, { message: "Failed to render Reviews" }),
|
||||||
|
|
||||||
BiteSizeReviewsButton: ErrorBoundary.wrap(({ user }: { user: User; }) => {
|
BiteSizeReviewsButton: ErrorBoundary.wrap(({ user }: { user: User; }) => {
|
||||||
return (
|
return (
|
||||||
<TooltipContainer text="View Reviews">
|
<TooltipContainer text="View Reviews">
|
||||||
|
|
|
@ -3,10 +3,6 @@
|
||||||
--vc-rdb-spacing-size: 8px;
|
--vc-rdb-spacing-size: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
[class|="section"]:not([class|="lastSection"])+.vc-rdb-view {
|
|
||||||
margin-top: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-rdb-badge {
|
.vc-rdb-badge {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
|
|
Loading…
Add table
Reference in a new issue