(feat): adjust to new calls array from ident res
This commit is contained in:
parent
dd09ca943d
commit
8e5ed8217d
6 changed files with 27 additions and 11 deletions
|
|
@ -130,7 +130,8 @@ export default function Actions() {
|
|||
>
|
||||
<ScreenShareOff
|
||||
style={{
|
||||
scale: (sharedIconSize ? sharedIconSize + 100 : 100) + "%",
|
||||
scale:
|
||||
(sharedIconSize ? sharedIconSize + 100 : 100) + "%",
|
||||
}}
|
||||
/>
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ export default function Layout({ children }: { children: React.ReactNode }) {
|
|||
>
|
||||
<div
|
||||
ref={topBarRef}
|
||||
className={`shrink-0 w-full z-20 transition-all duration-200 ${
|
||||
className={`shrink-0 w-full z-40 transition-all duration-200 ${
|
||||
isImmersiveFocusedView
|
||||
? immersiveChromeVisible
|
||||
? "opacity-100 translate-y-0 pointer-events-auto"
|
||||
|
|
@ -142,7 +142,7 @@ export default function Layout({ children }: { children: React.ReactNode }) {
|
|||
</div>
|
||||
<div
|
||||
ref={actionsRef}
|
||||
className={`shrink-0 pb-4.5 pt-3 bottom-0 w-full z-20 transition-all duration-200 ${
|
||||
className={`shrink-0 pb-4.5 pt-3 bottom-0 w-full z-40 transition-all duration-200 ${
|
||||
isImmersiveFocusedView
|
||||
? immersiveChromeVisible
|
||||
? "opacity-100 translate-y-0 pointer-events-auto"
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ export type Contacts = z.infer<
|
|||
export type Communities = z.infer<
|
||||
typeof ttp.challenge_response.response.shape.communities
|
||||
>;
|
||||
export type Calls = z.infer<typeof ttp.challenge_response.response.shape.calls>;
|
||||
|
||||
// TTP
|
||||
export const ttp = {
|
||||
|
|
@ -67,9 +68,6 @@ export const ttp = {
|
|||
communities: z.array(z.object({})).optional(),
|
||||
contacts: z.array(
|
||||
z.object({
|
||||
calls: z
|
||||
.array(z.object({ call_id: z.string(), call_secret: z.base64() }))
|
||||
.optional(),
|
||||
last_message_at: z.number(),
|
||||
user_id: z.number(),
|
||||
last_message: z
|
||||
|
|
@ -81,6 +79,13 @@ export const ttp = {
|
|||
messages: z.array(message),
|
||||
}),
|
||||
),
|
||||
calls: z.array(
|
||||
z.object({
|
||||
call_id: z.string(),
|
||||
call_secret: z.base64().optional(),
|
||||
call_members: z.array(z.number()),
|
||||
}),
|
||||
),
|
||||
}),
|
||||
},
|
||||
get_user_data: {
|
||||
|
|
|
|||
|
|
@ -7,18 +7,19 @@ import {
|
|||
useEffect,
|
||||
} from "react";
|
||||
import { useStorage } from "./context";
|
||||
import type { Contacts, Communities } from "@tensamin/shared/data";
|
||||
import type { Contacts, Communities, Calls } from "@tensamin/shared/data";
|
||||
|
||||
interface SessionContextType {
|
||||
contacts: Contacts;
|
||||
communities: Communities;
|
||||
calls: Calls;
|
||||
moveUserIdToTop: (userId: number) => void;
|
||||
}
|
||||
|
||||
const SessionContext = createContext<SessionContextType | undefined>(undefined);
|
||||
|
||||
export default function SessionProvider({ children }: { children: ReactNode }) {
|
||||
const { freshContacts, freshCommunities } = useTTP();
|
||||
const { freshContacts, freshCommunities, freshCalls } = useTTP();
|
||||
const { load, save } = useStorage();
|
||||
const [contacts, setContacts] = useState<Contacts>([]);
|
||||
const [communities, setCommunities] = useState<Communities>([]);
|
||||
|
|
@ -69,7 +70,9 @@ export default function SessionProvider({ children }: { children: ReactNode }) {
|
|||
};
|
||||
|
||||
return (
|
||||
<SessionContext.Provider value={{ contacts, communities, moveUserIdToTop }}>
|
||||
<SessionContext.Provider
|
||||
value={{ contacts, communities, calls: freshCalls, moveUserIdToTop }}
|
||||
>
|
||||
{children}
|
||||
</SessionContext.Provider>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import {
|
|||
TRANSPORT_URL,
|
||||
} from "./values";
|
||||
import {
|
||||
type Calls,
|
||||
type Communities,
|
||||
type Contacts,
|
||||
ttp as schemas,
|
||||
|
|
@ -149,6 +150,7 @@ type ContextType = {
|
|||
identified: boolean;
|
||||
freshContacts: Contacts;
|
||||
freshCommunities: Communities;
|
||||
freshCalls: Calls;
|
||||
};
|
||||
|
||||
const TTPContext = createContext<ContextType | undefined>(undefined);
|
||||
|
|
@ -178,6 +180,7 @@ export function Provider(props: {
|
|||
|
||||
const [freshCommunities, setFreshCommunities] = useState<Communities>([]);
|
||||
const [freshContacts, setFreshContacts] = useState<Contacts>([]);
|
||||
const [freshCalls, setFreshCalls] = useState<Calls>([]);
|
||||
|
||||
const clientRef = useRef<ReturnType<
|
||||
typeof createTransportClient<Schemas>
|
||||
|
|
@ -496,6 +499,7 @@ export function Provider(props: {
|
|||
// Data handling
|
||||
setFreshContacts(finalResponse.data.contacts);
|
||||
setFreshCommunities(finalResponse.data.communities);
|
||||
setFreshCalls(finalResponse.data.calls);
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -609,6 +613,7 @@ export function Provider(props: {
|
|||
identified,
|
||||
freshContacts,
|
||||
freshCommunities,
|
||||
freshCalls,
|
||||
}}
|
||||
>
|
||||
{props.children}
|
||||
|
|
|
|||
Loading…
Reference in a new issue