Commit 11eb633b authored by Muhammadali's avatar Muhammadali

update-

parent fe8dfbb8
{
"name": "boxdialer",
"version": "4.8.54",
"version": "4.8.55",
"description": "",
"main": "src/boxDialer.js",
"scripts": {
......
......@@ -34,13 +34,13 @@ const ControlRenderBX = () => {
console.log('window_alovoice_wsphone: ', window.alovoice_wsphone);
return (
<div>
{/*{wsphonedata?.number && (*/}
{wsphonedata?.number && (
<Root
setWsphonedata={setWsphonedata}
onSetDnd={window.alovoice_onsetdnd}
wsphonedata={wsphonedata}
/>
{/*)}*/}
)}
</div>
);
};
......
/** @format */
import React, { useContext, useEffect, useState } from 'react';
import React, {useContext, useEffect, useState} from 'react';
import packageJson from '../../package.json';
import DefaultWidjetUi from '../components/DefaultWidjetUi';
import ModalPhoneNumpad from '../components/ModalPhoneNumpad';
......@@ -11,180 +11,181 @@ import InnerCaller from '../components/InnerCaller';
import {useConfigHoldMute} from "../storage"
// import { contextModalEventProperty } from '../context/modalEventProperty';
const Root = ({ wsphonedata, onSetDnd, setWsphonedata, callMethod }) => {
const boxDialer = window.BoxDialer;
// // context
// const { callEvents, setCallEvents } = useContext(contextModalEventProperty);
const configHoldMute = useConfigHoldMute((state) => state)
const [phoneModal, setPhoneModal] = useState(false);
const [dynamicValue, setDynamicValue] = useState('pending');
const [modalState, setModalState] = useState(false);
const [secondLine, setSecondLine] = useState(false);
const [innerTimer, setInnerTimer] = useState(null);
const [innerCallerModal, setInnerCallerModal] = useState({
bool: false,
type: null,
from: '',
});
useEffect(() => {
if (secondLine) {
setTimeout(() => {
setSecondLine(false);
}, 5000);
}
}, [secondLine]);
useEffect(() => {
if (wsphonedata && wsphonedata?.number) {
boxDialer.setSipStateChangeCallback(setDynamicValue, 'dynamicValue');
boxDialer.setSipStateChangeCallback(setModalState, 'modalState');
boxDialer.setSipStateChangeCallback(setSecondLine, 'secondLine');
boxDialer.setSipStateChangeCallback(setPhoneModal, 'phoneModal');
boxDialer.setSipStateChangeCallback(setInnerTimer, 'innerTimer');
// // context
boxDialer.setSipStateChangeCallback(configHoldMute.setState, 'setCallEvents');
boxDialer.setSipStateChangeCallback(
setInnerCallerModal,
'innerCallerModal',
);
if (boxDialer.isUaRunning()) console.log('UA is running! in other tab');
else boxDialer.sipRegister(wsphonedata);
setTimeout(function waitUaRegisterLost() {
if (boxDialer.isUaRunning() || boxDialer.isRestarting)
setTimeout(waitUaRegisterLost, 10);
else boxDialer.sipRegister(wsphonedata);
}, 10);
}
}, []);
const hangupButton = () => {
boxDialer.hangupButtonClick();
};
window.setWSData = (result) => {
console.log('setWsphonedata', result);
setWsphonedata(result);
};
const reasonSelect = async (e) => {
let result = await onSetDnd(e);
if(setWsphonedata){
setWsphonedata(result);
}
console.log('reasonSelect_setWsphonedata', typeof setWsphonedata)
};
const getTransferers = async (e) => {
let result = await callMethod({
method: 'getPeers',
});
setWsphonedata(result);
};
const selectWidjetType = (type) => {
switch (type) {
case 'bxmini':
return (
<BxMiniWidjetUi
widjetState={dynamicValue}
phoneNumber={wsphonedata?.number}
reason={wsphonedata?.reason}
widjetVersion={packageJson?.version}
leftTime={wsphonedata.lefttime}
position={wsphonedata.position || 'bottomLeft'}
onClick={() => {
phoneModal ? setPhoneModal(false) : setPhoneModal(true);
}}
/>
);
default:
return (
<DefaultWidjetUi
widjetState={dynamicValue}
phoneNumber={wsphonedata?.number}
reason={wsphonedata?.reason}
widjetVersion={packageJson?.version}
leftTime={wsphonedata.lefttime}
position={wsphonedata.position || 'bottomLeft'}
onClick={() => {
phoneModal ? setPhoneModal(false) : setPhoneModal(true);
}}
/>
);
}
};
console.log(
'wsphonedata_all_data: ',
wsphonedata?.position,
wsphonedata?.number,
wsphonedata,
);
window.onbeforeunload = () => {
if (typeof BX !== 'undefined') {
boxDialer.isRestarting = true;
console.log('window_onbeforeunload =============-------------');
localStorage.removeItem('mycall');
localStorage.removeItem(BX.bitrix_sessid() + '_mycall');
console.log(
'--==== Checking removed Items: ',
localStorage.getItem('mycall'),
localStorage.getItem(BX.bitrix_sessid() + '_mycall'),
);
}
};
if (!wsphonedata || !wsphonedata?.number || !wsphonedata?.position) return;
return (
<>
{selectWidjetType(wsphonedata.variant)}
<ModalPhoneNumpad
modalState={modalState}
phoneModal={phoneModal}
reasons={wsphonedata?.reasons}
reason={wsphonedata?.reason}
onClick={(e) => e.stopPropagation()}
dynamicValue={dynamicValue}
onSetDnd={reasonSelect}
variant={wsphonedata.variant || 'defaultWidjet'}
position={wsphonedata.position || 'bottomLeft'}
extnums={wsphonedata.extnums}
/>
<Modal
className='tailwindGlobalCss'
hidden={modalState.bool}
// hidden={true}
callType={modalState.callType}
// callType={'connected'}
hangupButton={hangupButton}
phoneNumber={
modalState.callType === 'outcoming'
? 'inputValue'
: modalState.callFromName
}
/>
<InnerCaller
hidden={innerCallerModal.bool}
// hidden={true}
type={innerCallerModal.type}
// type={'connectingIncoming'}
from={innerCallerModal.from}
innerTimer={innerTimer}
/>
<SecondNotifSip secondLine={secondLine} />
</>
);
const Root = ({wsphonedata, onSetDnd, setWsphonedata, callMethod}) => {
const boxDialer = window.BoxDialer;
// // context
// const { callEvents, setCallEvents } = useContext(contextModalEventProperty);
const configHoldMute = useConfigHoldMute((state) => state)
const [phoneModal, setPhoneModal] = useState(false);
const [dynamicValue, setDynamicValue] = useState('pending');
const [modalState, setModalState] = useState(false);
const [secondLine, setSecondLine] = useState(false);
const [innerTimer, setInnerTimer] = useState(null);
const [innerCallerModal, setInnerCallerModal] = useState({
bool: false,
type: null,
from: '',
});
useEffect(() => {
if (secondLine) {
setTimeout(() => {
setSecondLine(false);
}, 5000);
}
}, [secondLine]);
useEffect(() => {
if (wsphonedata && wsphonedata?.number) {
boxDialer.setSipStateChangeCallback(setDynamicValue, 'dynamicValue');
boxDialer.setSipStateChangeCallback(setModalState, 'modalState');
boxDialer.setSipStateChangeCallback(setSecondLine, 'secondLine');
boxDialer.setSipStateChangeCallback(setPhoneModal, 'phoneModal');
boxDialer.setSipStateChangeCallback(setInnerTimer, 'innerTimer');
// // context
boxDialer.setSipStateChangeCallback(configHoldMute.setState, 'setCallEvents');
boxDialer.setSipStateChangeCallback(
setInnerCallerModal,
'innerCallerModal',
);
if (boxDialer.isUaRunning()) console.log('UA is running! in other tab');
else boxDialer.sipRegister(wsphonedata);
setTimeout(function waitUaRegisterLost() {
if (boxDialer.isUaRunning() || boxDialer.isRestarting)
setTimeout(waitUaRegisterLost, 10);
else boxDialer.sipRegister(wsphonedata);
}, 10);
}
}, []);
const hangupButton = () => {
boxDialer.hangupButtonClick();
};
window.setWSData = (result) => {
console.log('setWsphonedata', result);
setWsphonedata(result);
};
const reasonSelect = async (e) => {
let result = await onSetDnd(e);
if (setWsphonedata) {
setWsphonedata(result);
}
console.log('reasonSelect_setWsphonedata', typeof setWsphonedata)
};
const getTransferers = async (e) => {
let result = await callMethod({
method: 'getPeers',
});
setWsphonedata(result);
};
const selectWidjetType = (type) => {
switch (type) {
case 'bxmini':
return (
<BxMiniWidjetUi
widjetState={dynamicValue}
phoneNumber={wsphonedata?.number}
reason={wsphonedata?.reason}
widjetVersion={packageJson?.version}
leftTime={wsphonedata.lefttime}
position={wsphonedata.position || 'bottomLeft'}
onClick={() => {
phoneModal ? setPhoneModal(false) : setPhoneModal(true);
}}
/>
);
default:
return (
<DefaultWidjetUi
widjetState={dynamicValue}
phoneNumber={wsphonedata?.number}
reason={wsphonedata?.reason}
widjetVersion={packageJson?.version}
leftTime={wsphonedata.lefttime}
position={wsphonedata.position || 'bottomLeft'}
onClick={() => {
phoneModal ? setPhoneModal(false) : setPhoneModal(true);
}}
/>
);
}
};
console.log(
'wsphonedata_all_data: ',
wsphonedata?.position,
wsphonedata?.number,
wsphonedata,
);
window.onbeforeunload = () => {
if (typeof BX !== 'undefined') {
boxDialer.isRestarting = true;
console.log('window_onbeforeunload =============-------------');
localStorage.removeItem('mycall');
localStorage.removeItem(BX.bitrix_sessid() + '_mycall');
console.log(
'--==== Checking removed Items: ',
localStorage.getItem('mycall'),
localStorage.getItem(BX.bitrix_sessid() + '_mycall'),
);
}
};
// if (!wsphonedata || !wsphonedata?.number || !wsphonedata?.position) return;
console.log('wsphonedata_variant: ', wsphonedata.variant, !wsphonedata, !wsphonedata?.number, !wsphonedata?.position)
return (
<>
{selectWidjetType(wsphonedata.variant)}
<ModalPhoneNumpad
modalState={modalState}
phoneModal={phoneModal}
reasons={wsphonedata?.reasons}
reason={wsphonedata?.reason}
onClick={(e) => e.stopPropagation()}
dynamicValue={dynamicValue}
onSetDnd={reasonSelect}
variant={wsphonedata.variant || 'defaultWidjet'}
position={wsphonedata.position || 'bottomLeft'}
extnums={wsphonedata.extnums}
/>
<Modal
className='tailwindGlobalCss'
hidden={modalState.bool}
// hidden={true}
callType={modalState.callType}
// callType={'connected'}
hangupButton={hangupButton}
phoneNumber={
modalState.callType === 'outcoming'
? 'inputValue'
: modalState.callFromName
}
/>
<InnerCaller
hidden={innerCallerModal.bool}
// hidden={true}
type={innerCallerModal.type}
// type={'connectingIncoming'}
from={innerCallerModal.from}
innerTimer={innerTimer}
/>
<SecondNotifSip secondLine={secondLine}/>
</>
);
};
export default Root;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment