Fix KeyboardShortcut menu, person upload picture (#2669)

* Fix KeyboardShortcut menu, person upload picture

* Fixes
This commit is contained in:
Charles Bochet
2023-11-23 13:44:54 +01:00
committed by GitHub
parent 9c4f402102
commit 9dabe44d0f
16 changed files with 168 additions and 35 deletions

View File

@ -25,7 +25,8 @@ import {
} from './CommandMenuStyles';
export const CommandMenu = () => {
const { openCommandMenu, closeCommandMenu } = useCommandMenu();
const { openCommandMenu, closeCommandMenu, toggleCommandMenu } =
useCommandMenu();
const openActivityRightDrawer = useOpenActivityRightDrawer();
const isCommandMenuOpened = useRecoilValue(isCommandMenuOpenedState);
const [search, setSearch] = useState('');
@ -35,7 +36,7 @@ export const CommandMenu = () => {
'ctrl+k,meta+k',
() => {
setSearch('');
openCommandMenu();
toggleCommandMenu();
},
AppHotkeyScope.CommandMenu,
[openCommandMenu, setSearch],
@ -154,9 +155,11 @@ export const CommandMenu = () => {
Icon={() => (
<Avatar
type="rounded"
avatarUrl={null}
avatarUrl={person.avatarUrl}
colorId={person.id}
placeholder={person.displayName}
placeholder={
person.name?.firstName + ' ' + person.name?.lastName
}
/>
)}
/>

View File

@ -9,7 +9,9 @@ import { isCommandMenuOpenedState } from '../states/isCommandMenuOpenedState';
import { Command } from '../types/Command';
export const useCommandMenu = () => {
const [, setIsCommandMenuOpened] = useRecoilState(isCommandMenuOpenedState);
const [isCommandMenuOpened, setIsCommandMenuOpened] = useRecoilState(
isCommandMenuOpenedState,
);
const setCommands = useSetRecoilState(commandMenuCommandsState);
const {
setHotkeyScopeAndMemorizePreviousScope,
@ -26,6 +28,14 @@ export const useCommandMenu = () => {
goBackToPreviousHotkeyScope();
};
const toggleCommandMenu = () => {
if (isCommandMenuOpened) {
closeCommandMenu();
} else {
openCommandMenu();
}
};
const addToCommandMenu = (addCommand: Command[]) => {
setCommands((prev) => [...prev, ...addCommand]);
};
@ -37,6 +47,7 @@ export const useCommandMenu = () => {
return {
openCommandMenu,
closeCommandMenu,
toggleCommandMenu,
addToCommandMenu,
setToIntitialCommandMenu,
};