diff --git a/plugins/pronoundb/compactMode.scss b/plugins/pronoundb/compactMode.scss new file mode 100644 index 0000000..0c746bc --- /dev/null +++ b/plugins/pronoundb/compactMode.scss @@ -0,0 +1,16 @@ +$increase: 4rem; + +[class*="latin12CompactTimeStamp"] { + /* originally 2.25rem */ + width: #{2.25rem + $increase} !important; + --timestamp-width: #{2.25rem + $increase} !important; +} +[class*="latin12CompactTimeStamp"]::before { + /* originally --timestamp-width */ + --avatar-size: 2.25rem !important; +} + +:root { + /* originally 5rem, increase by the same amount. */ + --custom-message-margin-compact-indent: #{5rem + $increase}; +} \ No newline at end of file diff --git a/plugins/pronoundb/db.ts b/plugins/pronoundb/db.ts index 32bad00..b7b15a5 100644 --- a/plugins/pronoundb/db.ts +++ b/plugins/pronoundb/db.ts @@ -1,7 +1,16 @@ import type { FluxStore } from "@uwu/shelter-defs"; -const UserProfileStore = shelter.flux.stores.UserProfileStore as FluxStore<{ +const UserProfileStore = shelter.flux.storesFlat.UserProfileStore as FluxStore<{ getUserProfile(id: string): { bio: string; pronouns: string } | undefined; + getGuildMemberProfile( + u: string, + g: string, + ): { bio: string; pronouns: string } | null; +}>; + +const SelectedGuildStore = shelter.flux.storesFlat + .SelectedGuildStore as FluxStore<{ + getGuildId(): string; }>; const pronouns = { @@ -9,10 +18,10 @@ const pronouns = { it: "it/its", she: "she/her", they: "they/them", - any: "Any pronouns", - other: "Other pronouns", - ask: "Ask me my pronouns", - avoid: "Avoid pronouns, use my name", + any: "Any", + other: "Other", + ask: "Ask me", + avoid: "Use name", }; const additionalPronouns = [ @@ -35,11 +44,23 @@ const pronounsToSearch = Object.values(pronouns) .filter((p) => p.includes("/")) .sort((a, b) => b.length - a.length); -export const fromStore = (id) => { +export const fromStore = (id: string) => { const profile = UserProfileStore.getUserProfile(id); + const scoped = UserProfileStore.getGuildMemberProfile( + id, + SelectedGuildStore.getGuildId(), + ); if (!profile) return; - const pronounSource = (profile.pronouns + profile.bio).toLowerCase(); - return pronounsToSearch.find((p) => pronounSource.includes(p)); + + const search = (s: string) => + s && pronounsToSearch.find((p) => s.includes(p)); + + return ( + search(scoped?.pronouns) ?? + search(scoped?.bio) ?? + search(profile.pronouns) ?? + search(profile.bio) + ); }; const endpoint = "https://pronoundb.org/api/v2/lookup?platform=discord&ids="; diff --git a/plugins/pronoundb/index.tsx b/plugins/pronoundb/index.tsx index 90173c9..ac72ab4 100644 --- a/plugins/pronoundb/index.tsx +++ b/plugins/pronoundb/index.tsx @@ -5,10 +5,13 @@ const { observeDom, util: { getFiber, reactFiberWalker }, ui: { Space }, + solid: { Show }, } = shelter; import { fetchPronouns, fromStore } from "./db.js"; +import "./compactMode.scss"; // css modules brrr + // I love async! const patchedEls = new WeakSet(); @@ -31,18 +34,17 @@ async function inject(el) { pronouns = fromStore(authorId); } - if (!pronouns) pronouns = "Unspecified"; - - el.insertAdjacentElement( - "beforebegin", - ( - - - {pronouns} • - - - ) as HTMLSpanElement, - ); + if (pronouns) + el.insertAdjacentElement( + "beforebegin", + ( + + + {pronouns} • + + + ) as HTMLSpanElement, + ); } function onDispatch() { diff --git a/plugins/pronoundb/lune.config.js b/plugins/pronoundb/lune.config.js new file mode 100644 index 0000000..357136c --- /dev/null +++ b/plugins/pronoundb/lune.config.js @@ -0,0 +1,5 @@ +import { defineConfig } from "@uwu/lune"; + +export default defineConfig({ + cssModules: true, +});