fix: missing context menu in user's avatar
This commit is contained in:
@@ -7376,40 +7376,6 @@
|
||||
"store:deny-values"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"theme:default"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "theme:allow-get-theme -> Enables the get_theme command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"theme:allow-get-theme"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "theme:allow-set-theme -> Enables the set_theme command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"theme:allow-set-theme"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "theme:deny-get-theme -> Denies the get_theme command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"theme:deny-get-theme"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "theme:deny-set-theme -> Denies the set_theme command without any pre-configured scope.",
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"theme:deny-set-theme"
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "updater:default -> This permission set configures which kind of\nupdater functions are exposed to the frontend.\n\n#### Granted Permissions\n\nThe full workflow from checking for updates to installing them\nis enabled.\n\n",
|
||||
"type": "string",
|
||||
|
||||
@@ -1,47 +1,15 @@
|
||||
import { cn } from "@/commons";
|
||||
import { LumeWindow } from "@/system";
|
||||
import { Menu, MenuItem } from "@tauri-apps/api/menu";
|
||||
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
||||
import { useCallback } from "react";
|
||||
import { User } from "../user";
|
||||
import { useNoteContext } from "./provider";
|
||||
|
||||
export function NoteUser({ className }: { className?: string }) {
|
||||
const event = useNoteContext();
|
||||
|
||||
const showContextMenu = useCallback(async (e: React.MouseEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
const menuItems = await Promise.all([
|
||||
MenuItem.new({
|
||||
text: "View Profile",
|
||||
action: () => LumeWindow.openProfile(event.pubkey),
|
||||
}),
|
||||
MenuItem.new({
|
||||
text: "Copy Public Key",
|
||||
action: async () => {
|
||||
const pubkey = await event.pubkeyAsBech32();
|
||||
await writeText(pubkey);
|
||||
},
|
||||
}),
|
||||
]);
|
||||
|
||||
const menu = await Menu.new({
|
||||
items: menuItems,
|
||||
});
|
||||
|
||||
await menu.popup().catch((e) => console.error(e));
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<User.Provider pubkey={event.pubkey}>
|
||||
<User.Root className={cn("flex items-start justify-between", className)}>
|
||||
<div className="flex w-full gap-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => showContextMenu(e)}
|
||||
className="shrink-0"
|
||||
>
|
||||
<button type="button" className="shrink-0">
|
||||
<User.Avatar className="rounded-full size-8" />
|
||||
</button>
|
||||
<div className="flex items-center w-full gap-3">
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { appSettings, cn } from "@/commons";
|
||||
import { LumeWindow } from "@/system";
|
||||
import * as Avatar from "@radix-ui/react-avatar";
|
||||
import { useStore } from "@tanstack/react-store";
|
||||
import { Menu, MenuItem } from "@tauri-apps/api/menu";
|
||||
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
||||
import { minidenticon } from "minidenticons";
|
||||
import { useMemo } from "react";
|
||||
import { useCallback, useMemo } from "react";
|
||||
import { useUserContext } from "./provider";
|
||||
|
||||
export function UserAvatar({ className }: { className?: string }) {
|
||||
@@ -30,8 +33,32 @@ export function UserAvatar({ className }: { className?: string }) {
|
||||
[user.pubkey],
|
||||
);
|
||||
|
||||
const showContextMenu = useCallback(async (e: React.MouseEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
const menuItems = await Promise.all([
|
||||
MenuItem.new({
|
||||
text: "View Profile",
|
||||
action: () => LumeWindow.openProfile(user.pubkey),
|
||||
}),
|
||||
MenuItem.new({
|
||||
text: "Copy Public Key",
|
||||
action: async () => {
|
||||
await writeText(user.pubkey);
|
||||
},
|
||||
}),
|
||||
]);
|
||||
|
||||
const menu = await Menu.new({
|
||||
items: menuItems,
|
||||
});
|
||||
|
||||
await menu.popup().catch((e) => console.error(e));
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Avatar.Root
|
||||
onClick={(e) => showContextMenu(e)}
|
||||
className={cn(
|
||||
"shrink-0 block overflow-hidden bg-neutral-200 dark:bg-neutral-800",
|
||||
className,
|
||||
|
||||
Reference in New Issue
Block a user