(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
|
|
@ -14,13 +14,15 @@ import { useSession } from "@tensamin/storage/session";
|
||||||
export default function Navbar({ forMobile }: { forMobile: boolean }) {
|
export default function Navbar({ forMobile }: { forMobile: boolean }) {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const callState = useCall((state) => state.state);
|
const callState = useCall((state) => state.state);
|
||||||
const { contacts } = useSession();
|
const { calls } = useSession();
|
||||||
|
|
||||||
const { pathname } = useLocation();
|
const { pathname } = useLocation();
|
||||||
|
|
||||||
const { id } = useSearch({ strict: false });
|
const { id } = useSearch({ strict: false });
|
||||||
|
|
||||||
const currentCalls = id ? contacts?.[id]?.calls || [] : [];
|
const currentCalls = calls.filter((call) =>
|
||||||
|
call.call_members.some((member) => member === id),
|
||||||
|
);
|
||||||
//const currentCalls = ["leck", "schleck", "und", "eck"];
|
//const currentCalls = ["leck", "schleck", "und", "eck"];
|
||||||
|
|
||||||
const [selectOpen, setSelectOpen] = useState(false);
|
const [selectOpen, setSelectOpen] = useState(false);
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,8 @@ export default function Actions() {
|
||||||
>
|
>
|
||||||
<ScreenShareOff
|
<ScreenShareOff
|
||||||
style={{
|
style={{
|
||||||
scale: (sharedIconSize ? sharedIconSize + 100 : 100) + "%",
|
scale:
|
||||||
|
(sharedIconSize ? sharedIconSize + 100 : 100) + "%",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ export default function Layout({ children }: { children: React.ReactNode }) {
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
ref={topBarRef}
|
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
|
isImmersiveFocusedView
|
||||||
? immersiveChromeVisible
|
? immersiveChromeVisible
|
||||||
? "opacity-100 translate-y-0 pointer-events-auto"
|
? "opacity-100 translate-y-0 pointer-events-auto"
|
||||||
|
|
@ -142,7 +142,7 @@ export default function Layout({ children }: { children: React.ReactNode }) {
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
ref={actionsRef}
|
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
|
isImmersiveFocusedView
|
||||||
? immersiveChromeVisible
|
? immersiveChromeVisible
|
||||||
? "opacity-100 translate-y-0 pointer-events-auto"
|
? "opacity-100 translate-y-0 pointer-events-auto"
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ export type Contacts = z.infer<
|
||||||
export type Communities = z.infer<
|
export type Communities = z.infer<
|
||||||
typeof ttp.challenge_response.response.shape.communities
|
typeof ttp.challenge_response.response.shape.communities
|
||||||
>;
|
>;
|
||||||
|
export type Calls = z.infer<typeof ttp.challenge_response.response.shape.calls>;
|
||||||
|
|
||||||
// TTP
|
// TTP
|
||||||
export const ttp = {
|
export const ttp = {
|
||||||
|
|
@ -67,9 +68,6 @@ export const ttp = {
|
||||||
communities: z.array(z.object({})).optional(),
|
communities: z.array(z.object({})).optional(),
|
||||||
contacts: z.array(
|
contacts: z.array(
|
||||||
z.object({
|
z.object({
|
||||||
calls: z
|
|
||||||
.array(z.object({ call_id: z.string(), call_secret: z.base64() }))
|
|
||||||
.optional(),
|
|
||||||
last_message_at: z.number(),
|
last_message_at: z.number(),
|
||||||
user_id: z.number(),
|
user_id: z.number(),
|
||||||
last_message: z
|
last_message: z
|
||||||
|
|
@ -81,6 +79,13 @@ export const ttp = {
|
||||||
messages: z.array(message),
|
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: {
|
get_user_data: {
|
||||||
|
|
|
||||||
|
|
@ -7,18 +7,19 @@ import {
|
||||||
useEffect,
|
useEffect,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { useStorage } from "./context";
|
import { useStorage } from "./context";
|
||||||
import type { Contacts, Communities } from "@tensamin/shared/data";
|
import type { Contacts, Communities, Calls } from "@tensamin/shared/data";
|
||||||
|
|
||||||
interface SessionContextType {
|
interface SessionContextType {
|
||||||
contacts: Contacts;
|
contacts: Contacts;
|
||||||
communities: Communities;
|
communities: Communities;
|
||||||
|
calls: Calls;
|
||||||
moveUserIdToTop: (userId: number) => void;
|
moveUserIdToTop: (userId: number) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SessionContext = createContext<SessionContextType | undefined>(undefined);
|
const SessionContext = createContext<SessionContextType | undefined>(undefined);
|
||||||
|
|
||||||
export default function SessionProvider({ children }: { children: ReactNode }) {
|
export default function SessionProvider({ children }: { children: ReactNode }) {
|
||||||
const { freshContacts, freshCommunities } = useTTP();
|
const { freshContacts, freshCommunities, freshCalls } = useTTP();
|
||||||
const { load, save } = useStorage();
|
const { load, save } = useStorage();
|
||||||
const [contacts, setContacts] = useState<Contacts>([]);
|
const [contacts, setContacts] = useState<Contacts>([]);
|
||||||
const [communities, setCommunities] = useState<Communities>([]);
|
const [communities, setCommunities] = useState<Communities>([]);
|
||||||
|
|
@ -69,7 +70,9 @@ export default function SessionProvider({ children }: { children: ReactNode }) {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SessionContext.Provider value={{ contacts, communities, moveUserIdToTop }}>
|
<SessionContext.Provider
|
||||||
|
value={{ contacts, communities, calls: freshCalls, moveUserIdToTop }}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</SessionContext.Provider>
|
</SessionContext.Provider>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import {
|
||||||
TRANSPORT_URL,
|
TRANSPORT_URL,
|
||||||
} from "./values";
|
} from "./values";
|
||||||
import {
|
import {
|
||||||
|
type Calls,
|
||||||
type Communities,
|
type Communities,
|
||||||
type Contacts,
|
type Contacts,
|
||||||
ttp as schemas,
|
ttp as schemas,
|
||||||
|
|
@ -149,6 +150,7 @@ type ContextType = {
|
||||||
identified: boolean;
|
identified: boolean;
|
||||||
freshContacts: Contacts;
|
freshContacts: Contacts;
|
||||||
freshCommunities: Communities;
|
freshCommunities: Communities;
|
||||||
|
freshCalls: Calls;
|
||||||
};
|
};
|
||||||
|
|
||||||
const TTPContext = createContext<ContextType | undefined>(undefined);
|
const TTPContext = createContext<ContextType | undefined>(undefined);
|
||||||
|
|
@ -178,6 +180,7 @@ export function Provider(props: {
|
||||||
|
|
||||||
const [freshCommunities, setFreshCommunities] = useState<Communities>([]);
|
const [freshCommunities, setFreshCommunities] = useState<Communities>([]);
|
||||||
const [freshContacts, setFreshContacts] = useState<Contacts>([]);
|
const [freshContacts, setFreshContacts] = useState<Contacts>([]);
|
||||||
|
const [freshCalls, setFreshCalls] = useState<Calls>([]);
|
||||||
|
|
||||||
const clientRef = useRef<ReturnType<
|
const clientRef = useRef<ReturnType<
|
||||||
typeof createTransportClient<Schemas>
|
typeof createTransportClient<Schemas>
|
||||||
|
|
@ -496,6 +499,7 @@ export function Provider(props: {
|
||||||
// Data handling
|
// Data handling
|
||||||
setFreshContacts(finalResponse.data.contacts);
|
setFreshContacts(finalResponse.data.contacts);
|
||||||
setFreshCommunities(finalResponse.data.communities);
|
setFreshCommunities(finalResponse.data.communities);
|
||||||
|
setFreshCalls(finalResponse.data.calls);
|
||||||
if (cancelled) {
|
if (cancelled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -609,6 +613,7 @@ export function Provider(props: {
|
||||||
identified,
|
identified,
|
||||||
freshContacts,
|
freshContacts,
|
||||||
freshCommunities,
|
freshCommunities,
|
||||||
|
freshCalls,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{props.children}
|
{props.children}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue