This commit is contained in:
PhilReact 2024-10-28 12:07:22 +02:00
parent e6cbec4b08
commit b665d229f3
6 changed files with 383 additions and 330 deletions

View File

@ -404,13 +404,17 @@ function App() {
globalApiKey = key; globalApiKey = key;
} }
useEffect(() => { useEffect(() => {
chrome?.runtime?.sendMessage({ action: "getApiKey" }, (response) => { window.sendMessage("getApiKey")
.then((response) => {
if (response) { if (response) {
handleSetGlobalApikey(response) handleSetGlobalApikey(response);
setApiKey(response); setApiKey(response);
} }
})
.catch((error) => {
console.error("Failed to get API key:", error?.message || "An error occurred");
}); });
}, []); }, []);
useEffect(() => { useEffect(() => {
if (extState) { if (extState) {

View File

@ -90,14 +90,16 @@ export const NotAuthenticated = ({
}, []); }, []);
useEffect(() => { useEffect(() => {
chrome?.runtime?.sendMessage( window.sendMessage("getCustomNodesFromStorage")
{ action: "getCustomNodesFromStorage" }, .then((response) => {
(response) => { if (response) {
if (response) { setCustomNodes(response || []);
setCustomNodes(response || []);
}
} }
); })
.catch((error) => {
console.error("Failed to get custom nodes from storage:", error.message || "An error occurred");
});
}, []); }, []);
useEffect(()=> { useEffect(()=> {
@ -147,19 +149,21 @@ export const NotAuthenticated = ({
// Assuming the response is in plain text and will be 'true' or 'false' // Assuming the response is in plain text and will be 'true' or 'false'
const data = await response.text(); const data = await response.text();
if (data === "true") { if (data === "true") {
chrome?.runtime?.sendMessage( window.sendMessage("setApiKey", payload)
{ action: "setApiKey", payload }, .then((response) => {
(response) => { if (response) {
if (response) { handleSetGlobalApikey(payload);
handleSetGlobalApikey(payload); setIsValidApiKey(true);
setIsValidApiKey(true); setUseLocalNode(true);
setUseLocalNode(true); if (!fromStartUp) {
if(!fromStartUp){ setApiKey(payload);
setApiKey(payload)
}
} }
} }
); })
.catch((error) => {
console.error("Failed to set API key:", error.message || "An error occurred");
});
} else { } else {
setIsValidApiKey(false); setIsValidApiKey(false);
setUseLocalNode(false); setUseLocalNode(false);
@ -208,17 +212,19 @@ export const NotAuthenticated = ({
setCustomNodes(nodes); setCustomNodes(nodes);
setCustomNodeToSaveIndex(null); setCustomNodeToSaveIndex(null);
if (!nodes) return; if (!nodes) return;
chrome?.runtime?.sendMessage( window.sendMessage("setCustomNodes", nodes)
{ action: "setCustomNodes", nodes }, .then((response) => {
(response) => { if (response) {
if (response) { setMode("list");
setMode("list"); setUrl("http://");
setUrl("http://"); setCustomApiKey("");
setCustomApiKey(""); // add alert if needed
// add alert }
} })
} .catch((error) => {
); console.error("Failed to set custom nodes:", error.message || "An error occurred");
});
}; };
@ -338,16 +344,17 @@ export const NotAuthenticated = ({
url: "http://127.0.0.1:12391", url: "http://127.0.0.1:12391",
}) })
setUseLocalNode(false) setUseLocalNode(false)
chrome?.runtime?.sendMessage( window.sendMessage("setApiKey", null)
{ action: "setApiKey", payload:null }, .then((response) => {
(response) => { if (response) {
if (response) { setApiKey(null);
setApiKey(null); handleSetGlobalApikey(null);
handleSetGlobalApikey(null); }
})
} .catch((error) => {
} console.error("Failed to set API key:", error.message || "An error occurred");
); });
} }
}} }}
@ -462,16 +469,17 @@ export const NotAuthenticated = ({
setMode("list"); setMode("list");
setShow(false); setShow(false);
setUseLocalNode(false); setUseLocalNode(false);
chrome?.runtime?.sendMessage( window.sendMessage("setApiKey", null)
{ action: "setApiKey", payload:null }, .then((response) => {
(response) => { if (response) {
if (response) { setApiKey(null);
setApiKey(null); handleSetGlobalApikey(null);
handleSetGlobalApikey(null); }
})
} .catch((error) => {
} console.error("Failed to set API key:", error.message || "An error occurred");
); });
}} }}
variant="contained" variant="contained"
> >
@ -517,16 +525,17 @@ export const NotAuthenticated = ({
setShow(false); setShow(false);
setIsValidApiKey(false); setIsValidApiKey(false);
setUseLocalNode(false); setUseLocalNode(false);
chrome?.runtime?.sendMessage( window.sendMessage("setApiKey", null)
{ action: "setApiKey", payload:null }, .then((response) => {
(response) => { if (response) {
if (response) { setApiKey(null);
setApiKey(null); handleSetGlobalApikey(null);
handleSetGlobalApikey(null); }
})
} .catch((error) => {
} console.error("Failed to set API key:", error.message || "An error occurred");
); });
}} }}
variant="contained" variant="contained"
> >

View File

@ -1,5 +1,6 @@
import { import {
addDataPublishes, addDataPublishes,
addTimestampEnterChat,
addUserSettings, addUserSettings,
banFromGroup, banFromGroup,
cancelBan, cancelBan,
@ -7,7 +8,9 @@ import {
createGroup, createGroup,
decryptWallet, decryptWallet,
findUsableApi, findUsableApi,
getApiKeyFromStorage,
getBalanceInfo, getBalanceInfo,
getCustomNodesFromStorage,
getDataPublishes, getDataPublishes,
getKeyPair, getKeyPair,
getLTCBalance, getLTCBalance,
@ -24,6 +27,7 @@ import {
removeAdmin, removeAdmin,
saveTempPublish, saveTempPublish,
sendCoin, sendCoin,
setChatHeads,
walletVersion, walletVersion,
} from "./background"; } from "./background";
@ -715,4 +719,183 @@ export async function balanceCase(request, event) {
event.origin event.origin
); );
} }
}
export async function notificationCase(request, event) {
try {
const notificationId = "chat_notification_" + Date.now(); // Create a unique ID
chrome.notifications.create(notificationId, {
type: "basic",
iconUrl: "qort.png", // Add an appropriate icon for chat notifications
title: "New Group Message!",
message: "You have received a new message from one of your groups",
priority: 2, // Use the maximum priority to ensure it's noticeable
// buttons: [
// { title: 'Go to group' }
// ]
});
// Set a timeout to clear the notification after 'timeout' milliseconds
setTimeout(() => {
chrome.notifications.clear(notificationId);
}, 3000);
event.source.postMessage(
{
requestId: request.requestId,
action: "notification",
payload: true,
type: "backgroundMessageResponse",
},
event.origin
);
} catch (error) {
event.source.postMessage(
{
requestId: request.requestId,
action: "notification",
error: "Error displaying notifaction",
type: "backgroundMessageResponse",
},
event.origin
);
}
}
export async function addTimestampEnterChatCase(request, event) {
try {
const { groupId, timestamp } = request.payload;
const response = await addTimestampEnterChat({groupId, timestamp});
event.source.postMessage(
{
requestId: request.requestId,
action: "addTimestampEnterChat",
payload: response,
type: "backgroundMessageResponse",
},
event.origin
);
} catch (error) {
event.source.postMessage(
{
requestId: request.requestId,
action: "addTimestampEnterChat",
error: error?.message,
type: "backgroundMessageResponse",
},
event.origin
);
}
}
export async function setApiKeyCase(request, event) {
try {
const payload = request.payload;
chrome.storage.local.set({ apiKey: payload }, () => {
// sendResponse(true);
});
event.source.postMessage(
{
requestId: request.requestId,
action: "setApiKey",
payload: true,
type: "backgroundMessageResponse",
},
event.origin
);
} catch (error) {
event.source.postMessage(
{
requestId: request.requestId,
action: "setApiKey",
error: error?.message,
type: "backgroundMessageResponse",
},
event.origin
);
}
}
export async function setCustomNodesCase(request, event) {
try {
const nodes = request.payload;
chrome.storage.local.set({ customNodes: nodes }, () => {
// sendResponse(true);
});
event.source.postMessage(
{
requestId: request.requestId,
action: "setCustomNodes",
payload: true,
type: "backgroundMessageResponse",
},
event.origin
);
} catch (error) {
event.source.postMessage(
{
requestId: request.requestId,
action: "setCustomNodes",
error: error?.message,
type: "backgroundMessageResponse",
},
event.origin
);
}
}
export async function getApiKeyCase(request, event) {
try {
const response = await getApiKeyFromStorage();
event.source.postMessage(
{
requestId: request.requestId,
action: "getApiKey",
payload: response,
type: "backgroundMessageResponse",
},
event.origin
);
} catch (error) {
event.source.postMessage(
{
requestId: request.requestId,
action: "getApiKey",
error: error?.message,
type: "backgroundMessageResponse",
},
event.origin
);
}
}
export async function getCustomNodesFromStorageCase(request, event) {
try {
const response = await getCustomNodesFromStorage();
event.source.postMessage(
{
requestId: request.requestId,
action: "getCustomNodesFromStorage",
payload: response,
type: "backgroundMessageResponse",
},
event.origin
);
} catch (error) {
event.source.postMessage(
{
requestId: request.requestId,
action: "getCustomNodesFromStorage",
error: error?.message,
type: "backgroundMessageResponse",
},
event.origin
);
}
} }

View File

@ -30,6 +30,7 @@ import { TradeBotRespondMultipleRequest } from "./transactions/TradeBotRespondMu
import { RESOURCE_TYPE_NUMBER_GROUP_CHAT_REACTIONS } from "./constants/resourceTypes"; import { RESOURCE_TYPE_NUMBER_GROUP_CHAT_REACTIONS } from "./constants/resourceTypes";
import { import {
addDataPublishesCase, addDataPublishesCase,
addTimestampEnterChatCase,
addUserSettingsCase, addUserSettingsCase,
balanceCase, balanceCase,
banFromGroupCase, banFromGroupCase,
@ -37,6 +38,8 @@ import {
cancelInvitationToGroupCase, cancelInvitationToGroupCase,
createGroupCase, createGroupCase,
decryptWalletCase, decryptWalletCase,
getApiKeyCase,
getCustomNodesFromStorageCase,
getDataPublishesCase, getDataPublishesCase,
getTempPublishCase, getTempPublishCase,
getUserSettingsCase, getUserSettingsCase,
@ -48,10 +51,14 @@ import {
ltcBalanceCase, ltcBalanceCase,
makeAdminCase, makeAdminCase,
nameCase, nameCase,
notificationCase,
registerNameCase, registerNameCase,
removeAdminCase, removeAdminCase,
saveTempPublishCase, saveTempPublishCase,
sendCoinCase, sendCoinCase,
setApiKeyCase,
setChatHeadsCase,
setCustomNodesCase,
userInfoCase, userInfoCase,
validApiCase, validApiCase,
versionCase, versionCase,
@ -134,7 +141,7 @@ const checkDifference = (createdTimestamp) => {
Date.now() - createdTimestamp < timeDifferenceForNotificationChatsBackground Date.now() - createdTimestamp < timeDifferenceForNotificationChatsBackground
); );
}; };
const getApiKeyFromStorage = async () => { export const getApiKeyFromStorage = async () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
chrome.storage.local.get("apiKey", (result) => { chrome.storage.local.get("apiKey", (result) => {
if (chrome.runtime.lastError) { if (chrome.runtime.lastError) {
@ -145,7 +152,7 @@ const getApiKeyFromStorage = async () => {
}); });
}; };
const getCustomNodesFromStorage = async () => { export const getCustomNodesFromStorage = async () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
chrome.storage.local.get("customNodes", (result) => { chrome.storage.local.get("customNodes", (result) => {
if (chrome.runtime.lastError) { if (chrome.runtime.lastError) {
@ -396,16 +403,20 @@ const handleNotificationDirect = async (directs) => {
} }
} catch (error) { } catch (error) {
if (!isFocused) { if (!isFocused) {
chrome.runtime.sendMessage( window
{ .sendMessage("notification", {})
action: "notification", .then((response) => {
payload: {},
},
(response) => {
if (!response?.error) { if (!response?.error) {
// Handle success if needed
} }
} })
); .catch((error) => {
console.error(
"Failed to send notification:",
error.message || "An error occurred"
);
});
const notificationId = "chat_notification_" + Date.now(); const notificationId = "chat_notification_" + Date.now();
chrome.notifications.create(notificationId, { chrome.notifications.create(notificationId, {
type: "basic", type: "basic",
@ -639,16 +650,20 @@ const handleNotification = async (groups) => {
} }
} catch (error) { } catch (error) {
if (!isFocused) { if (!isFocused) {
chrome.runtime.sendMessage( window
{ .sendMessage("notification", {})
action: "notification", .then((response) => {
payload: {},
},
(response) => {
if (!response?.error) { if (!response?.error) {
// Handle success if needed
} }
} })
); .catch((error) => {
console.error(
"Failed to send notification:",
error.message || "An error occurred"
);
});
const notificationId = "chat_notification_" + Date.now(); const notificationId = "chat_notification_" + Date.now();
chrome.notifications.create(notificationId, { chrome.notifications.create(notificationId, {
type: "basic", type: "basic",
@ -2614,7 +2629,7 @@ export function removeDuplicateWindow(popupUrl) {
); );
} }
async function setChatHeads(data) { export async function setChatHeads(data) {
const wallet = await getSaveWallet(); const wallet = await getSaveWallet();
const address = wallet.address0; const address = wallet.address0;
const dataString = JSON.stringify(data); const dataString = JSON.stringify(data);
@ -2818,7 +2833,7 @@ async function setGroupData({
}); });
} }
async function addTimestampEnterChat({ groupId, timestamp }) { export async function addTimestampEnterChat({ groupId, timestamp }) {
const wallet = await getSaveWallet(); const wallet = await getSaveWallet();
const address = wallet.address0; const address = wallet.address0;
const data = await getTimestampEnterChat(); const data = await getTimestampEnterChat();
@ -2974,6 +2989,24 @@ function setupMessageListener() {
case "removeAdmin": case "removeAdmin":
removeAdminCase(request, event); removeAdminCase(request, event);
break; break;
case "notification":
notificationCase(request, event);
break;
case "addTimestampEnterChat":
addTimestampEnterChatCase(request, event);
break;
case "setApiKey":
setApiKeyCase(request, event);
break;
case "setCustomNodes":
setCustomNodesCase(request, event);
case "getApiKey":
getApiKeyCase(request, event);
break;
case "getCustomNodesFromStorage":
getCustomNodesFromStorageCase(request, event);
break;
default: default:
console.error("Unknown action:", request.action); console.error("Unknown action:", request.action);
} }

View File

@ -267,13 +267,13 @@ const sendChatDirect = async ({ chatReference = undefined, messageText, otherDat
"senderName": myName "senderName": myName
}) })
setNewChat(null) setNewChat(null)
chrome?.runtime?.sendMessage({ window.sendMessage("addTimestampEnterChat", {
action: "addTimestampEnterChat", timestamp: Date.now(),
payload: { groupId: response.recipient,
timestamp: Date.now(), }).catch((error) => {
groupId: response.recipient, console.error("Failed to add timestamp:", error.message || "An error occurred");
}, });
});
setTimeout(() => { setTimeout(() => {
getTimestampEnterChat() getTimestampEnterChat()
}, 400); }, 400);

View File

@ -901,22 +901,22 @@ export const Group = ({
setMemberGroups(message.payload); setMemberGroups(message.payload);
if (selectedGroupRef.current && groupSectionRef.current === "chat") { if (selectedGroupRef.current && groupSectionRef.current === "chat") {
chrome?.runtime?.sendMessage({ window.sendMessage("addTimestampEnterChat", {
action: "addTimestampEnterChat", timestamp: Date.now(),
payload: { groupId: selectedGroupRef.current.groupId,
timestamp: Date.now(), }).catch((error) => {
groupId: selectedGroupRef.current.groupId, console.error("Failed to add timestamp:", error.message || "An error occurred");
}, });
});
} }
if (selectedDirectRef.current) { if (selectedDirectRef.current) {
chrome?.runtime?.sendMessage({ window.sendMessage("addTimestampEnterChat", {
action: "addTimestampEnterChat", timestamp: Date.now(),
payload: { groupId: selectedDirectRef.current.address,
timestamp: Date.now(), }).catch((error) => {
groupId: selectedDirectRef.current.address, console.error("Failed to add timestamp:", error.message || "An error occurred");
}, });
});
} }
setTimeout(() => { setTimeout(() => {
getTimestampEnterChat(); getTimestampEnterChat();
@ -946,18 +946,7 @@ export const Group = ({
// Update the component state with the received 'sendqort' state // Update the component state with the received 'sendqort' state
setDirects(message.payload); setDirects(message.payload);
// if (selectedGroupRef.current) {
// chrome?.runtime?.sendMessage({
// action: "addTimestampEnterChat",
// payload: {
// timestamp: Date.now(),
// groupId: selectedGroupRef.current.groupId,
// },
// });
// }
// setTimeout(() => {
// getTimestampEnterChat();
// }, 200);
} else if (message.action === "PLAY_NOTIFICATION_SOUND") { } else if (message.action === "PLAY_NOTIFICATION_SOUND") {
audio.play(); audio.play();
} }
@ -1115,13 +1104,13 @@ export const Group = ({
setNewChat(false); setNewChat(false);
chrome?.runtime?.sendMessage({ window.sendMessage("addTimestampEnterChat", {
action: "addTimestampEnterChat", timestamp: Date.now(),
payload: { groupId: findDirect.address,
timestamp: Date.now(), }).catch((error) => {
groupId: findDirect.address, console.error("Failed to add timestamp:", error.message || "An error occurred");
}, });
});
setTimeout(() => { setTimeout(() => {
setSelectedDirect(findDirect); setSelectedDirect(findDirect);
@ -1152,13 +1141,13 @@ export const Group = ({
setNewChat(false); setNewChat(false);
chrome?.runtime?.sendMessage({ window.sendMessage("addTimestampEnterChat", {
action: "addTimestampEnterChat", timestamp: Date.now(),
payload: { groupId: findDirect.address,
timestamp: Date.now(), }).catch((error) => {
groupId: findDirect.address, console.error("Failed to add timestamp:", error.message || "An error occurred");
}, });
});
setTimeout(() => { setTimeout(() => {
setSelectedDirect(findDirect); setSelectedDirect(findDirect);
@ -1201,13 +1190,13 @@ export const Group = ({
const handleMarkAsRead = (e) => { const handleMarkAsRead = (e) => {
const { groupId } = e.detail; const { groupId } = e.detail;
chrome?.runtime?.sendMessage({ window.sendMessage("addTimestampEnterChat", {
action: "addTimestampEnterChat", timestamp: Date.now(),
payload: { groupId,
timestamp: Date.now(), }).catch((error) => {
groupId, console.error("Failed to add timestamp:", error.message || "An error occurred");
}, });
});
chrome?.runtime?.sendMessage({ chrome?.runtime?.sendMessage({
action: "addGroupNotificationTimestamp", action: "addGroupNotificationTimestamp",
@ -1323,13 +1312,13 @@ export const Group = ({
setFirstSecretKeyInCreation(false); setFirstSecretKeyInCreation(false);
setGroupSection("chat"); setGroupSection("chat");
chrome?.runtime?.sendMessage({ window.sendMessage("addTimestampEnterChat", {
action: "addTimestampEnterChat", timestamp: Date.now(),
payload: { groupId: findGroup.groupId,
timestamp: Date.now(), }).catch((error) => {
groupId: findGroup.groupId, console.error("Failed to add timestamp:", error.message || "An error occurred");
}, });
});
setTimeout(() => { setTimeout(() => {
setSelectedGroup(findGroup); setSelectedGroup(findGroup);
@ -1537,13 +1526,13 @@ export const Group = ({
setNewChat(false); setNewChat(false);
setSelectedDirect(null); setSelectedDirect(null);
if (selectedGroupRef.current) { if (selectedGroupRef.current) {
chrome?.runtime?.sendMessage({ window.sendMessage("addTimestampEnterChat", {
action: "addTimestampEnterChat", timestamp: Date.now(),
payload: { groupId: selectedGroupRef.current.groupId,
timestamp: Date.now(), }).catch((error) => {
groupId: selectedGroupRef.current.groupId, console.error("Failed to add timestamp:", error.message || "An error occurred");
}, });
});
setTimeout(() => { setTimeout(() => {
getTimestampEnterChat(); getTimestampEnterChat();
@ -1644,13 +1633,13 @@ export const Group = ({
setNewChat(false); setNewChat(false);
// setSelectedGroup(null); // setSelectedGroup(null);
setIsOpenDrawer(false); setIsOpenDrawer(false);
chrome?.runtime?.sendMessage({ window.sendMessage("addTimestampEnterChat", {
action: "addTimestampEnterChat", timestamp: Date.now(),
payload: { groupId: direct.address,
timestamp: Date.now(), }).catch((error) => {
groupId: direct.address, console.error("Failed to add timestamp:", error.message || "An error occurred");
}, });
});
setTimeout(() => { setTimeout(() => {
setSelectedDirect(direct); setSelectedDirect(direct);
@ -1771,172 +1760,7 @@ export const Group = ({
borderRadius: !isMobile && '0px 15px 15px 0px' borderRadius: !isMobile && '0px 15px 15px 0px'
}} }}
> >
{/* <div
style={{
display: "flex",
width: "100%",
justifyContent: "center",
gap: "20px",
padding: "10px",
flexDirection: "column",
}}
>
{isMobile && (
<Box
sx={{
width: "100%",
display: "flex",
justifyContent: "flex-end",
}}
>
<CloseIcon
onClick={() => {
setIsOpenDrawer(false);
}}
sx={{
cursor: "pointer",
color: "white",
}}
/>
</Box>
)}
<CustomButton
onClick={() => {
setChatMode((prev) =>
prev === "directs" ? "groups" : "directs"
);
}}
sx={{
backgroundColor: chatMode === 'directs' && ( groupChatHasUnread || groupsAnnHasUnread) ? 'red' : 'revert'
}}
>
{chatMode === "groups" && (
<>
<MarkUnreadChatAltIcon
sx={{
color: directChatHasUnread ? "red" : "white",
}}
/>
</>
)}
{chatMode === "directs" ? "Switch to groups" : "Direct msgs"}
</CustomButton>
</div> */}
{/* <div
style={{
display: "flex",
width: "100%",
flexDirection: "column",
alignItems: "flex-start",
flexGrow: 1,
overflowY: "auto",
visibility: chatMode === "groups" && "hidden",
position: chatMode === "groups" && "fixed",
left: chatMode === "groups" && "-1000px",
}}
>
{directs.map((direct: any) => (
<List sx={{
width: '100%'
}} className="group-list" dense={true}>
<ListItem
// secondaryAction={
// <IconButton edge="end" aria-label="delete">
// <SettingsIcon />
// </IconButton>
// }
onClick={() => {
setSelectedDirect(null);
setNewChat(false);
// setSelectedGroup(null);
setIsOpenDrawer(false);
chrome?.runtime?.sendMessage({
action: "addTimestampEnterChat",
payload: {
timestamp: Date.now(),
groupId: direct.address,
},
});
setTimeout(() => {
setSelectedDirect(direct);
getTimestampEnterChat();
}, 200);
}}
sx={{
display: "flex",
width: "100%",
flexDirection: "column",
cursor: "pointer",
border: "1px #232428 solid",
padding: "2px",
borderRadius: "2px",
background:
direct?.address === selectedDirect?.address && "white",
}}
>
<Box
sx={{
display: "flex",
width: "100%",
}}
>
<ListItemAvatar>
<Avatar
sx={{
background: "#232428",
color: "white",
}}
alt={direct?.name || direct?.address}
// src={`${getBaseApiReact()}/arbitrary/THUMBNAIL/${groupOwner?.name}/qortal_group_avatar_${group.groupId}?async=true`}
>
{(direct?.name || direct?.address)?.charAt(0)}
</Avatar>
</ListItemAvatar>
<ListItemText
primary={direct?.name || direct?.address}
primaryTypographyProps={{
style: {
color:
direct?.address === selectedDirect?.address &&
"black",
textWrap: "wrap",
overflow: "hidden",
},
}} // Change the color of the primary text
secondaryTypographyProps={{
style: {
color:
direct?.address === selectedDirect?.address &&
"black",
},
}}
sx={{
width: "150px",
fontFamily: "Inter",
fontSize: "16px",
}}
/>
{direct?.sender !== myAddress &&
direct?.timestamp &&
((!timestampEnterData[direct?.address] &&
Date.now() - direct?.timestamp <
timeDifferenceForNotificationChats) ||
timestampEnterData[direct?.address] <
direct?.timestamp) && (
<MarkChatUnreadIcon
sx={{
color: "red",
}}
/>
)}
</Box>
</ListItem>
</List>
))}
</div> */}
<div <div
style={{ style={{
display: "flex", display: "flex",
@ -1994,13 +1818,13 @@ export const Group = ({
// getTimestampEnterChat(); // getTimestampEnterChat();
}, 200); }, 200);
chrome?.runtime?.sendMessage({ window.sendMessage("addTimestampEnterChat", {
action: "addTimestampEnterChat", timestamp: Date.now(),
payload: { groupId: group.groupId,
timestamp: Date.now(), }).catch((error) => {
groupId: group.groupId, console.error("Failed to add timestamp:", error.message || "An error occurred");
}, });
});
setTimeout(() => { setTimeout(() => {
getTimestampEnterChat(); getTimestampEnterChat();