mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-01-09 17:36:23 +00:00
Add Ignored Users tab to ServerInfo
This commit is contained in:
parent
0fd76ab15a
commit
81866a162c
2 changed files with 21 additions and 3 deletions
|
@ -31,7 +31,8 @@ export function openGuildInfoModal(guild: Guild) {
|
|||
const enum Tabs {
|
||||
ServerInfo,
|
||||
Friends,
|
||||
BlockedUsers
|
||||
BlockedUsers,
|
||||
IgnoredUsers
|
||||
}
|
||||
|
||||
interface GuildProps {
|
||||
|
@ -44,7 +45,8 @@ interface RelationshipProps extends GuildProps {
|
|||
|
||||
const fetched = {
|
||||
friends: false,
|
||||
blocked: false
|
||||
blocked: false,
|
||||
ignored: false
|
||||
};
|
||||
|
||||
function renderTimestamp(timestamp: number) {
|
||||
|
@ -56,10 +58,12 @@ function renderTimestamp(timestamp: number) {
|
|||
function GuildInfoModal({ guild }: GuildProps) {
|
||||
const [friendCount, setFriendCount] = useState<number>();
|
||||
const [blockedCount, setBlockedCount] = useState<number>();
|
||||
const [ignoredCount, setIgnoredCount] = useState<number>();
|
||||
|
||||
useEffect(() => {
|
||||
fetched.friends = false;
|
||||
fetched.blocked = false;
|
||||
fetched.ignored = false;
|
||||
}, []);
|
||||
|
||||
const [currentTab, setCurrentTab] = useState(Tabs.ServerInfo);
|
||||
|
@ -132,12 +136,19 @@ function GuildInfoModal({ guild }: GuildProps) {
|
|||
>
|
||||
Blocked Users{blockedCount !== undefined ? ` (${blockedCount})` : ""}
|
||||
</TabBar.Item>
|
||||
<TabBar.Item
|
||||
className={cl("tab", { selected: currentTab === Tabs.IgnoredUsers })}
|
||||
id={Tabs.IgnoredUsers}
|
||||
>
|
||||
Ignored Users{ignoredCount !== undefined ? ` (${ignoredCount})` : ""}
|
||||
</TabBar.Item>
|
||||
</TabBar>
|
||||
|
||||
<div className={cl("tab-content")}>
|
||||
{currentTab === Tabs.ServerInfo && <ServerInfoTab guild={guild} />}
|
||||
{currentTab === Tabs.Friends && <FriendsTab guild={guild} setCount={setFriendCount} />}
|
||||
{currentTab === Tabs.BlockedUsers && <BlockedUsersTab guild={guild} setCount={setBlockedCount} />}
|
||||
{currentTab === Tabs.IgnoredUsers && <IgnoredUserTab guild={guild} setCount={setIgnoredCount} />}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -211,7 +222,13 @@ function BlockedUsersTab({ guild, setCount }: RelationshipProps) {
|
|||
return UserList("blocked", guild, blockedIds, setCount);
|
||||
}
|
||||
|
||||
function UserList(type: "friends" | "blocked", guild: Guild, ids: string[], setCount: (count: number) => void) {
|
||||
function IgnoredUserTab({ guild, setCount }: RelationshipProps) {
|
||||
const ignoredIds = Object.keys(RelationshipStore.getRelationships()).filter(id => RelationshipStore.isIgnored(id));
|
||||
return UserList("ignored", guild, ignoredIds, setCount);
|
||||
}
|
||||
|
||||
|
||||
function UserList(type: "friends" | "blocked" | "ignored", guild: Guild, ids: string[], setCount: (count: number) => void) {
|
||||
const missing = [] as string[];
|
||||
const members = [] as string[];
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ export let GuildMemberStore: Stores.GuildMemberStore & t.FluxStore;
|
|||
export let RelationshipStore: Stores.RelationshipStore & t.FluxStore & {
|
||||
/** Get the date (as a string) that the relationship was created */
|
||||
getSince(userId: string): string;
|
||||
isIgnored(userId: string): boolean;
|
||||
};
|
||||
|
||||
export let EmojiStore: t.EmojiStore;
|
||||
|
|
Loading…
Reference in a new issue