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" export const groupApiSocketLocal = "ws://127.0.0.1:12391"
const timeDifferenceForNotificationChatsBackground = 600000 const timeDifferenceForNotificationChatsBackground = 600000
const requestQueueAnnouncements = new RequestQueueWithPromise(1) 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 = { const allQueues = {
requestQueueAnnouncements: requestQueueAnnouncements, requestQueueAnnouncements: requestQueueAnnouncements,
} }
@ -237,9 +258,12 @@ if (!oldestLatestTimestamp || oldChat?.timestamp > oldestLatestTimestamp?.timest
// { title: 'Go to group' } // { title: 'Go to group' }
// ] // ]
}); });
setTimeout(() => { if(!isMobile){
chrome.notifications.clear(notificationId); setTimeout(() => {
}, 7000); chrome.notifications.clear(notificationId);
}, 7000);
}
// chrome.runtime.sendMessage( // chrome.runtime.sendMessage(
// { // {
// action: "notification", // action: "notification",
@ -282,9 +306,11 @@ if (!oldestLatestTimestamp || oldChat?.timestamp > oldestLatestTimestamp?.timest
// { title: 'Go to group' } // { title: 'Go to group' }
// ] // ]
}); });
if(!isMobile){
setTimeout(() => { setTimeout(() => {
chrome.notifications.clear(notificationId); chrome.notifications.clear(notificationId);
}, 7000); }, 7000);
}
playNotificationSound() playNotificationSound()
// audio.play(); // audio.play();
// } // }
@ -427,9 +453,11 @@ const handleNotification = async (groups)=> {
// { title: 'Go to group' } // { title: 'Go to group' }
// ] // ]
}); });
if(!isMobile){
setTimeout(() => { setTimeout(() => {
chrome.notifications.clear(notificationId); chrome.notifications.clear(notificationId);
}, 7000); }, 7000);
}
// chrome.runtime.sendMessage( // chrome.runtime.sendMessage(
// { // {
// action: "notification", // action: "notification",
@ -472,9 +500,11 @@ const handleNotification = async (groups)=> {
// { title: 'Go to group' } // { title: 'Go to group' }
// ] // ]
}); });
if(!isMobile){
setTimeout(() => { setTimeout(() => {
chrome.notifications.clear(notificationId); chrome.notifications.clear(notificationId);
}, 7000); }, 7000);
}
playNotificationSound() playNotificationSound()
// audio.play(); // audio.play();
lastGroupNotification = Date.now() lastGroupNotification = Date.now()
@ -614,9 +644,11 @@ const checkThreads = async (bringBack) => {
// { title: 'Go to group' } // { title: 'Go to group' }
// ] // ]
}); });
if(!isMobile){
setTimeout(() => { setTimeout(() => {
chrome.notifications.clear(notificationId); chrome.notifications.clear(notificationId);
}, 7000); }, 7000);
}
playNotificationSound() playNotificationSound()
} }
const savedtimestampAfter = await getTimestampGroupAnnouncement() const savedtimestampAfter = await getTimestampGroupAnnouncement()
@ -685,9 +717,11 @@ const checkNewMessages =
// { title: 'Go to group' } // { title: 'Go to group' }
// ] // ]
}); });
if(!isMobile){
setTimeout(() => { setTimeout(() => {
chrome.notifications.clear(notificationId); chrome.notifications.clear(notificationId);
}, 7000); }, 7000);
}
playNotificationSound() playNotificationSound()
} }
const savedtimestampAfter = await getTimestampGroupAnnouncement() const savedtimestampAfter = await getTimestampGroupAnnouncement()

View File

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

View File

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

View File

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