feat(WhoReacted): add toggle to disable click (#46)

* squash (#8)

squash

* lil fix

---------

Co-authored-by: thororen1234 <78185467+thororen1234@users.noreply.github.com>
This commit is contained in:
panbread 2024-10-03 18:55:53 +04:00 committed by GitHub
parent 026d39aef2
commit 11ad3bceb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -16,12 +16,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { definePluginSettings } from "@api/Settings";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import { sleep } from "@utils/misc";
import { Queue } from "@utils/Queue";
import { useForceUpdater } from "@utils/react";
import definePlugin from "@utils/types";
import definePlugin, { OptionType } from "@utils/types";
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
import { ChannelStore, Constants, FluxDispatcher, React, RestAPI, Tooltip } from "@webpack/common";
import { CustomEmoji } from "@webpack/types";
@ -97,11 +98,20 @@ function handleClickAvatar(event: React.MouseEvent<HTMLElement, MouseEvent>) {
event.stopPropagation();
}
const settings = definePluginSettings({
avatarClick: {
description: "Toggle clicking avatars in reactions",
type: OptionType.BOOLEAN,
default: false,
restartNeeded: true
}
});
export default definePlugin({
name: "WhoReacted",
description: "Renders the avatars of users who reacted to a message",
authors: [Devs.Ven, Devs.KannaDev, Devs.newwares],
settings,
patches: [
{
find: ",reactionRef:",
@ -159,10 +169,13 @@ export default definePlugin({
const reactions = getReactionsWithQueue(message, emoji, type);
const users = Object.values(reactions).filter(Boolean) as User[];
console.log(settings.store.avatarClick);
return (
<div
style={{ marginLeft: "0.5em", transform: "scale(0.9)" }}
>
{settings.store.avatarClick ? (
<div onClick={handleClickAvatar}>
<UserSummaryItem
users={users}
@ -174,6 +187,19 @@ export default definePlugin({
renderMoreUsers={makeRenderMoreUsers(users)}
/>
</div>
) : (
<div>
<UserSummaryItem
users={users}
guildId={ChannelStore.getChannel(message.channel_id)?.guild_id}
renderIcon={false}
max={5}
showDefaultAvatarsForNullUsers
showUserPopout={false}
renderMoreUsers={makeRenderMoreUsers(users)}
/>
</div>
)}
</div>
);
},