BetterQuickReact: Configurable column count, toggle frequent emojis without reloading

This commit is contained in:
Sqaaakoi 2024-03-14 21:26:33 +13:00
parent 3d9dc75b3e
commit 394a25ff15
No known key found for this signature in database
2 changed files with 35 additions and 7 deletions

View file

@ -1,6 +1,13 @@
/* Fixes to make the quick reactions look better */
[class*="wrapper_"][role="group"]:has(>[id*="message-quickreact-"]:nth-child(5)) {
padding: 4px 1px 6px;
gap: 2px;
.vc-better-quick-react[role="group"] {
padding: 4px 0 6px;
justify-self: center;
gap: 4px;
max-width: calc(var(--vc-better-quick-react-columns) * 44px);
grid-template-columns: repeat(var(--vc-better-quick-react-columns), 40px);
}
[class*="menu_"]:has(>div>.vc-better-quick-react[role="group"]) {
max-width: fit-content
}

View file

@ -24,6 +24,13 @@ export const settings = definePluginSettings({
markers: makeRange(1, 16, 1),
stickToMarkers: true
},
columns: {
description: "Columns of quick reactions to display",
type: OptionType.SLIDER,
default: 4,
markers: makeRange(4, 10, 1),
stickToMarkers: true
},
});
export default definePlugin({
@ -35,10 +42,9 @@ export default definePlugin({
patches: [
{
find: "this.favoriteEmojisWithoutFetchingLatest.concat",
predicate: () => settings.store.frequentEmojis,
replacement: {
match: "this.favoriteEmojisWithoutFetchingLatest.concat",
replace: "[].concat"
match: /(this\.favoriteEmojisWithoutFetchingLatest)\.concat/,
replace: "($self.settings.store.frequentEmojis?[]:$1).concat"
}
},
{
@ -47,9 +53,24 @@ export default definePlugin({
match: /(\i)\.length>4&&\((\i)\.length=4\);/,
replace: "$1.length>$self.getMaxQuickReactions()&&($2.length=$self.getMaxQuickReactions());"
}
},
{
find: "default.Messages.ADD_REACTION_NAMED.format",
replacement: {
match: /className:(\i)\.wrapper,/,
replace: "className:\"vc-better-quick-react \"+$1.wrapper,style:{\"--vc-better-quick-react-columns\":$self.settings.store.columns},"
}
},
// MenuGroup doesn't accept styles or anything special by default :/
{
find: "{MenuGroup:function()",
replacement: {
match: /role:"group",/,
replace: "role:\"group\",style:arguments[0].style,"
}
}
],
getMaxQuickReactions() {
return settings.store.rows * 4;
return settings.store.rows * settings.store.columns;
}
});