nice count in the sidebar dynamic
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Avatar } from "antd";
|
import { Avatar, Tooltip } from "antd";
|
||||||
import { useRecoilValue } from "recoil";
|
import { useRecoilValue } from "recoil";
|
||||||
import {
|
import {
|
||||||
checkIncomingMessageSelector,
|
checkIncomingMessageSelector,
|
||||||
@@ -7,6 +7,7 @@ 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";
|
||||||
|
|
||||||
export default function PriorityConvoRow(props: {
|
export default function PriorityConvoRow(props: {
|
||||||
conversation: Conversation;
|
conversation: Conversation;
|
||||||
@@ -51,6 +52,24 @@ justify-center rounded-lg text-slate-400 font-bold hover:cursor-pointer text-xs"
|
|||||||
{moment(props.conversation.lastActivityDate.toDate()).fromNow()}
|
{moment(props.conversation.lastActivityDate.toDate()).fromNow()}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
{isSelected && (
|
||||||
|
<>
|
||||||
|
<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">
|
||||||
|
<FaMicrophoneAlt className="ml-auto text-md text-orange-800" />
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
|
<Tooltip
|
||||||
|
title={"Play last convo chunk by pressing SPACE on keyboard."}
|
||||||
|
>
|
||||||
|
<span className="p-2 rounded-full hover:cursor-pointer hover:bg-slate-200">
|
||||||
|
<FaPlay className="ml-auto text-md text-emerald-800" />
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,8 +47,6 @@ export default function Priority() {
|
|||||||
|
|
||||||
const selectingPriorityConvoHandler = (event) => {
|
const selectingPriorityConvoHandler = (event) => {
|
||||||
const key = event.key;
|
const key = event.key;
|
||||||
console.log(mapShortcutsToConvoId);
|
|
||||||
console.log(key);
|
|
||||||
|
|
||||||
// select the convo based on the right convo
|
// select the convo based on the right convo
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,11 @@ import {
|
|||||||
} from "react-icons/fa";
|
} from "react-icons/fa";
|
||||||
import { HiSpeakerphone } from "react-icons/hi";
|
import { HiSpeakerphone } from "react-icons/hi";
|
||||||
import Priority from "./Priority";
|
import Priority from "./Priority";
|
||||||
|
import { useRecoilValue } from "recoil";
|
||||||
|
import {
|
||||||
|
countNavigationContentSelector,
|
||||||
|
NavigationContentCount,
|
||||||
|
} from "../../recoil/main";
|
||||||
|
|
||||||
function Sidebar() {
|
function Sidebar() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -28,6 +33,10 @@ function Sidebar() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const navCountObject: NavigationContentCount = useRecoilValue(
|
||||||
|
countNavigationContentSelector
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col justify-start items-baseline w-[20rem]">
|
<div className="flex flex-col justify-start items-baseline w-[20rem]">
|
||||||
{/* new button */}
|
{/* new button */}
|
||||||
@@ -73,7 +82,11 @@ function Sidebar() {
|
|||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span className="text-slate-300 text-md ml-auto">4</span>
|
{navCountObject.defaultCount > 0 && (
|
||||||
|
<span className="text-slate-300 text-md ml-auto">
|
||||||
|
{navCountObject.defaultCount}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
@@ -97,7 +110,11 @@ function Sidebar() {
|
|||||||
Later
|
Later
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span className="text-slate-300 text-md ml-auto">1</span>
|
{navCountObject.laterCount > 0 && (
|
||||||
|
<span className="text-slate-300 text-md ml-auto">
|
||||||
|
{navCountObject.laterCount}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
@@ -120,6 +137,12 @@ 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">
|
||||||
Done
|
Done
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
{navCountObject.doneCount > 0 && (
|
||||||
|
<span className="text-slate-300 text-md ml-auto">
|
||||||
|
{navCountObject.doneCount}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<Divider />
|
<Divider />
|
||||||
@@ -145,10 +168,16 @@ function Sidebar() {
|
|||||||
Drawer
|
Drawer
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<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">
|
<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">
|
||||||
<HiSpeakerphone />
|
<HiSpeakerphone />
|
||||||
<span>new</span>
|
<span>new</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
|
{navCountObject.drawerCount > 0 && (
|
||||||
|
<span className="text-slate-300 text-md ml-auto">
|
||||||
|
{navCountObject.drawerCount}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<Divider />
|
<Divider />
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ export enum RecoilActions {
|
|||||||
USER_DATA = "USER_DATA",
|
USER_DATA = "USER_DATA",
|
||||||
|
|
||||||
SELECTED_CONVERSATION_ATOM = "SELECTED_CONVERSATION_ATOM",
|
SELECTED_CONVERSATION_ATOM = "SELECTED_CONVERSATION_ATOM",
|
||||||
|
|
||||||
|
COUNT_DEFAULT_CONVOS_SELECTOR = "COUNT_DEFAULT_CONVOS_SELECTOR",
|
||||||
|
COUNT_NAVIGATION_ITEMS = "COUNT_NAVIGATION_ITEMS",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const nirvanaUserDataAtom = atom<NirvanaUser | null>({
|
export const nirvanaUserDataAtom = atom<NirvanaUser | null>({
|
||||||
@@ -198,6 +201,48 @@ export const doneConvosSelector = selector<Conversation[]>({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const countDefaultConvosSelector = selector<number>({
|
||||||
|
key: RecoilActions.COUNT_DEFAULT_CONVOS_SELECTOR,
|
||||||
|
get: ({ get }) => {
|
||||||
|
const sortedConvos = get(sortedRoomSelector);
|
||||||
|
|
||||||
|
const userMemberMap = get(allUsersConversationsAtom);
|
||||||
|
const defaultConvos = sortedConvos.filter((convo) => {
|
||||||
|
return (
|
||||||
|
userMemberMap.get(convo.id)?.state == ConversationMemberState.default &&
|
||||||
|
!convo.membersInLiveRoom?.length
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
return defaultConvos.length;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export interface NavigationContentCount {
|
||||||
|
doneCount: number;
|
||||||
|
defaultCount: number;
|
||||||
|
laterCount: number;
|
||||||
|
drawerCount: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const countNavigationContentSelector = selector<NavigationContentCount>({
|
||||||
|
key: RecoilActions.COUNT_NAVIGATION_ITEMS,
|
||||||
|
get: ({ get }) => {
|
||||||
|
const laterConvos = get(laterConvosSelector);
|
||||||
|
const doneConvos = get(doneConvosSelector);
|
||||||
|
const defaultCount = get(countDefaultConvosSelector);
|
||||||
|
|
||||||
|
const navCountObject: NavigationContentCount = {
|
||||||
|
defaultCount,
|
||||||
|
laterCount: laterConvos.length,
|
||||||
|
doneCount: doneConvos.length,
|
||||||
|
drawerCount: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
return navCountObject;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
export enum RelativeTimeConvosSections {
|
export enum RelativeTimeConvosSections {
|
||||||
today = "TODAY",
|
today = "TODAY",
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user