diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 2a03d51..752a547 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -64,6 +64,7 @@ "You must accept audio and video permissions.": "You must accept audio/video permissions", "Unknown audio or camera permissions.": "Unknown audio/camera permissions", "Web Phone connection is down.": "Web Phone connection is down", + "NethLink connection is down.": "NethLink connection is down", "Server connection is down.": "Server connection is down", "Camera is already used.": "Camera is already used", "Call transferred successfully.": "Call transferred successfully" diff --git a/public/locales/it/translation.json b/public/locales/it/translation.json index d867ceb..80cc1cc 100644 --- a/public/locales/it/translation.json +++ b/public/locales/it/translation.json @@ -64,6 +64,7 @@ "Accept audio and video permissions.": "Accetta le autorizzazioni audio/video", "Unknown audio or camera permissions.": "Autorizzazioni audio/camera sconosciute", "Web Phone connection is down.": "Connessione Web Phone non disponibile", + "NethLink connection is down.": "Connessione NethLink non disponibile", "Server connection is down.": "Connessione al server non disponibile", "Camera is already used.": "Camera giĆ  in uso", "Call transferred successfully.": "Chiamata trasferita con successo" diff --git a/src/App.tsx b/src/App.tsx index 551613d..4eeabfa 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -12,6 +12,7 @@ import { useEventListener, eventDispatch, setJSONItem, getJSONItem } from './uti import { detach } from './lib/webrtc/messages' import { checkDarkTheme, setTheme } from './lib/darkTheme' import { changeOperatorStatus } from './services/user' +import { isEmpty } from './utils/genericFunctions/isEmpty' interface PhoneIslandProps { dataConfig: string @@ -168,6 +169,25 @@ export const PhoneIsland: FC = ({ store.dispatch.alerts.setAlert(alertType.toString()) }) + useEventListener('phone-island-main-presence', (data: any) => { + const currentUsernameInformation: any = store.getState().currentUser?.username + const currentUserObject: any = store.getState().currentUser + let mainPresenceValueBeforeUpdate = currentUserObject?.mainPresence + if ( + currentUsernameInformation !== undefined && + currentUsernameInformation !== '' && + !isEmpty(data[currentUsernameInformation]) && + data[currentUsernameInformation]?.mainPresence !== undefined + ) { + let newMainPresenceValue = data[currentUsernameInformation]?.mainPresence + store.dispatch.currentUser.updateMainPresence(data[currentUsernameInformation]?.mainPresence) + let mainPresenceValueAfterUpdate = newMainPresenceValue + if (mainPresenceValueAfterUpdate === 'online' && mainPresenceValueBeforeUpdate !== 'online') { + eventDispatch('phone-island-call-ended', {}) + } + } + }) + return ( <> diff --git a/src/components/AlertView/index.tsx b/src/components/AlertView/index.tsx index d83da0d..d1062ee 100644 --- a/src/components/AlertView/index.tsx +++ b/src/components/AlertView/index.tsx @@ -9,12 +9,14 @@ import { faTimes, faCircleXmark, faCircleCheck } from '@fortawesome/free-solid-s import { Button } from '../Button' import { t } from 'i18next' import { eventDispatch } from '../../utils' +import { store } from '../../store' /** * Shows user alerts */ const AlertView: FC = () => { const { data } = useSelector((state: RootState) => state.alerts) + const { default_device } = useSelector((state: RootState) => state.currentUser) const dispatch = useDispatch() // Extract active alerts @@ -53,7 +55,13 @@ const AlertView: FC = () => {

- {t(`Errors.${latestAlert?.type}`)} + {t( + `Errors.${ + default_device?.type === 'nethlink' && latestAlert?.type === 'webrtc_down' + ? latestAlert?.nethlink_message + : latestAlert?.type + }`, + )}

{t(`Errors.${latestAlert?.message}`)} diff --git a/src/models/alerts.ts b/src/models/alerts.ts index 68ec1dc..54e7c19 100644 --- a/src/models/alerts.ts +++ b/src/models/alerts.ts @@ -29,6 +29,7 @@ const defaultState: AlertsTypes = { active: false, break: true, message: 'Web Phone connection is down.', + nethlink_message: 'NethLink connection is down.', type: 'webrtc_down', }, socket_down: { @@ -143,4 +144,5 @@ export interface AlertTypes { break?: boolean // This means that it brokes WebRTC audio calls or Socket connection success?: boolean type: string + nethlink_message?: string } diff --git a/src/models/currentUser.ts b/src/models/currentUser.ts index 8d0d660..6b7fb8e 100644 --- a/src/models/currentUser.ts +++ b/src/models/currentUser.ts @@ -19,6 +19,9 @@ export const currentUser = createModel()({ ...payload, } }, + updateMainPresence: (state, payload) => { + state.mainPresence = payload + }, updateCurrentDefaultDevice: (state, payload) => { state.default_device = payload },