starting keyboard shortcuts and all
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { Avatar, Tooltip } from "antd";
|
import { Avatar, Tooltip } from "antd";
|
||||||
import { useRecoilValue } from "recoil";
|
import { useRecoilState, useRecoilValue } from "recoil";
|
||||||
import {
|
import {
|
||||||
checkIncomingMessageSelector,
|
checkIncomingMessageSelector,
|
||||||
selectedPriorityConvoAtom,
|
selectedPriorityConvoAtom,
|
||||||
@@ -7,14 +7,23 @@ import {
|
|||||||
import Conversation from "../../../common/models/conversation";
|
import Conversation from "../../../common/models/conversation";
|
||||||
import { MasterAvatarGroupWithUserFetch } from "../UserDetails/MasterAvatarGroup";
|
import { MasterAvatarGroupWithUserFetch } from "../UserDetails/MasterAvatarGroup";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { FaMicrophoneAlt, FaPlay } from "react-icons/fa";
|
import {
|
||||||
|
FaCaretRight,
|
||||||
|
FaCircle,
|
||||||
|
FaMicrophoneAlt,
|
||||||
|
FaPlay,
|
||||||
|
} from "react-icons/fa";
|
||||||
|
import { useCallback } from "react";
|
||||||
|
import { FaAngleRight } from "react-icons/fa";
|
||||||
|
|
||||||
export default function PriorityConvoRow(props: {
|
export default function PriorityConvoRow(props: {
|
||||||
conversation: Conversation;
|
conversation: Conversation;
|
||||||
itemIndex: number;
|
itemIndex: number;
|
||||||
}) {
|
}) {
|
||||||
// figure out if this is a selectedConvo
|
// figure out if this is a selectedConvo
|
||||||
const selectedConvo = useRecoilValue(selectedPriorityConvoAtom);
|
const [selectedConvo, setSelectedConvo] = useRecoilState(
|
||||||
|
selectedPriorityConvoAtom
|
||||||
|
);
|
||||||
|
|
||||||
const isSelected = selectedConvo == props.conversation.id ? true : false;
|
const isSelected = selectedConvo == props.conversation.id ? true : false;
|
||||||
|
|
||||||
@@ -26,10 +35,15 @@ export default function PriorityConvoRow(props: {
|
|||||||
// todo: implement method in conversation
|
// todo: implement method in conversation
|
||||||
// const isOneonOne =
|
// const isOneonOne =
|
||||||
|
|
||||||
|
const handleSelectConvo = useCallback(() => {
|
||||||
|
setSelectedConvo(props.conversation.id);
|
||||||
|
}, [props.conversation]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
|
onClick={handleSelectConvo}
|
||||||
className={`group flex flex-row items-center rounded-lg p-2 w-full transition-all hover:cursor-pointer ${
|
className={`group flex flex-row items-center rounded-lg p-2 w-full transition-all hover:cursor-pointer ${
|
||||||
isSelected && "bg-slate-50 shadow-lg scale-125"
|
isSelected && "bg-slate-50 shadow-lg scale-125 w-[25rem]"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<MasterAvatarGroupWithUserFetch
|
<MasterAvatarGroupWithUserFetch
|
||||||
@@ -48,8 +62,13 @@ justify-center rounded-lg text-slate-400 font-bold hover:cursor-pointer text-xs"
|
|||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span className="text-slate-300 text-xs">
|
<span className="flex flex-row">
|
||||||
{moment(props.conversation.lastActivityDate.toDate()).fromNow()}
|
{isNewIncoming && (
|
||||||
|
<FaCircle className="ml-2 text-orange-500 mr-2 animate-pulse text-[0.75rem]" />
|
||||||
|
)}
|
||||||
|
<span className="text-slate-300 text-xs">
|
||||||
|
{moment(props.conversation.lastActivityDate.toDate()).fromNow()}
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
@@ -57,7 +76,7 @@ justify-center rounded-lg text-slate-400 font-bold hover:cursor-pointer text-xs"
|
|||||||
<>
|
<>
|
||||||
<Tooltip title={"Record by pressing and holding R on keyboard."}>
|
<Tooltip title={"Record by pressing and holding R on keyboard."}>
|
||||||
<span className="ml-auto p-2 rounded-full hover:cursor-pointer hover:bg-slate-200">
|
<span className="ml-auto p-2 rounded-full hover:cursor-pointer hover:bg-slate-200">
|
||||||
<FaMicrophoneAlt className="ml-auto text-md text-orange-800" />
|
<FaMicrophoneAlt className="ml-auto text-lg text-orange-800" />
|
||||||
</span>
|
</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
@@ -65,7 +84,12 @@ justify-center rounded-lg text-slate-400 font-bold hover:cursor-pointer text-xs"
|
|||||||
title={"Play last convo chunk by pressing SPACE on keyboard."}
|
title={"Play last convo chunk by pressing SPACE on keyboard."}
|
||||||
>
|
>
|
||||||
<span className="p-2 rounded-full hover:cursor-pointer hover:bg-slate-200">
|
<span className="p-2 rounded-full hover:cursor-pointer hover:bg-slate-200">
|
||||||
<FaPlay className="ml-auto text-md text-emerald-800" />
|
<FaPlay className="ml-auto text-lg text-emerald-800" />
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip title={"View Details"}>
|
||||||
|
<span className="p-2 rounded-full hover:cursor-pointer hover:bg-slate-200">
|
||||||
|
<FaAngleRight className="ml-auto text-md text-slate-400" />
|
||||||
</span>
|
</span>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import { GlobalHotKeys, KeyMap, configure } from "react-hotkeys";
|
|||||||
import { selectedPriorityConvoAtom } from "../../recoil/main";
|
import { selectedPriorityConvoAtom } from "../../recoil/main";
|
||||||
import { useSetRecoilState } from "recoil";
|
import { useSetRecoilState } from "recoil";
|
||||||
|
|
||||||
configure({
|
|
||||||
ignoreTags: [],
|
|
||||||
});
|
|
||||||
|
|
||||||
export default function KeyboardShortcutHandler() {
|
export default function KeyboardShortcutHandler() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
configure({
|
||||||
|
ignoreTags: [],
|
||||||
|
});
|
||||||
|
|
||||||
const setSelectedPriorityConvo = useSetRecoilState(selectedPriorityConvoAtom);
|
const setSelectedPriorityConvo = useSetRecoilState(selectedPriorityConvoAtom);
|
||||||
|
|
||||||
const handleEscape = () => {
|
const handleEscape = () => {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {
|
|||||||
selectedPriorityConvoAtom,
|
selectedPriorityConvoAtom,
|
||||||
} from "../../recoil/main";
|
} from "../../recoil/main";
|
||||||
import PriorityConvoRow from "../Conversations/PriorityConvoRow";
|
import PriorityConvoRow from "../Conversations/PriorityConvoRow";
|
||||||
import { GlobalHotKeys, HotKeys } from "react-hotkeys";
|
import { configure, GlobalHotKeys, HotKeys, KeyMap } from "react-hotkeys";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
|
|
||||||
@@ -62,12 +62,37 @@ export default function Priority() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const keyMap = {
|
configure({
|
||||||
|
ignoreTags: ["input", "select", "textarea"],
|
||||||
|
});
|
||||||
|
|
||||||
|
const startRecording = () => {
|
||||||
|
toast.loading("speaking to Patels");
|
||||||
|
};
|
||||||
|
|
||||||
|
const stopRecording = () => {
|
||||||
|
console.log("stop recording");
|
||||||
|
toast.dismiss();
|
||||||
|
};
|
||||||
|
|
||||||
|
const keyMap: KeyMap = {
|
||||||
SELECT_PRIORITY_CONVO: ["1", "2", "3", "4", "5", "6", "7", "8"],
|
SELECT_PRIORITY_CONVO: ["1", "2", "3", "4", "5", "6", "7", "8"],
|
||||||
|
START_RECORDING: {
|
||||||
|
name: "START RECORDING",
|
||||||
|
sequence: "r",
|
||||||
|
action: "keydown",
|
||||||
|
},
|
||||||
|
STOP_RECORDING: {
|
||||||
|
name: "STOP RECORDING",
|
||||||
|
sequence: "r",
|
||||||
|
action: "keyup",
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlers = {
|
const handlers = {
|
||||||
SELECT_PRIORITY_CONVO: selectingPriorityConvoHandler,
|
SELECT_PRIORITY_CONVO: selectingPriorityConvoHandler,
|
||||||
|
START_RECORDING: startRecording,
|
||||||
|
STOP_RECORDING: stopRecording,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -165,10 +165,10 @@ function Sidebar() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<span className="text-md text-slate-400 font-semibold group-hover:text-slate-600">
|
<span className="text-md text-slate-400 font-semibold group-hover:text-slate-600">
|
||||||
Drawer
|
Drawer{" "}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span className="text-emerald-700 bg-emerald-200 bg-opacity-20 p-1 rounded-md text-xs font-semibold flex items-center flex-row space-x-1">
|
<span className="ml-2 text-emerald-700 bg-emerald-200 bg-opacity-20 p-1 rounded-md text-xs font-semibold flex items-center flex-row space-x-1">
|
||||||
<HiSpeakerphone />
|
<HiSpeakerphone />
|
||||||
<span>new</span>
|
<span>new</span>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user