smooth selection with feedback when selecting someone
This commit is contained in:
@@ -156,6 +156,8 @@ export function TerminalProvider({ children }: { children?: React.ReactNode }) {
|
|||||||
// not 100% consistent to the second, but still works...don't need atomicity
|
// not 100% consistent to the second, but still works...don't need atomicity
|
||||||
const handleQuickDial = useCallback(
|
const handleQuickDial = useCallback(
|
||||||
async (otherUserId: string) => {
|
async (otherUserId: string) => {
|
||||||
|
setSearchVal('');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// check all current conversations which should be live listened to
|
// check all current conversations which should be live listened to
|
||||||
|
|
||||||
@@ -172,18 +174,15 @@ export function TerminalProvider({ children }: { children?: React.ReactNode }) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (findExistingConversation) {
|
if (findExistingConversation) {
|
||||||
|
enqueueSnackbar('quick dialed someone!', { variant: 'success' });
|
||||||
setSelectedConversationId(findExistingConversation.id);
|
setSelectedConversationId(findExistingConversation.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create conversation in this case
|
// create conversation in this case
|
||||||
const newConversationId = await createOneOnOneConversation(otherUserId, user.uid);
|
const newConversationId = await createOneOnOneConversation(otherUserId, user.uid);
|
||||||
|
|
||||||
enqueueSnackbar('started conversation!', { variant: 'success' });
|
enqueueSnackbar('started conversation!', { variant: 'success' });
|
||||||
|
|
||||||
setSelectedConversationId(newConversationId);
|
setSelectedConversationId(newConversationId);
|
||||||
|
|
||||||
setSearchVal('');
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
enqueueSnackbar('Something went wrong, please try again', { variant: 'error' });
|
enqueueSnackbar('Something went wrong, please try again', { variant: 'error' });
|
||||||
}
|
}
|
||||||
@@ -318,7 +317,13 @@ export function TerminalProvider({ children }: { children?: React.ReactNode }) {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
{searchVal ? <ListPeople people={searchUsersResults} /> : <ListConversations />}
|
{searchVal ? (
|
||||||
|
<ListPeople people={searchUsersResults} />
|
||||||
|
) : (
|
||||||
|
<ListConversations
|
||||||
|
lookingForSomeone={selectedConversationId && !selectedConversation}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Stack>
|
</Stack>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
@@ -373,7 +378,7 @@ function ListPeople({ people }: { people: User[] }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ListConversations() {
|
function ListConversations({ lookingForSomeone = false }: { lookingForSomeone: boolean }) {
|
||||||
const { conversationMap } = useTerminal();
|
const { conversationMap } = useTerminal();
|
||||||
|
|
||||||
if (Object.keys(conversationMap).length === 0) {
|
if (Object.keys(conversationMap).length === 0) {
|
||||||
@@ -397,6 +402,7 @@ function ListConversations() {
|
|||||||
</ListSubheader>
|
</ListSubheader>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
{lookingForSomeone && <CircularProgress />}
|
||||||
{Object.values(conversationMap).map((currentConversation) => (
|
{Object.values(conversationMap).map((currentConversation) => (
|
||||||
<ConversationRow
|
<ConversationRow
|
||||||
key={`${currentConversation.id}-priorityConvoList`}
|
key={`${currentConversation.id}-priorityConvoList`}
|
||||||
|
|||||||
Reference in New Issue
Block a user