This commit is contained in:
PhilReact 2024-09-12 05:41:57 +03:00
parent 99f2ae1885
commit f032016b83
4 changed files with 42 additions and 6 deletions

View File

@ -32,7 +32,28 @@ export const groupApiLocal = "http://127.0.0.1:12391"
export const groupApiSocketLocal = "ws://127.0.0.1:12391"
const timeDifferenceForNotificationChatsBackground = 600000
const requestQueueAnnouncements = new RequestQueueWithPromise(1)
let isMobile = false
const isMobileDevice = () => {
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
if (/android/i.test(userAgent)) {
return true; // Android device
}
if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
return true; // iOS device
}
return false;
};
if (isMobileDevice()) {
isMobile = true
console.log("Running on a mobile device");
} else {
console.log("Running on a desktop");
}
const allQueues = {
requestQueueAnnouncements: requestQueueAnnouncements,
}
@ -237,9 +258,12 @@ if (!oldestLatestTimestamp || oldChat?.timestamp > oldestLatestTimestamp?.timest
// { title: 'Go to group' }
// ]
});
setTimeout(() => {
chrome.notifications.clear(notificationId);
}, 7000);
if(!isMobile){
setTimeout(() => {
chrome.notifications.clear(notificationId);
}, 7000);
}
// chrome.runtime.sendMessage(
// {
// action: "notification",
@ -282,9 +306,11 @@ if (!oldestLatestTimestamp || oldChat?.timestamp > oldestLatestTimestamp?.timest
// { title: 'Go to group' }
// ]
});
if(!isMobile){
setTimeout(() => {
chrome.notifications.clear(notificationId);
}, 7000);
}
playNotificationSound()
// audio.play();
// }
@ -427,9 +453,11 @@ const handleNotification = async (groups)=> {
// { title: 'Go to group' }
// ]
});
if(!isMobile){
setTimeout(() => {
chrome.notifications.clear(notificationId);
}, 7000);
}
// chrome.runtime.sendMessage(
// {
// action: "notification",
@ -472,9 +500,11 @@ const handleNotification = async (groups)=> {
// { title: 'Go to group' }
// ]
});
if(!isMobile){
setTimeout(() => {
chrome.notifications.clear(notificationId);
}, 7000);
}
playNotificationSound()
// audio.play();
lastGroupNotification = Date.now()
@ -614,9 +644,11 @@ const checkThreads = async (bringBack) => {
// { title: 'Go to group' }
// ]
});
if(!isMobile){
setTimeout(() => {
chrome.notifications.clear(notificationId);
}, 7000);
}
playNotificationSound()
}
const savedtimestampAfter = await getTimestampGroupAnnouncement()
@ -685,9 +717,11 @@ const checkNewMessages =
// { title: 'Go to group' }
// ]
});
if(!isMobile){
setTimeout(() => {
chrome.notifications.clear(notificationId);
}, 7000);
}
playNotificationSound()
}
const savedtimestampAfter = await getTimestampGroupAnnouncement()

View File

@ -60,7 +60,8 @@ export const AnnouncementItem = ({ message, messageData, setSelectedAnnouncement
<Box sx={{
display: "flex",
gap: '7px',
width: '100%'
width: '100%',
wordBreak: 'break-word'
}}>
<Avatar
sx={{

View File

@ -11,7 +11,7 @@ import { LoadingSnackbar } from '../Snackbar/LoadingSnackbar';
import { getNameInfo } from '../Group/Group';
import { Spacer } from '../../common/Spacer';
import { CustomizedSnackbars } from '../Snackbar/Snackbar';
import { getBaseApiReactSocket } from '../../App';
import { getBaseApiReactSocket, isMobile } from '../../App';
@ -226,7 +226,7 @@ const clearEditorContent = () => {
return (
<div style={{
height: '100vh',
height: isMobile ? '100%' : '100vh',
display: 'flex',
flexDirection: 'column',
width: '100%'

View File

@ -1818,6 +1818,7 @@ export const Group = ({
position: "relative",
flexGrow: 1,
display: "flex",
height: '100%'
}}
>
<ChatDirect