(feat): improved conversation adding flow
(feat): visual tweaks for user modal (feat): now using full width for profile settings page on mobile (fix): profile not saving with empty avatar (chore): bump version due to prod release not getting created (chore): update licenses
This commit is contained in:
parent
4380d664be
commit
ba59a49f98
14 changed files with 203 additions and 44 deletions
|
|
@ -14,6 +14,7 @@ interface SessionContextType {
|
|||
communities: Communities;
|
||||
calls: Calls;
|
||||
moveUserIdToTop: (userId: number) => void;
|
||||
insertContact: (userId: number) => void;
|
||||
}
|
||||
|
||||
const SessionContext = createContext<SessionContextType | undefined>(undefined);
|
||||
|
|
@ -69,9 +70,31 @@ export default function SessionProvider({ children }: { children: ReactNode }) {
|
|||
});
|
||||
};
|
||||
|
||||
const insertContact = (userId: number) => {
|
||||
setContacts((prevContacts) => {
|
||||
if (prevContacts.some((contact) => contact.user_id === userId)) {
|
||||
return prevContacts;
|
||||
}
|
||||
|
||||
const newUser = {
|
||||
user_id: userId,
|
||||
last_message_at: new Date().getTime(),
|
||||
messages: [],
|
||||
} satisfies Contacts[0];
|
||||
|
||||
return [newUser, ...prevContacts];
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<SessionContext.Provider
|
||||
value={{ contacts, communities, calls: freshCalls, moveUserIdToTop }}
|
||||
value={{
|
||||
contacts,
|
||||
communities,
|
||||
calls: freshCalls,
|
||||
moveUserIdToTop,
|
||||
insertContact,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</SessionContext.Provider>
|
||||
|
|
|
|||
Loading…
Reference in a new issue