(undefined);
-async function requestNotificationPermission() {
- if (!("Notification" in window)) return false;
-
- if (Notification.permission === "granted") return true;
-
- const permission = await Notification.requestPermission();
- return permission === "granted";
+function reduceDisplay(display: string) {
+ const words = display.split(" ");
+ if (words.length === 1) {
+ return display.slice(0, 2).toUpperCase();
+ } else {
+ return words[0].charAt(0).toUpperCase() + words[1].charAt(0).toUpperCase();
+ }
}
export default function Provider(props: { children: React.ReactNode }) {
@@ -30,7 +29,6 @@ export default function Provider(props: { children: React.ReactNode }) {
const { decryptText, getSharedSecret } = useCrypto();
const { addLiveMessage, userId } = useChat();
const { moveUserIdToTop } = useSession();
- const navigate = useNavigate();
useEffect(() => {
return subscribePush(async (ttpMessage) => {
@@ -56,7 +54,7 @@ export default function Provider(props: { children: React.ReactNode }) {
(await load("settings.read_confirmations")) &&
userId === sender_id
) {
- void send(
+ await send(
"message_state",
{
message_state: "read",
@@ -66,7 +64,7 @@ export default function Provider(props: { children: React.ReactNode }) {
},
);
} else {
- void send(
+ await send(
"message_state",
{
message_state: "received",
@@ -94,41 +92,18 @@ export default function Provider(props: { children: React.ReactNode }) {
if (isTauri()) {
console.log("weewoo");
} else {
- const hasPermissions = await requestNotificationPermission();
-
- if (hasPermissions) {
- const notification = new Notification(user.display, {
- body: decryptedContent,
- icon: user.avatar || user.display.slice(0, 2).toUpperCase(),
- badge: user.avatar || user.display.slice(0, 2).toUpperCase(),
- tag: `message-${user.user_id}`,
- silent: true,
- });
-
- notification.onclick = () => {
- window.focus();
- navigate({
- to: `/chat?id=${user.user_id}`,
- });
-
- notification.close();
- };
- } else {
- sonnerToast(user.display, {
- classNames: {
- content: "pl-4",
- },
- description: decryptedContent,
- icon: (
-
-
-
- {user.display.slice(0, 2).toUpperCase()}
-
-
- ),
- });
- }
+ sonnerToast(user.display, {
+ classNames: {
+ content: "pl-4",
+ },
+ description: decryptedContent,
+ icon: (
+
+
+ {reduceDisplay(user.display)}
+
+ ),
+ });
}
}
});
@@ -142,7 +117,6 @@ export default function Provider(props: { children: React.ReactNode }) {
userId,
moveUserIdToTop,
send,
- navigate,
]);
return (
diff --git a/packages/ttp/src/context.tsx b/packages/ttp/src/context.tsx
index d33313d..2f8fc40 100644
--- a/packages/ttp/src/context.tsx
+++ b/packages/ttp/src/context.tsx
@@ -257,7 +257,7 @@ export function Provider(props: {
setErrorDescription(
"You could try to restart your Iota, check for updates or check your network connection.",
);
- });
+ })
}, [connected, subscribePush]);
useEffect(() => {