(feat): add live messages

(feat): update licenses
(feat): update livekit logging
(feat): add basic grid layout
(fix): remove deeplink log message
This commit is contained in:
Alois 2026-04-29 23:30:41 +02:00
commit 8e294d230e
21 changed files with 510 additions and 51 deletions

View file

@ -12,7 +12,11 @@
"build": "tsc -p tsconfig.json --noEmit"
},
"dependencies": {
"@tensamin/ttp": "git+https://github.com/Tensamin/TTP.git",
"@tensamin/ttp": "workspace:*",
"@tensamin/shared": "workspace:*",
"@tensamin/crypto": "workspace:*",
"@tensamin/storage": "workspace:*",
"@tensamin/user": "workspace:*",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"zod": "^4.3.6"

View file

@ -1,14 +1,43 @@
import * as React from "react";
import { useCrypto } from "@tensamin/crypto/context";
import { useStorage } from "@tensamin/storage/context";
import { useUser } from "@tensamin/user/context";
import { useTTP } from "@tensamin/ttp";
import { createContext, useEffect, useContext } from "react";
import z from "zod";
import { toast as sonnerToast } from "sonner";
import { message as messageSchema } from "@tensamin/shared/data";
export const context = React.createContext<contextType | undefined>(undefined);
export const context = createContext<contextType | undefined>(undefined);
/**
* Executes Provider.
* @param props Parameter props.
* @returns unknown.
*/
export default function Provider(props: { children: React.ReactNode }) {
// live_messages
const { subscribePush } = useTTP();
const { load } = useStorage();
const { get } = useUser();
const { decryptText, getSharedSecret } = useCrypto();
useEffect(() => {
subscribePush(async (ttpMessage) => {
if (ttpMessage.type === "message_live") {
const { message, sender_id } = ttpMessage.data as {
message: z.infer<typeof messageSchema>;
sender_id: number;
};
const decryptedContent = await decryptText(
await getSharedSecret(
await load("private_key"),
await get(await load("user_id")).then((data) => data.public_key),
await get(sender_id).then((data) => data.public_key),
),
message.content,
);
sonnerToast(decryptedContent, {
icon: <div>A</div>,
});
}
});
}, [subscribePush, decryptText, getSharedSecret, load, get]);
return (
<context.Provider value={{ test: () => {} }}>
@ -27,7 +56,7 @@ type contextType = {
* @returns contextType.
*/
export function useNotifications(): contextType {
const ctx = React.useContext(context);
const ctx = useContext(context);
if (!ctx) {
throw new Error("useNotifications must be used within a ChatProvider");
}