(fix): small notification logic error
All checks were successful
/ build-web (push) Successful in 7m45s
/ build-desktop (linux) (push) Successful in 12m15s
/ build-mobile (push) Successful in 19m39s
/ release (push) Successful in 3m27s

(fix): call ui
This commit is contained in:
Alois 2026-07-31 00:59:57 +02:00
commit 6f03604c90
Signed by: alois
SSH key fingerprint: SHA256:GBzT2DXvAuGV9XIV5W3WrzVpjU54FThmxHXdbz95J24
5 changed files with 5961 additions and 3108 deletions

View file

@ -185,7 +185,7 @@ export default function View() {
}
>
<Base
fill
fill={isImmersiveFocusedView}
flush={isImmersiveFocusedView || isFocusedTileFlush}
type={focusedTileType}
participant={focusedParticipant}

View file

@ -334,7 +334,8 @@ function MessageComponent({
})}
</p>
<div className="flex items-center justify-start gap-1">
{message.MessageState === "read" ? (
{message.SenderId !==
ownId ? null : message.MessageState === "read" ? (
<Check
size={12}
color="var(--primary-foreground-alt)"

View file

@ -14,6 +14,7 @@
"dependencies": {
"@tanstack/react-router": "^1.169.1",
"@tauri-apps/api": "^2.11.0",
"@tauri-apps/plugin-notification": "~2",
"@tensamin/crypto": "workspace:*",
"@tensamin/shared": "workspace:*",
"@tensamin/chat": "workspace:*",

View file

@ -6,8 +6,13 @@ import { createContext, useEffect, useContext } from "react";
import { toast as sonnerToast } from "sonner";
import { Avatar, AvatarFallback, AvatarImage } from "@methanium/ui";
import { isTauri } from "@tauri-apps/api/core";
import {
isPermissionGranted as isTauriNotificationPermissionGranted,
requestPermission as requestTauriNotificationPermission,
sendNotification as sendTauriNotification,
} from "@tauri-apps/plugin-notification";
import { useSession } from "@tensamin/storage/session";
import { useNavigate } from "@tanstack/react-router";
import { useLocation, useNavigate } from "@tanstack/react-router";
import { decryptChatText } from "@tensamin/crypto/chatSecret";
import { log } from "@tensamin/shared/log";
import { playSound } from "@tensamin/shared/sounds";
@ -31,6 +36,7 @@ export default function Provider(props: { children: React.ReactNode }) {
const { addLiveMessage, chatSecret, getChatSecret, userId } = useChat();
const { moveUserIdToTop } = useSession();
const navigate = useNavigate();
const location = useLocation();
useEffect(() => {
return subscribePush(async (message) => {
@ -42,13 +48,19 @@ export default function Provider(props: { children: React.ReactNode }) {
if (!data.SenderId) return;
const isCurrentChat =
location.pathname === "/chat" && userId === data.SenderId;
const appFocused =
document.hasFocus() && document.visibilityState === "visible";
const shouldAlert = !isCurrentChat || !appFocused;
const messageSecret =
userId === data.SenderId && chatSecret
isCurrentChat && chatSecret
? chatSecret
: await getChatSecret(data.SenderId);
if (!data.Message || !messageSecret) return;
playSound("message");
if (shouldAlert) playSound("message");
void decryptChatText(messageSecret, data.Message.Content)
.catch((err) => {
@ -60,33 +72,43 @@ export default function Provider(props: { children: React.ReactNode }) {
.then(async (content) => {
if (!data.Message || !content || !data.SenderId) return;
if (userId === data.SenderId) {
if (isCurrentChat) {
addLiveMessage({
...data.Message,
Content: content ?? "Failed to decrypt message",
decryptionFailed: content === null,
});
return;
}
// todo: add notification symbol to conversation cards (incl. message start)
moveUserIdToTop(data.SenderId);
if (!shouldAlert) return;
if (!isCurrentChat) {
// todo: add notification symbol to conversation cards (incl. message start)
moveUserIdToTop(data.SenderId);
if (await load("settings.receive_confirmations")) {
void send(
"MessageState",
{
MessageState: "received",
},
{
id: data.Message.SendTime,
},
);
}
}
const user = await get(data.SenderId);
if (await load("settings.receive_confirmations")) {
void send(
"MessageState",
{
MessageState: "received",
},
{
id: data.Message.SendTime,
},
);
}
if (isTauri()) {
console.log("weewoo");
const permissionGranted =
(await isTauriNotificationPermissionGranted()) ||
(await requestTauriNotificationPermission()) === "granted";
if (permissionGranted) {
sendTauriNotification({ title: user.Display, body: content });
}
} else {
const hasPermissions = await requestNotificationPermission();
@ -133,6 +155,7 @@ export default function Provider(props: { children: React.ReactNode }) {
chatSecret,
get,
load,
location.pathname,
navigate,
send,
moveUserIdToTop,

8624
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff