(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 <Base
fill fill={isImmersiveFocusedView}
flush={isImmersiveFocusedView || isFocusedTileFlush} flush={isImmersiveFocusedView || isFocusedTileFlush}
type={focusedTileType} type={focusedTileType}
participant={focusedParticipant} participant={focusedParticipant}

View file

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

View file

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

View file

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

8624
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff