Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
BoxDialer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
BoxDialer
Commits
73f4a102
Commit
73f4a102
authored
Sep 20, 2023
by
Muhammadali
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
8c8540f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
39 deletions
+70
-39
index.jsx
src/components/ModalPhoneNumpad/index.jsx
+69
-38
boxDIaler.js
src/lib/boxDIaler.js
+1
-1
No files found.
src/components/ModalPhoneNumpad/index.jsx
View file @
73f4a102
...
@@ -22,37 +22,14 @@ const ModalPhoneNumpad = ({
...
@@ -22,37 +22,14 @@ const ModalPhoneNumpad = ({
const
[
inputValue
,
setInputValue
]
=
useState
(
''
);
const
[
inputValue
,
setInputValue
]
=
useState
(
''
);
const
[
call_history
,
setCall_history
]
=
useState
([]);
const
[
call_history
,
setCall_history
]
=
useState
([]);
const
[
numberSelectHistory
,
setNumberSelectHistory
]
=
useState
(
0
);
useEffect
(()
=>
{
useEffect
(()
=>
{
// setCall_history(JSON.parse(localStorage.getItem('call_history')) || []);
let
currentCalls
=
localStorage
.
getItem
(
'
callhistory
'
)
},
[]);
?
JSON
.
parse
(
localStorage
.
getItem
(
'
callhistory
'
))
:
false
;
// useEffect(() => {
if
(
currentCalls
)
setCall_history
(
currentCalls
);
// let call_history_storage = JSON.parse(localStorage.getItem('call_history'));
},
[
localStorage
.
getItem
(
'
callhistory
'
),
inputValue
]);
// if (call_history_storage.length !== call_history.length) {
// setCall_history(call_history_storage);
// localStorage.setItem('call_history', JSON.stringify(call_history));
// }
// }, [call_history]);
const
addNumberStorage
=
({
number
})
=>
{
// let stringNumber = number.toString() || '';
// let storageNumbers =
// // (localStorage.getItem('call_history') &&
// // JSON.parse(localStorage.getItem('call_history'))) ||
// // [];
// // console.log(
// // stringNumber,
// // null === localStorage.getItem('call_history'),
// // typeof [],
// // );
// localStorage.setItem('call_history', [
// stringNumber,
// ,
// ]);
// setCall_history([number, ...call_history]);
// }
};
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
modalState
.
bool
)
setInputValue
(
''
);
if
(
!
modalState
.
bool
)
setInputValue
(
''
);
},
[
modalState
.
bool
]);
},
[
modalState
.
bool
]);
...
@@ -90,10 +67,55 @@ const ModalPhoneNumpad = ({
...
@@ -90,10 +67,55 @@ const ModalPhoneNumpad = ({
}
}
};
};
const
history
=
({
type
})
=>
{
console
.
log
(
'
type
'
,
type
);
if
(
phoneModal
&&
(
modalState
.
bool
?
false
:
true
))
{
if
(
(
type
===
'
up
'
&&
numberSelectHistory
<
call_history
.
length
)
||
numberSelectHistory
===
'
zero
'
)
{
setNumberSelectHistory
(
numberSelectHistory
!==
'
zero
'
?
numberSelectHistory
+
1
:
0
+
1
,
);
}
if
(
type
===
'
down
'
&&
numberSelectHistory
>
0
)
{
setNumberSelectHistory
(
numberSelectHistory
!==
'
zero
'
?
numberSelectHistory
-
1
:
0
-
1
,
);
}
}
};
useEffect
(()
=>
{
if
(
phoneModal
&&
(
modalState
.
bool
?
false
:
true
))
{
let
selectedNumber
;
if
(
numberSelectHistory
==
0
)
{
setInputValue
(
''
);
}
selectedNumber
=
call_history
.
slice
(
numberSelectHistory
*
-
1
)[
0
]
?
call_history
.
slice
(
numberSelectHistory
*
-
1
)[
0
]
:
false
;
if
(
numberSelectHistory
===
0
)
{
selectedNumber
=
''
;
setNumberSelectHistory
(
'
zero
'
);
}
if
(
numberSelectHistory
===
'
zero
'
)
{
selectedNumber
=
''
;
setNumberSelectHistory
(
'
zero
'
);
}
if
(
selectedNumber
)
{
setInputValue
(
selectedNumber
);
}
}
},
[
numberSelectHistory
]);
console
.
log
(
'
numberSelectHistory
'
,
numberSelectHistory
);
document
.
onkeydown
=
function
(
e
)
{
document
.
onkeydown
=
function
(
e
)
{
if
(
phoneModal
&&
modalState
.
bool
?
false
:
true
)
{
if
(
phoneModal
&&
modalState
.
bool
?
false
:
true
)
{
e
=
e
||
window
.
event
;
e
=
e
||
window
.
event
;
if
(
e
.
ctrlKey
&&
e
.
keyCode
===
86
)
{
let
actualKeyCode
=
e
.
keyCode
;
if
(
e
.
ctrlKey
&&
actualKeyCode
===
86
)
{
navigator
.
clipboard
navigator
.
clipboard
.
readText
()
.
readText
()
.
then
((
text
)
=>
{
.
then
((
text
)
=>
{
...
@@ -109,8 +131,8 @@ const ModalPhoneNumpad = ({
...
@@ -109,8 +131,8 @@ const ModalPhoneNumpad = ({
const
gameState
=
{
const
gameState
=
{
toggleCP
:
(
e
)
=>
{
toggleCP
:
(
e
)
=>
{
if
(
phoneModal
&&
(
modalState
.
bool
?
false
:
true
)
&&
e
.
key
===
'
Enter
'
)
{
if
(
phoneModal
&&
(
modalState
.
bool
?
false
:
true
)
&&
e
.
key
===
'
Enter
'
)
{
boxDialer
.
initialized
(
inputValue
);
//
boxDialer.initialized(inputValue);
addNumberStorage
({
number
:
inputValue
}
);
callButton
(
);
}
else
if
(
}
else
if
(
phoneModal
&&
phoneModal
&&
(
modalState
.
bool
?
false
:
true
)
&&
(
modalState
.
bool
?
false
:
true
)
&&
...
@@ -128,12 +150,14 @@ const ModalPhoneNumpad = ({
...
@@ -128,12 +150,14 @@ const ModalPhoneNumpad = ({
(
modalState
.
bool
?
false
:
true
)
&&
(
modalState
.
bool
?
false
:
true
)
&&
e
.
key
===
'
Backspace
'
e
.
key
===
'
Backspace
'
)
{
)
{
}
}
else
if
(
(
phoneModal
&&
(
modalState
.
bool
?
false
:
true
)
&&
e
.
keyCode
==
38
)
||
e
.
keyCode
==
40
)
history
({
type
:
e
.
keyCode
===
38
?
'
up
'
:
'
down
'
});
},
},
};
};
// ArrowDown;
// ArrowUp
const
handleKeyUp
=
useCallback
(
const
handleKeyUp
=
useCallback
(
(
event
)
=>
{
(
event
)
=>
{
gameState
.
toggleCP
(
event
);
gameState
.
toggleCP
(
event
);
...
@@ -150,11 +174,18 @@ const ModalPhoneNumpad = ({
...
@@ -150,11 +174,18 @@ const ModalPhoneNumpad = ({
},
[
handleKeyUp
]);
},
[
handleKeyUp
]);
const
callButton
=
()
=>
{
const
callButton
=
()
=>
{
addNumberStorage
({
number
:
inputValue
});
// inset if ----------
if
(
Boolean
(
inputValue
.
toString
().
length
))
{
console
.
log
(
inputValue
,
'
inputValue
'
);
let
newCallsStringify
=
JSON
.
stringify
([...
call_history
,
inputValue
]);
localStorage
.
setItem
(
'
callhistory
'
,
newCallsStringify
);
}
// -------------------
if
(
dynamicValue
===
'
connected
'
)
{
if
(
dynamicValue
===
'
connected
'
)
{
// let call_history = localStorage.getItem('call_history');
// let call_history = localStorage.getItem('call_history');
// console.log(call_history, 'call_history');
boxDialer
.
initialized
(
inputValue
);
boxDialer
.
initialized
(
inputValue
);
}
else
{
}
else
{
toast
.
error
(
'
Please wait
'
,
{
toast
.
error
(
'
Please wait
'
,
{
...
...
src/lib/boxDIaler.js
View file @
73f4a102
...
@@ -219,13 +219,13 @@ export class BoxDialer {
...
@@ -219,13 +219,13 @@ export class BoxDialer {
let
uiStates
=
{
let
uiStates
=
{
stack_i_new_call
:
stack_i_new_call
:
this
.
callDirection
===
'
in
'
?
'
connectingIncoming
'
:
'
connected
'
,
this
.
callDirection
===
'
in
'
?
'
connectingIncoming
'
:
'
connected
'
,
call_connected
:
'
connected
'
,
call_connected
:
'
connected
'
,
call_m_stream_audio_remote_added
:
'
connected
'
,
call_m_stream_audio_remote_added
:
'
connected
'
,
call_i_ao_request
:
'
connectingOutgoing
'
,
call_i_ao_request
:
'
connectingOutgoing
'
,
stack_m_permission_accepted
:
stack_m_permission_accepted
:
this
.
callDirection
===
'
in
'
?
'
incoming
'
:
'
outgoing
'
,
this
.
callDirection
===
'
in
'
?
'
incoming
'
:
'
outgoing
'
,
};
};
return
sipState
&&
uiStates
[
sipState
]
?
uiStates
[
sipState
]
:
''
;
return
sipState
&&
uiStates
[
sipState
]
?
uiStates
[
sipState
]
:
''
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment