mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-20 06:30:35 +00:00
A pr was wanted
This commit is contained in:
parent
5e9a9fe836
commit
6875ff0d9f
3 changed files with 42 additions and 0 deletions
3
src/plugins/UnreadCountBadge/README.md
Normal file
3
src/plugins/UnreadCountBadge/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
Show a badge in the channel list for unread messages.
|
||||
|
||||
![image](https://github.com/user-attachments/assets/fdec8682-8db6-4a24-be48-b13a16ad9d00)
|
36
src/plugins/UnreadCountBadge/index.tsx
Normal file
36
src/plugins/UnreadCountBadge/index.tsx
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { ReadStateStore, useStateFromStores } from "@webpack/common";
|
||||
const { NumberBadge } = findByPropsLazy("NumberBadge");
|
||||
|
||||
import "./styles.css";
|
||||
|
||||
export default definePlugin({
|
||||
name: "UnreadCountBadge",
|
||||
authors: [Devs.Joona],
|
||||
description: "Show unread count in the channel list",
|
||||
patches: [
|
||||
// Kanged from typingindicators
|
||||
{
|
||||
find: "UNREAD_IMPORTANT:",
|
||||
replacement: {
|
||||
match: /\.name\),.{0,120}\.children.+?:null(?<=,channel:(\i).+?)/,
|
||||
replace: "$&,$self.CountBadge({channelId:$1.id})"
|
||||
}
|
||||
},
|
||||
],
|
||||
|
||||
CountBadge: ErrorBoundary.wrap(({ channelId }: { channelId: string; }) => {
|
||||
const unreadCount = useStateFromStores([ReadStateStore], () => ReadStateStore.getUnreadCount(channelId));
|
||||
if (!unreadCount) return null;
|
||||
return <NumberBadge count={unreadCount} color="var(--brand-500)" className="unreadCountBadge" />;
|
||||
}, { noop: true })
|
||||
});
|
3
src/plugins/UnreadCountBadge/styles.css
Normal file
3
src/plugins/UnreadCountBadge/styles.css
Normal file
|
@ -0,0 +1,3 @@
|
|||
.unreadCountBadge {
|
||||
margin-left: 4px;
|
||||
}
|
Loading…
Reference in a new issue