Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
Fix UI/UX Page [Chats] [React Component] (#125)
Browse files Browse the repository at this point in the history
[+] fix(chat.tsx): fix togglePinApp function to use useCallback hook and update setPinApp with previous state
[+] docs(chat.tsx): update comments for handleKeyPress and handleMouseClick functions
  • Loading branch information
H0llyW00dzZ authored Nov 19, 2023
1 parent 5e0a8a7 commit e483519
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ function usePinApp() {
const config = useAppConfig();
const TauriShortcut = config.desktopShortcut;

const togglePinApp = async () => {
const togglePinApp = useCallback(async () => {
if (!isApp) {
return;
}
Expand All @@ -715,17 +715,17 @@ function usePinApp() {
sendDesktopNotification(Locale.Chat.Actions.PinAppContent.Pinned);
showToast(Locale.Chat.Actions.PinAppContent.Pinned);
}
setPinApp(!pinApp);
};
setPinApp((prevPinApp) => !prevPinApp);
}, [isApp, pinApp]);

useEffect(() => {
const handleKeyPress = (event: KeyboardEvent) => {
if (event.key === TauriShortcut) {
togglePinApp();
}
};
//Usage : Mouse+5,Mouse+4,Mouse+1(Middle Click)
//You need copy paste (e.g., "Mouse+5" paste in settings) instead of typing manually in settings
// Usage : Mouse+5,Mouse+4,Mouse+1(Middle Click)
// You need to copy-paste (e.g., Mouse+5 paste in settings) instead of typing manually in settings
const handleMouseClick = (event: MouseEvent) => {
if (event.button === 1 || event.button === 4 || event.button === 5) {
togglePinApp();
Expand Down

0 comments on commit e483519

Please sign in to comment.