Compare commits
12 changed files with 101 additions and 492 deletions
|
|
@ -1,12 +0,0 @@
|
||||||
{
|
|
||||||
"$schema": "https://raw.githubusercontent.com/fallow-rs/fallow/main/schema.json",
|
|
||||||
"entry": ["src/index.{ts,tsx,js,jsx}", "src/main.{ts,tsx,js,jsx}"],
|
|
||||||
"workspaces": {
|
|
||||||
"packages": ["packages/*", "apps/*"]
|
|
||||||
},
|
|
||||||
"duplicates": {
|
|
||||||
"minOccurrences": 3,
|
|
||||||
"ignore": ["**/scripts/**", "**.test.ts", "licenses/**"]
|
|
||||||
},
|
|
||||||
"rules": {}
|
|
||||||
}
|
|
||||||
|
|
@ -31,18 +31,16 @@ jobs:
|
||||||
"$API/repos/$REPO/actions/runs?page=$PAGE&limit=50" \
|
"$API/repos/$REPO/actions/runs?page=$PAGE&limit=50" \
|
||||||
-o runs.json
|
-o runs.json
|
||||||
|
|
||||||
COUNT="$(jq 'if type == "array" then length else (.workflow_runs // []) | length end' runs.json)"
|
COUNT="$(jq '.workflow_runs | length' runs.json)"
|
||||||
test "$COUNT" -gt 0 || break
|
test "$COUNT" -gt 0 || break
|
||||||
|
|
||||||
jq -r \
|
jq -r \
|
||||||
--arg cutoff "$CUTOFF" \
|
--arg cutoff "$CUTOFF" \
|
||||||
--arg current "$CURRENT_RUN_ID" \
|
--arg current "$CURRENT_RUN_ID" \
|
||||||
'if type == "array" then . else (.workflow_runs // []) end
|
'.workflow_runs[]
|
||||||
| .[]
|
|
||||||
| select(type == "object")
|
|
||||||
| select((.id | tostring) != $current)
|
| select((.id | tostring) != $current)
|
||||||
| select((.status // .conclusion) as $status | ["success", "failure", "cancelled", "skipped", "succeeded", "failed"] | index($status))
|
| select(["success", "failure", "cancelled", "skipped", "succeeded", "failed"] | index(.status))
|
||||||
| select((.created // .created_at) < $cutoff)
|
| select(.created < $cutoff)
|
||||||
| .id' runs.json \
|
| .id' runs.json \
|
||||||
>> "$DELETE_IDS"
|
>> "$DELETE_IDS"
|
||||||
|
|
||||||
|
|
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,3 +1,2 @@
|
||||||
node_modules
|
node_modules
|
||||||
releases
|
releases
|
||||||
.fallow/
|
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,9 @@ function AppShell() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function CallInit() {
|
function CallInit() {
|
||||||
return useInitializeCall();
|
useInitializeCall();
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rootRoute = createRootRoute({
|
const rootRoute = createRootRoute({
|
||||||
|
|
|
||||||
19
bun.lock
19
bun.lock
|
|
@ -17,7 +17,6 @@
|
||||||
"@typescript-eslint/parser": "^8.59.1",
|
"@typescript-eslint/parser": "^8.59.1",
|
||||||
"eslint": "^10.2.1",
|
"eslint": "^10.2.1",
|
||||||
"eslint-plugin-react-hooks": "^7.1.1",
|
"eslint-plugin-react-hooks": "^7.1.1",
|
||||||
"fallow": "^2.86.0",
|
|
||||||
"globals": "^17.5.0",
|
"globals": "^17.5.0",
|
||||||
"jsonc-parser": "^3.3.1",
|
"jsonc-parser": "^3.3.1",
|
||||||
"prettier": "^3.8.3",
|
"prettier": "^3.8.3",
|
||||||
|
|
@ -466,22 +465,6 @@
|
||||||
|
|
||||||
"@eslint/plugin-kit": ["@eslint/plugin-kit@0.7.1", "", { "dependencies": { "@eslint/core": "^1.2.1", "levn": "^0.4.1" } }, "sha512-rZAP3aVgB9ds9KOeUSL+zZ21hPmo8dh6fnIFwRQj5EAZl9gzR7wxYbYXYysAM8CTqGmUGyp2S4kUdV17MnGuWQ=="],
|
"@eslint/plugin-kit": ["@eslint/plugin-kit@0.7.1", "", { "dependencies": { "@eslint/core": "^1.2.1", "levn": "^0.4.1" } }, "sha512-rZAP3aVgB9ds9KOeUSL+zZ21hPmo8dh6fnIFwRQj5EAZl9gzR7wxYbYXYysAM8CTqGmUGyp2S4kUdV17MnGuWQ=="],
|
||||||
|
|
||||||
"@fallow-cli/darwin-arm64": ["@fallow-cli/darwin-arm64@2.86.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-MOAi1tP+pho98AUEgmA5ziWSDsbr0KWQXNuk9GrptYDBsH0H+Jf9qdW8m3ilJXcgL5+RO8RTH/5Nfkhq0uoMYA=="],
|
|
||||||
|
|
||||||
"@fallow-cli/darwin-x64": ["@fallow-cli/darwin-x64@2.86.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-8mzvGhbZZ8KSG2ZEKnVpiL3Vp9lX4fep2HI8eHt3VDuhMkz8t5n3WRBaBS7LLGTCfLDZ9QPDWhSNCTkx/Llhxw=="],
|
|
||||||
|
|
||||||
"@fallow-cli/linux-arm64-gnu": ["@fallow-cli/linux-arm64-gnu@2.86.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-1N/GCf48xp0Rh9T1JrBvKXAwn1V/+UdCsc2QgF5IrUnwD1JjTG1+/mMg5XwKmrJNPfznJzgzyYGlyfdBeJlqwA=="],
|
|
||||||
|
|
||||||
"@fallow-cli/linux-arm64-musl": ["@fallow-cli/linux-arm64-musl@2.86.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-/H8eK3JpLOq3l5ccEoVVuRssM528vYjk06fy9AcjIvVAGnESErfHQkmGkzAU3nquNL/tlqz88OoBvX+rayDKzQ=="],
|
|
||||||
|
|
||||||
"@fallow-cli/linux-x64-gnu": ["@fallow-cli/linux-x64-gnu@2.86.0", "", { "os": "linux", "cpu": "x64" }, "sha512-svu6wYoCnb1zjZFGjWGtmf8PMiN3SLBn7HYrkA/hXsFK3VRQLFXzts2dJOJ2kHN18rhCExBCQcqukuc/SOoKiA=="],
|
|
||||||
|
|
||||||
"@fallow-cli/linux-x64-musl": ["@fallow-cli/linux-x64-musl@2.86.0", "", { "os": "linux", "cpu": "x64" }, "sha512-pOr4ka4lUIdExkxG0/5cofETE1QY0DI1hbnGJxfLu3Ui0gr9A0H1Dl+ipo5oMJbMFaUiEMAFRCrtNx/j3tA/fg=="],
|
|
||||||
|
|
||||||
"@fallow-cli/win32-arm64-msvc": ["@fallow-cli/win32-arm64-msvc@2.86.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-GmUU/l3euQkNcp5i6ZaUttjTrg2WEYohRCLMqWOUrY0CNaj/ejZ3bhDC+ZZIJZVuWg7sEFACi8wbXhc0rwVb9g=="],
|
|
||||||
|
|
||||||
"@fallow-cli/win32-x64-msvc": ["@fallow-cli/win32-x64-msvc@2.86.0", "", { "os": "win32", "cpu": "x64" }, "sha512-6c+y+QrhfiRQGiqo0QbZ5uoMxuSFichOVzPbZtagvUSO6LGogyB0qH+vNL2kk74NpD6knSXO8vrebhnsBJeI7Q=="],
|
|
||||||
|
|
||||||
"@floating-ui/core": ["@floating-ui/core@1.7.5", "", { "dependencies": { "@floating-ui/utils": "^0.2.11" } }, "sha512-1Ih4WTWyw0+lKyFMcBHGbb5U5FtuHJuujoyyr5zTaWS5EYMeT6Jb2AuDeftsCsEuchO+mM2ij5+q9crhydzLhQ=="],
|
"@floating-ui/core": ["@floating-ui/core@1.7.5", "", { "dependencies": { "@floating-ui/utils": "^0.2.11" } }, "sha512-1Ih4WTWyw0+lKyFMcBHGbb5U5FtuHJuujoyyr5zTaWS5EYMeT6Jb2AuDeftsCsEuchO+mM2ij5+q9crhydzLhQ=="],
|
||||||
|
|
||||||
"@floating-ui/dom": ["@floating-ui/dom@1.7.4", "", { "dependencies": { "@floating-ui/core": "^1.7.3", "@floating-ui/utils": "^0.2.10" } }, "sha512-OOchDgh4F2CchOX94cRVqhvy7b3AFb+/rQXyswmzmGakRfkMgoWVjfnLWkRirfLEfuD4ysVW16eXzwt3jHIzKA=="],
|
"@floating-ui/dom": ["@floating-ui/dom@1.7.4", "", { "dependencies": { "@floating-ui/core": "^1.7.3", "@floating-ui/utils": "^0.2.10" } }, "sha512-OOchDgh4F2CchOX94cRVqhvy7b3AFb+/rQXyswmzmGakRfkMgoWVjfnLWkRirfLEfuD4ysVW16eXzwt3jHIzKA=="],
|
||||||
|
|
@ -1208,8 +1191,6 @@
|
||||||
|
|
||||||
"extsprintf": ["extsprintf@1.4.1", "", {}, "sha512-Wrk35e8ydCKDj/ArClo1VrPVmN8zph5V4AtHwIuHhvMXsKf73UT3BOD+azBIW+3wOJ4FhEH7zyaJCFvChjYvMA=="],
|
"extsprintf": ["extsprintf@1.4.1", "", {}, "sha512-Wrk35e8ydCKDj/ArClo1VrPVmN8zph5V4AtHwIuHhvMXsKf73UT3BOD+azBIW+3wOJ4FhEH7zyaJCFvChjYvMA=="],
|
||||||
|
|
||||||
"fallow": ["fallow@2.86.0", "", { "dependencies": { "detect-libc": "2.1.2" }, "optionalDependencies": { "@fallow-cli/darwin-arm64": "2.86.0", "@fallow-cli/darwin-x64": "2.86.0", "@fallow-cli/linux-arm64-gnu": "2.86.0", "@fallow-cli/linux-arm64-musl": "2.86.0", "@fallow-cli/linux-x64-gnu": "2.86.0", "@fallow-cli/linux-x64-musl": "2.86.0", "@fallow-cli/win32-arm64-msvc": "2.86.0", "@fallow-cli/win32-x64-msvc": "2.86.0" }, "bin": { "fallow": "bin/fallow", "fallow-lsp": "bin/fallow-lsp", "fallow-mcp": "bin/fallow-mcp" } }, "sha512-jHSTWCrvU2Llq7M0bDniTR2aqxWOwJO8BsV2IIl4lOfysJ0bd/3APu3qZ5wJZ+FE40t5DKlMEFQeURMpEb0Rig=="],
|
|
||||||
|
|
||||||
"fast-deep-equal": ["fast-deep-equal@3.1.3", "", {}, "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="],
|
"fast-deep-equal": ["fast-deep-equal@3.1.3", "", {}, "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="],
|
||||||
|
|
||||||
"fast-glob": ["fast-glob@3.3.3", "", { "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", "glob-parent": "^5.1.2", "merge2": "^1.3.0", "micromatch": "^4.0.8" } }, "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg=="],
|
"fast-glob": ["fast-glob@3.3.3", "", { "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", "glob-parent": "^5.1.2", "merge2": "^1.3.0", "micromatch": "^4.0.8" } }, "sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg=="],
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"format": "bunx prettier --write .",
|
"format": "bunx prettier --write .",
|
||||||
"lint": "bun scripts/lint-packages.ts",
|
"lint": "bun scripts/lint-packages.ts",
|
||||||
"check": "fallow && bun run lint",
|
|
||||||
"copy-licenses": "bun scripts/copy-licenses.ts",
|
"copy-licenses": "bun scripts/copy-licenses.ts",
|
||||||
"copy-releases": "bun scripts/copy-releases.ts",
|
"copy-releases": "bun scripts/copy-releases.ts",
|
||||||
"pre-build": "bun run lint && bun run build:packages",
|
"pre-build": "bun run lint && bun run build:packages",
|
||||||
|
|
@ -35,12 +34,11 @@
|
||||||
"@typescript-eslint/parser": "^8.59.1",
|
"@typescript-eslint/parser": "^8.59.1",
|
||||||
"eslint": "^10.2.1",
|
"eslint": "^10.2.1",
|
||||||
"eslint-plugin-react-hooks": "^7.1.1",
|
"eslint-plugin-react-hooks": "^7.1.1",
|
||||||
"fallow": "^2.86.0",
|
|
||||||
"globals": "^17.5.0",
|
"globals": "^17.5.0",
|
||||||
"jsonc-parser": "^3.3.1",
|
|
||||||
"prettier": "^3.8.3",
|
"prettier": "^3.8.3",
|
||||||
"typescript": "^6.0.3",
|
"typescript": "^6.0.3",
|
||||||
"typescript-eslint": "^8.59.1"
|
"typescript-eslint": "^8.59.1",
|
||||||
|
"jsonc-parser": "^3.3.1"
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"@tensamin/ui": "https://git.methanium.net/tensamin/ui/archive/0.0.36.tar.gz",
|
"@tensamin/ui": "https://git.methanium.net/tensamin/ui/archive/0.0.36.tar.gz",
|
||||||
|
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
import {
|
|
||||||
Avatar,
|
|
||||||
AvatarFallback,
|
|
||||||
AvatarImage,
|
|
||||||
Button,
|
|
||||||
Dialog,
|
|
||||||
DialogContent,
|
|
||||||
} from "@tensamin/ui";
|
|
||||||
import Wrapper from "@tensamin/user/wrapper";
|
|
||||||
import { PhoneIncoming, PhoneMissed } from "lucide-react";
|
|
||||||
|
|
||||||
export default function InvitePopup({
|
|
||||||
open,
|
|
||||||
setOpen,
|
|
||||||
onAccept,
|
|
||||||
user,
|
|
||||||
}: {
|
|
||||||
open: boolean;
|
|
||||||
setOpen: (value: boolean) => void;
|
|
||||||
onAccept: (value: boolean) => void;
|
|
||||||
user: number;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<Wrapper
|
|
||||||
userId={user}
|
|
||||||
loading={null}
|
|
||||||
component={(user) => (
|
|
||||||
<Dialog open={open} onOpenChange={setOpen}>
|
|
||||||
<DialogContent className="flex flex-col gap-5 items-center justify-center w-65 h-80">
|
|
||||||
<Avatar className="size-30">
|
|
||||||
<AvatarImage src={user.avatar} />
|
|
||||||
<AvatarFallback className="text-5xl">
|
|
||||||
{user.display.slice(0, 2).toUpperCase()}
|
|
||||||
</AvatarFallback>
|
|
||||||
</Avatar>
|
|
||||||
<p className="text-xl font-medium">{user.display}</p>
|
|
||||||
<div className="w-full flex justify-center gap-3">
|
|
||||||
<Button
|
|
||||||
className="w-14 h-14"
|
|
||||||
variant="subtleDefault"
|
|
||||||
onClick={() => onAccept(true)}
|
|
||||||
>
|
|
||||||
<PhoneIncoming className="size-5" />
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
className="w-14 h-14"
|
|
||||||
variant="destructive"
|
|
||||||
onClick={() => onAccept(false)}
|
|
||||||
>
|
|
||||||
<PhoneMissed className="size-5" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</DialogContent>
|
|
||||||
</Dialog>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -6,7 +6,6 @@ import { log, toast } from "@tensamin/shared/log";
|
||||||
import { ttp } from "@tensamin/shared/data";
|
import { ttp } from "@tensamin/shared/data";
|
||||||
import { useCrypto } from "@tensamin/crypto/context";
|
import { useCrypto } from "@tensamin/crypto/context";
|
||||||
import { useStorage } from "@tensamin/storage/context";
|
import { useStorage } from "@tensamin/storage/context";
|
||||||
import { useSession } from "@tensamin/storage/session";
|
|
||||||
import { useUser } from "@tensamin/user/context";
|
import { useUser } from "@tensamin/user/context";
|
||||||
import { DeepFilterNoiseFilterProcessor } from "deepfilternet3-noise-filter";
|
import { DeepFilterNoiseFilterProcessor } from "deepfilternet3-noise-filter";
|
||||||
import {
|
import {
|
||||||
|
|
@ -25,6 +24,7 @@ import {
|
||||||
getLogger,
|
getLogger,
|
||||||
} from "livekit-client";
|
} from "livekit-client";
|
||||||
import z from "zod";
|
import z from "zod";
|
||||||
|
import { toast as sonnerToast } from "sonner";
|
||||||
import {
|
import {
|
||||||
createScreenShareController,
|
createScreenShareController,
|
||||||
type ScreenShareSession,
|
type ScreenShareSession,
|
||||||
|
|
@ -33,7 +33,6 @@ import {
|
||||||
getSpeakingDetector,
|
getSpeakingDetector,
|
||||||
disposeSpeakingDetector,
|
disposeSpeakingDetector,
|
||||||
} from "./speakingIndicator";
|
} from "./speakingIndicator";
|
||||||
import InvitePopup from "./components/invitePopup";
|
|
||||||
|
|
||||||
// logging
|
// logging
|
||||||
setLogExtension(
|
setLogExtension(
|
||||||
|
|
@ -46,11 +45,6 @@ setLogExtension(
|
||||||
|
|
||||||
type CallState = "closed" | "closing" | "connecting" | "open" | "encrypting";
|
type CallState = "closed" | "closing" | "connecting" | "open" | "encrypting";
|
||||||
type CallView = "preview" | "focused" | "grid";
|
type CallView = "preview" | "focused" | "grid";
|
||||||
type IncomingCallInvite = {
|
|
||||||
callId: string;
|
|
||||||
callSecret: string;
|
|
||||||
senderId: number;
|
|
||||||
};
|
|
||||||
type CurrentCallData =
|
type CurrentCallData =
|
||||||
| (z.infer<typeof ttp.call_data.response> & { exists: boolean })
|
| (z.infer<typeof ttp.call_data.response> & { exists: boolean })
|
||||||
| null;
|
| null;
|
||||||
|
|
@ -89,7 +83,6 @@ type CallStore = {
|
||||||
view: CallView;
|
view: CallView;
|
||||||
invitedUserId: number | null;
|
invitedUserId: number | null;
|
||||||
callId: string | null;
|
callId: string | null;
|
||||||
incomingCallInvite: IncomingCallInvite | null;
|
|
||||||
callSecret: string | null;
|
callSecret: string | null;
|
||||||
livekitToken: string | null;
|
livekitToken: string | null;
|
||||||
currentCallData: CurrentCallData;
|
currentCallData: CurrentCallData;
|
||||||
|
|
@ -844,7 +837,6 @@ export async function disconnect() {
|
||||||
state: "closing",
|
state: "closing",
|
||||||
invitedUserId: null,
|
invitedUserId: null,
|
||||||
callId: null,
|
callId: null,
|
||||||
incomingCallInvite: null,
|
|
||||||
callSecret: null,
|
callSecret: null,
|
||||||
livekitToken: null,
|
livekitToken: null,
|
||||||
currentCallData: null,
|
currentCallData: null,
|
||||||
|
|
@ -891,7 +883,7 @@ export async function joinCall(
|
||||||
log(2, "call", "purple", "Call creation initialised");
|
log(2, "call", "purple", "Call creation initialised");
|
||||||
useCall.setState({
|
useCall.setState({
|
||||||
state: "encrypting",
|
state: "encrypting",
|
||||||
invitedUserId: sendInvite && !existingCallId ? userId : null,
|
invitedUserId: sendInvite ? userId : null,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (callSecret) {
|
if (callSecret) {
|
||||||
|
|
@ -1007,7 +999,6 @@ export function resetCallState() {
|
||||||
view: "preview",
|
view: "preview",
|
||||||
invitedUserId: null,
|
invitedUserId: null,
|
||||||
callId: null,
|
callId: null,
|
||||||
incomingCallInvite: null,
|
|
||||||
callSecret: null,
|
callSecret: null,
|
||||||
livekitToken: null,
|
livekitToken: null,
|
||||||
currentCallData: null,
|
currentCallData: null,
|
||||||
|
|
@ -1059,7 +1050,6 @@ export const useCall = create<CallStore>(() => ({
|
||||||
view: "preview",
|
view: "preview",
|
||||||
invitedUserId: null,
|
invitedUserId: null,
|
||||||
callId: null,
|
callId: null,
|
||||||
incomingCallInvite: null,
|
|
||||||
callSecret: null,
|
callSecret: null,
|
||||||
livekitToken: null,
|
livekitToken: null,
|
||||||
currentCallData: null,
|
currentCallData: null,
|
||||||
|
|
@ -1090,12 +1080,10 @@ export function useInitializeCall() {
|
||||||
const { send, subscribePush } = useTTP();
|
const { send, subscribePush } = useTTP();
|
||||||
const { getSharedSecret, decryptText, encryptText } = useCrypto();
|
const { getSharedSecret, decryptText, encryptText } = useCrypto();
|
||||||
const { load } = useStorage();
|
const { load } = useStorage();
|
||||||
const { insertCall } = useSession();
|
|
||||||
const { get } = useUser();
|
const { get } = useUser();
|
||||||
|
|
||||||
const callId = useCall((state) => state.callId);
|
const callId = useCall((state) => state.callId);
|
||||||
const view = useCall((state) => state.view);
|
const view = useCall((state) => state.view);
|
||||||
const incomingCallInvite = useCall((state) => state.incomingCallInvite);
|
|
||||||
|
|
||||||
const listenersRegistered = useRef(false);
|
const listenersRegistered = useRef(false);
|
||||||
const noiseFilter = useMemo(
|
const noiseFilter = useMemo(
|
||||||
|
|
@ -1125,54 +1113,30 @@ export function useInitializeCall() {
|
||||||
}, [decryptText, encryptText, get, getSharedSecret, load, navigate, send]);
|
}, [decryptText, encryptText, get, getSharedSecret, load, navigate, send]);
|
||||||
|
|
||||||
const showCallingScreen = useCallback(
|
const showCallingScreen = useCallback(
|
||||||
(callId: string, callSecret: string, senderId: number) => {
|
async (callId: string, callSecret: string, senderId: number) => {
|
||||||
useCall.setState({
|
const senderName = await get(senderId).then((data) => data.display);
|
||||||
incomingCallInvite: { callId, callSecret, senderId },
|
|
||||||
|
sonnerToast(`Incoming call from ${senderName}`, {
|
||||||
|
action: {
|
||||||
|
label: "Accept",
|
||||||
|
onClick: () => {
|
||||||
|
joinCall(senderId, callSecret, callId, false).catch((err) => {
|
||||||
|
log(1, "call", "red", "Failed to join call", err);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
cancel: {
|
||||||
|
label: "Decline",
|
||||||
|
onClick: () => {
|
||||||
|
log(2, "call", "purple", "Declined call invite", {
|
||||||
|
callId,
|
||||||
|
senderId,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
[],
|
[get],
|
||||||
);
|
|
||||||
|
|
||||||
const setInvitePopupOpen = useCallback((open: boolean) => {
|
|
||||||
if (!open) {
|
|
||||||
useCall.setState({ incomingCallInvite: null });
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const respondToInvite = useCallback(
|
|
||||||
(accepted: boolean) => {
|
|
||||||
const invite = useCall.getState().incomingCallInvite;
|
|
||||||
|
|
||||||
useCall.setState({ incomingCallInvite: null });
|
|
||||||
|
|
||||||
if (!invite) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
insertCall({
|
|
||||||
call_id: invite.callId,
|
|
||||||
call_secret: invite.callSecret,
|
|
||||||
call_members: [invite.senderId],
|
|
||||||
});
|
|
||||||
|
|
||||||
if (accepted) {
|
|
||||||
joinCall(
|
|
||||||
invite.senderId,
|
|
||||||
invite.callSecret,
|
|
||||||
invite.callId,
|
|
||||||
false,
|
|
||||||
).catch((err) => {
|
|
||||||
log(1, "call", "red", "Failed to join call", err);
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
log(2, "call", "purple", "Declined call invite", {
|
|
||||||
callId: invite.callId,
|
|
||||||
senderId: invite.senderId,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
[insertCall],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// listen to call invites
|
// listen to call invites
|
||||||
|
|
@ -1518,13 +1482,4 @@ export function useInitializeCall() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, [callId, send, view]);
|
}, [callId, send, view]);
|
||||||
|
|
||||||
return incomingCallInvite ? (
|
|
||||||
<InvitePopup
|
|
||||||
open
|
|
||||||
setOpen={setInvitePopupOpen}
|
|
||||||
onAccept={respondToInvite}
|
|
||||||
user={incomingCallInvite.senderId}
|
|
||||||
/>
|
|
||||||
) : null;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,14 @@ import {
|
||||||
TooltipContent,
|
TooltipContent,
|
||||||
TooltipTrigger,
|
TooltipTrigger,
|
||||||
} from "@tensamin/ui";
|
} from "@tensamin/ui";
|
||||||
|
import {
|
||||||
|
ContextMenu,
|
||||||
|
ContextMenuContent,
|
||||||
|
ContextMenuItem,
|
||||||
|
ContextMenuTrigger,
|
||||||
|
} from "@tensamin/ui";
|
||||||
import Wrapper from "@tensamin/user/wrapper";
|
import Wrapper from "@tensamin/user/wrapper";
|
||||||
import { useChat } from "../context";
|
import { useChat } from "../context";
|
||||||
import MessageContextMenu from "./messageContextMenu";
|
|
||||||
|
|
||||||
function MessageComponent({
|
function MessageComponent({
|
||||||
grouped,
|
grouped,
|
||||||
|
|
@ -33,66 +38,72 @@ function MessageComponent({
|
||||||
// pt-3 is to get a gap between messages
|
// pt-3 is to get a gap between messages
|
||||||
className={`${grouped ? "" : "pt-3"} w-full flex justify-start transition-opacity duration-150 ${actuallyFailed || message.message_state === "awaiting" ? "opacity-50" : ""}`}
|
className={`${grouped ? "" : "pt-3"} w-full flex justify-start transition-opacity duration-150 ${actuallyFailed || message.message_state === "awaiting" ? "opacity-50" : ""}`}
|
||||||
>
|
>
|
||||||
<MessageContextMenu
|
<ContextMenu>
|
||||||
content={message.content}
|
<ContextMenuTrigger
|
||||||
messageId={message.send_time}
|
render={
|
||||||
>
|
<div
|
||||||
<div
|
className={cn(
|
||||||
className={cn(
|
"group hover:bg-muted/50 select-text! justify-start flex gap-1 items-center w-full px-2 whitespace-pre-wrap break-all",
|
||||||
"group hover:bg-muted/50 select-text! justify-start flex gap-1 items-center w-full px-2 whitespace-pre-wrap break-all",
|
{
|
||||||
{
|
"bg-(--destructive)/15 text-destructive-foreground":
|
||||||
"bg-(--destructive)/15 text-destructive-foreground":
|
actuallyFailed,
|
||||||
actuallyFailed,
|
},
|
||||||
},
|
)}
|
||||||
)}
|
>
|
||||||
>
|
<Wrapper
|
||||||
<Wrapper
|
loading={"State not achievable"}
|
||||||
loading={"State not achievable"}
|
userId={message.sent_by_self ? "own" : userId}
|
||||||
userId={message.sent_by_self ? "own" : userId}
|
component={(user) => (
|
||||||
component={(user) => (
|
<>
|
||||||
<>
|
{grouped ? (
|
||||||
{grouped ? (
|
<p className="w-9 text-xs group-hover:visible invisible text-muted-foreground">
|
||||||
<p className="w-9 text-xs group-hover:visible invisible text-muted-foreground">
|
|
||||||
{new Date(message.send_time).toLocaleString([], {
|
|
||||||
hour: "2-digit",
|
|
||||||
minute: "2-digit",
|
|
||||||
})}
|
|
||||||
</p>
|
|
||||||
) : (
|
|
||||||
<Avatar className="mr-1 mb-auto mt-1 w-10">
|
|
||||||
<AvatarImage src={user.avatar} />
|
|
||||||
<AvatarFallback>
|
|
||||||
{user.display.slice(0, 2).toUpperCase()}
|
|
||||||
</AvatarFallback>
|
|
||||||
</Avatar>
|
|
||||||
)}
|
|
||||||
{message.failed && message.message_state === "awaiting" && (
|
|
||||||
<Tooltip>
|
|
||||||
<TooltipContent>
|
|
||||||
<p>Failed to send message</p>
|
|
||||||
</TooltipContent>
|
|
||||||
<TooltipTrigger render={<AlertTriangle size={17} />} />
|
|
||||||
</Tooltip>
|
|
||||||
)}
|
|
||||||
<div className="flex flex-col">
|
|
||||||
{!grouped && (
|
|
||||||
<div className="flex items-center gap-1">
|
|
||||||
<p className="font-medium">{user.display}</p>
|
|
||||||
<p className="text-xs text-muted-foreground">
|
|
||||||
{new Date(message.send_time).toLocaleString([], {
|
{new Date(message.send_time).toLocaleString([], {
|
||||||
hour: "2-digit",
|
hour: "2-digit",
|
||||||
minute: "2-digit",
|
minute: "2-digit",
|
||||||
})}
|
})}
|
||||||
</p>
|
</p>
|
||||||
|
) : (
|
||||||
|
<Avatar className="mr-1 mb-auto mt-1 w-10">
|
||||||
|
<AvatarImage src={user.avatar} />
|
||||||
|
<AvatarFallback>
|
||||||
|
{user.display.slice(0, 2).toUpperCase()}
|
||||||
|
</AvatarFallback>
|
||||||
|
</Avatar>
|
||||||
|
)}
|
||||||
|
{message.failed && message.message_state === "awaiting" && (
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipContent>
|
||||||
|
<p>Failed to send message</p>
|
||||||
|
</TooltipContent>
|
||||||
|
<TooltipTrigger render={<AlertTriangle size={17} />} />
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
|
<div className="flex flex-col">
|
||||||
|
{!grouped && (
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<p className="font-medium">{user.display}</p>
|
||||||
|
<p className="text-xs text-muted-foreground">
|
||||||
|
{new Date(message.send_time).toLocaleString([], {
|
||||||
|
hour: "2-digit",
|
||||||
|
minute: "2-digit",
|
||||||
|
})}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<Text value={message.content} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
</>
|
||||||
<Text value={message.content} />
|
)}
|
||||||
</div>
|
/>
|
||||||
</>
|
</div>
|
||||||
)}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
<ContextMenuContent>
|
||||||
</MessageContextMenu>
|
<ContextMenuItem>
|
||||||
|
<Text value={message.content} />
|
||||||
|
</ContextMenuItem>
|
||||||
|
</ContextMenuContent>
|
||||||
|
</ContextMenu>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,242 +0,0 @@
|
||||||
import {
|
|
||||||
cn,
|
|
||||||
ContextMenu,
|
|
||||||
ContextMenuContent,
|
|
||||||
ContextMenuGroup,
|
|
||||||
ContextMenuItem,
|
|
||||||
ContextMenuSeparator,
|
|
||||||
ContextMenuSub,
|
|
||||||
ContextMenuSubContent,
|
|
||||||
ContextMenuSubTrigger,
|
|
||||||
ContextMenuTrigger,
|
|
||||||
Drawer,
|
|
||||||
DrawerContent,
|
|
||||||
DrawerTrigger,
|
|
||||||
useIsMobile,
|
|
||||||
} from "@tensamin/ui";
|
|
||||||
import { Pin, Clipboard, Pen, Reply, Forward, Trash } from "lucide-react";
|
|
||||||
import { useMemo, useState } from "react";
|
|
||||||
import type { ReactElement, ReactNode } from "react";
|
|
||||||
|
|
||||||
async function copyText(text: string) {
|
|
||||||
await navigator.clipboard.writeText(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
type MenuComponents = {
|
|
||||||
Content: (props: { className?: string; children: ReactNode }) => ReactElement;
|
|
||||||
Group: (props: { children: ReactNode }) => ReactElement;
|
|
||||||
Item: (props: {
|
|
||||||
children: ReactNode;
|
|
||||||
className?: string;
|
|
||||||
disabled?: boolean;
|
|
||||||
onClick?: () => void | Promise<void>;
|
|
||||||
variant?: "default" | "destructive";
|
|
||||||
}) => ReactElement;
|
|
||||||
Separator: (props: { className?: string }) => ReactElement;
|
|
||||||
Sub: (props: { children: ReactNode }) => ReactElement;
|
|
||||||
SubTrigger: (props: {
|
|
||||||
children: ReactNode;
|
|
||||||
onClick?: () => void | Promise<void>;
|
|
||||||
}) => ReactElement;
|
|
||||||
SubContent: (props: { children: ReactNode }) => ReactElement;
|
|
||||||
};
|
|
||||||
|
|
||||||
const desktopMenuComponents: MenuComponents = {
|
|
||||||
Content: ContextMenuContent,
|
|
||||||
Group: ContextMenuGroup,
|
|
||||||
Item: ContextMenuItem,
|
|
||||||
Separator: ContextMenuSeparator,
|
|
||||||
Sub: ContextMenuSub,
|
|
||||||
SubTrigger: ContextMenuSubTrigger,
|
|
||||||
SubContent: ContextMenuSubContent,
|
|
||||||
};
|
|
||||||
|
|
||||||
function getMobileMenuComponents(onClose: () => void): MenuComponents {
|
|
||||||
return {
|
|
||||||
Content: ({ className, children }) => (
|
|
||||||
<DrawerContent>
|
|
||||||
<div className={cn("p-3!", className)}>{children}</div>
|
|
||||||
</DrawerContent>
|
|
||||||
),
|
|
||||||
Group: ({ children }) => <div>{children}</div>,
|
|
||||||
Item: ({ children, className, disabled, onClick, variant = "default" }) => {
|
|
||||||
async function handleClick() {
|
|
||||||
await onClick?.();
|
|
||||||
onClose();
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
disabled={disabled}
|
|
||||||
data-variant={variant}
|
|
||||||
className={cn(
|
|
||||||
"relative flex w-full cursor-default items-center gap-1.5 rounded-md px-1.5 py-2 text-left text-sm outline-hidden select-none data-[variant=destructive]:text-destructive disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
|
|
||||||
className,
|
|
||||||
)}
|
|
||||||
onClick={handleClick}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
Separator: ({ className }) => (
|
|
||||||
<div className={cn("-mx-1 my-1 h-px bg-border", className)} />
|
|
||||||
),
|
|
||||||
Sub: ({ children }) => <div>{children}</div>,
|
|
||||||
SubTrigger: ({ children, onClick }) => {
|
|
||||||
async function handleClick() {
|
|
||||||
await onClick?.();
|
|
||||||
onClose();
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="flex w-full cursor-default items-center gap-1.5 rounded-md px-1.5 py-2 text-left text-sm outline-hidden select-none"
|
|
||||||
onClick={handleClick}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
</button>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
SubContent: ({ children }) => <div className="pl-3">{children}</div>,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function ReactionItems({ Item }: { Item: MenuComponents["Item"] }) {
|
|
||||||
return <Item>Cool item</Item>;
|
|
||||||
}
|
|
||||||
|
|
||||||
function MessageMenuContent({
|
|
||||||
components,
|
|
||||||
content,
|
|
||||||
devEnabled,
|
|
||||||
messageId,
|
|
||||||
onAddReaction,
|
|
||||||
showReactionItems = true,
|
|
||||||
}: {
|
|
||||||
components: MenuComponents;
|
|
||||||
content: string;
|
|
||||||
devEnabled: boolean;
|
|
||||||
messageId: number;
|
|
||||||
onAddReaction?: () => void | Promise<void>;
|
|
||||||
showReactionItems?: boolean;
|
|
||||||
}) {
|
|
||||||
const { Content, Group, Item, Separator, Sub, SubContent, SubTrigger } =
|
|
||||||
components;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Content>
|
|
||||||
<Group>
|
|
||||||
<Sub>
|
|
||||||
<SubTrigger onClick={onAddReaction}>Add Reaction</SubTrigger>
|
|
||||||
{showReactionItems && (
|
|
||||||
<SubContent>
|
|
||||||
<ReactionItems Item={Item} />
|
|
||||||
</SubContent>
|
|
||||||
)}
|
|
||||||
</Sub>
|
|
||||||
<Item disabled className="flex justify-between">
|
|
||||||
<p>Pin Message</p> <Pin />
|
|
||||||
</Item>
|
|
||||||
<Item
|
|
||||||
className="flex justify-between"
|
|
||||||
onClick={() => copyText(content)}
|
|
||||||
>
|
|
||||||
<p>Copy Raw</p> <Clipboard />
|
|
||||||
</Item>
|
|
||||||
</Group>
|
|
||||||
<Separator />
|
|
||||||
<Group>
|
|
||||||
<Item disabled className="flex justify-between">
|
|
||||||
<p>Edit Message</p> <Pen />
|
|
||||||
</Item>
|
|
||||||
<Item disabled className="flex justify-between">
|
|
||||||
<p>Reply</p> <Reply />
|
|
||||||
</Item>
|
|
||||||
<Item disabled className="flex justify-between">
|
|
||||||
<p>Forward</p> <Forward />
|
|
||||||
</Item>
|
|
||||||
</Group>
|
|
||||||
<Separator />
|
|
||||||
<Group>
|
|
||||||
<Item disabled variant="destructive" className="flex justify-between">
|
|
||||||
<p>Delete Message</p> <Trash />
|
|
||||||
</Item>
|
|
||||||
</Group>
|
|
||||||
{devEnabled && (
|
|
||||||
<>
|
|
||||||
<Separator />
|
|
||||||
<Group>
|
|
||||||
<Item
|
|
||||||
className="flex justify-between"
|
|
||||||
onClick={() => copyText(String(messageId))}
|
|
||||||
>
|
|
||||||
<p>Copy ID</p> <Clipboard />
|
|
||||||
</Item>
|
|
||||||
</Group>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Content>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function MessageContextMenu({
|
|
||||||
children,
|
|
||||||
content,
|
|
||||||
messageId,
|
|
||||||
}: {
|
|
||||||
children: ReactElement;
|
|
||||||
content: string;
|
|
||||||
messageId: number;
|
|
||||||
}) {
|
|
||||||
const isMobile = useIsMobile();
|
|
||||||
const devEnabled = useMemo(
|
|
||||||
() => Number(localStorage.getItem("log_level")) >= 3,
|
|
||||||
[],
|
|
||||||
);
|
|
||||||
const [mainDrawerOpen, setMainDrawerOpen] = useState(false);
|
|
||||||
const [reactionDrawerOpen, setReactionDrawerOpen] = useState(false);
|
|
||||||
const mainDrawerComponents = getMobileMenuComponents(() =>
|
|
||||||
setMainDrawerOpen(false),
|
|
||||||
);
|
|
||||||
const reactionDrawerComponents = getMobileMenuComponents(() =>
|
|
||||||
setReactionDrawerOpen(false),
|
|
||||||
);
|
|
||||||
|
|
||||||
if (isMobile) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Drawer open={mainDrawerOpen} onOpenChange={setMainDrawerOpen}>
|
|
||||||
<DrawerTrigger asChild>{children}</DrawerTrigger>
|
|
||||||
<MessageMenuContent
|
|
||||||
components={mainDrawerComponents}
|
|
||||||
content={content}
|
|
||||||
devEnabled={devEnabled}
|
|
||||||
messageId={messageId}
|
|
||||||
onAddReaction={() => setReactionDrawerOpen(true)}
|
|
||||||
showReactionItems={false}
|
|
||||||
/>
|
|
||||||
</Drawer>
|
|
||||||
<Drawer open={reactionDrawerOpen} onOpenChange={setReactionDrawerOpen}>
|
|
||||||
<DrawerContent>
|
|
||||||
<ReactionItems Item={reactionDrawerComponents.Item} />
|
|
||||||
</DrawerContent>
|
|
||||||
</Drawer>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ContextMenu>
|
|
||||||
<ContextMenuTrigger render={children} />
|
|
||||||
<MessageMenuContent
|
|
||||||
components={desktopMenuComponents}
|
|
||||||
content={content}
|
|
||||||
devEnabled={devEnabled}
|
|
||||||
messageId={messageId}
|
|
||||||
/>
|
|
||||||
</ContextMenu>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,2 +1 @@
|
||||||
- Implement context menu features
|
- Add context menu to messages
|
||||||
- Add default-emoji-hotkey in settings
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ interface SessionContextType {
|
||||||
calls: Calls;
|
calls: Calls;
|
||||||
moveUserIdToTop: (userId: number) => void;
|
moveUserIdToTop: (userId: number) => void;
|
||||||
insertContact: (userId: number) => void;
|
insertContact: (userId: number) => void;
|
||||||
insertCall: (call: Calls[number]) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const SessionContext = createContext<SessionContextType | undefined>(undefined);
|
const SessionContext = createContext<SessionContextType | undefined>(undefined);
|
||||||
|
|
@ -25,7 +24,6 @@ export default function SessionProvider({ children }: { children: ReactNode }) {
|
||||||
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>([]);
|
||||||
const [calls, setCalls] = useState<Calls>([]);
|
|
||||||
|
|
||||||
// Get cached data and merge fresh data
|
// Get cached data and merge fresh data
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -53,15 +51,6 @@ export default function SessionProvider({ children }: { children: ReactNode }) {
|
||||||
});
|
});
|
||||||
}, [load, freshContacts, freshCommunities]);
|
}, [load, freshContacts, freshCommunities]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setCalls((prevCalls) => [
|
|
||||||
...freshCalls,
|
|
||||||
...prevCalls.filter(
|
|
||||||
(call) => !freshCalls.some((fresh) => fresh.call_id === call.call_id),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
}, [freshCalls]);
|
|
||||||
|
|
||||||
// Save data
|
// Save data
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
save("cached_contacts", contacts);
|
save("cached_contacts", contacts);
|
||||||
|
|
@ -97,25 +86,14 @@ export default function SessionProvider({ children }: { children: ReactNode }) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const insertCall = (call: Calls[number]) => {
|
|
||||||
setCalls((prevCalls) => {
|
|
||||||
if (prevCalls.some((prevCall) => prevCall.call_id === call.call_id)) {
|
|
||||||
return prevCalls;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [call, ...prevCalls];
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SessionContext.Provider
|
<SessionContext.Provider
|
||||||
value={{
|
value={{
|
||||||
contacts,
|
contacts,
|
||||||
communities,
|
communities,
|
||||||
calls,
|
calls: freshCalls,
|
||||||
moveUserIdToTop,
|
moveUserIdToTop,
|
||||||
insertContact,
|
insertContact,
|
||||||
insertCall,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue