diff --git a/apps/web/src/components/navbar.tsx b/apps/web/src/components/navbar.tsx
index 1c2733b..2df62aa 100644
--- a/apps/web/src/components/navbar.tsx
+++ b/apps/web/src/components/navbar.tsx
@@ -14,13 +14,15 @@ import { useSession } from "@tensamin/storage/session";
export default function Navbar({ forMobile }: { forMobile: boolean }) {
const navigate = useNavigate();
const callState = useCall((state) => state.state);
- const { contacts } = useSession();
+ const { calls } = useSession();
const { pathname } = useLocation();
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 [selectOpen, setSelectOpen] = useState(false);
diff --git a/packages/call/src/components/actions.tsx b/packages/call/src/components/actions.tsx
index b4e1311..0aa7220 100644
--- a/packages/call/src/components/actions.tsx
+++ b/packages/call/src/components/actions.tsx
@@ -130,7 +130,8 @@ export default function Actions() {
>
diff --git a/packages/call/src/views/main/layout.tsx b/packages/call/src/views/main/layout.tsx
index 605c01c..b3710da 100644
--- a/packages/call/src/views/main/layout.tsx
+++ b/packages/call/src/views/main/layout.tsx
@@ -112,7 +112,7 @@ export default function Layout({ children }: { children: React.ReactNode }) {
>
;
+export type Calls = z.infer;
// 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: {
diff --git a/packages/storage/src/session.tsx b/packages/storage/src/session.tsx
index 32efc13..03b3826 100644
--- a/packages/storage/src/session.tsx
+++ b/packages/storage/src/session.tsx
@@ -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(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([]);
const [communities, setCommunities] = useState([]);
@@ -69,7 +70,9 @@ export default function SessionProvider({ children }: { children: ReactNode }) {
};
return (
-
+
{children}
);
diff --git a/packages/ttp/src/context.tsx b/packages/ttp/src/context.tsx
index cb613f3..722bcd6 100644
--- a/packages/ttp/src/context.tsx
+++ b/packages/ttp/src/context.tsx
@@ -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(undefined);
@@ -178,6 +180,7 @@ export function Provider(props: {
const [freshCommunities, setFreshCommunities] = useState([]);
const [freshContacts, setFreshContacts] = useState([]);
+ const [freshCalls, setFreshCalls] = useState([]);
const clientRef = useRef
@@ -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}