ReviewDB: add more context menu shortcuts to view reviews (#2382)

Co-authored-by: V <vendicated@riseup.net>
This commit is contained in:
Sqaaakoi 2024-05-04 01:17:12 +12:00 committed by GitHub
parent 03d7e0fb93
commit 315f4f4e58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -35,13 +35,25 @@ import { getCurrentUserInfo, readNotification } from "./reviewDbApi";
import { settings } from "./settings"; import { settings } from "./settings";
import { showToast } from "./utils"; import { showToast } from "./utils";
const guildPopoutPatch: NavContextMenuPatchCallback = (children, props: { guild: Guild, onClose(): void; }) => { const guildPopoutPatch: NavContextMenuPatchCallback = (children, { guild }: { guild: Guild, onClose(): void; }) => {
children.push( children.push(
<Menu.MenuItem <Menu.MenuItem
label="View Reviews" label="View Reviews"
id="vc-rdb-server-reviews" id="vc-rdb-server-reviews"
icon={OpenExternalIcon} icon={OpenExternalIcon}
action={() => openReviewsModal(props.guild.id, props.guild.name)} action={() => openReviewsModal(guild.id, guild.name)}
/>
);
};
const userContextPatch: NavContextMenuPatchCallback = (children, { user }: { user?: User, onClose(): void; }) => {
if (!user) return;
children.push(
<Menu.MenuItem
label="View Reviews"
id="vc-rdb-user-reviews"
icon={OpenExternalIcon}
action={() => openReviewsModal(user.id, user.username)}
/> />
); );
}; };
@ -53,7 +65,10 @@ export default definePlugin({
settings, settings,
contextMenus: { contextMenus: {
"guild-header-popout": guildPopoutPatch "guild-header-popout": guildPopoutPatch,
"guild-context": guildPopoutPatch,
"user-context": userContextPatch,
"user-profile-actions": userContextPatch
}, },
patches: [ patches: [