File tree 1 file changed +30
-32
lines changed
src/shared/components/Settings/Tools/Devices
1 file changed +30
-32
lines changed Original file line number Diff line number Diff line change @@ -90,40 +90,38 @@ export default class Devices extends ConsentComponent {
90
90
if ( this . onCheckFormValue ( newDevice ) ) {
91
91
return ;
92
92
}
93
- if ( ! isEdit ) {
94
- const deviceItems = deviceTrait . traits
95
- ? deviceTrait . traits . data . slice ( ) : [ ] ;
96
- let exist = false ;
97
- // eslint-disable-next-line no-restricted-syntax
98
- for ( const item of deviceItems ) {
99
- if ( item . deviceType === newDevice . deviceType
100
- && item . manufacturer === newDevice . manufacturer
101
- && item . model === newDevice . model
102
- && item . operatingSystem === newDevice . operatingSystem ) {
103
- exist = true ;
104
- break ;
105
- }
106
- }
107
- if ( exist === true ) {
108
- const empty = {
109
- deviceType : '' ,
110
- manufacturer : '' ,
111
- model : '' ,
112
- operatingSystem : '' ,
113
- } ;
114
- this . setState ( {
115
- newDevice : empty ,
116
- isEdit : false ,
117
- indexNo : null ,
118
- isSubmit : false ,
119
- } ) ;
120
- clearDeviceState ( ) ;
121
- setImmediate ( ( ) => {
122
- toastr . error ( 'Looks like you\'ve already entered this device.' ) ;
123
- } ) ;
124
- return ;
93
+ const deviceItems = deviceTrait . traits
94
+ ? deviceTrait . traits . data . slice ( ) : [ ] ;
95
+ let exist = false ;
96
+ // eslint-disable-next-line no-restricted-syntax
97
+ for ( const item of deviceItems ) {
98
+ if ( item . deviceType === newDevice . deviceType
99
+ && item . manufacturer === newDevice . manufacturer
100
+ && item . model === newDevice . model
101
+ && item . operatingSystem === newDevice . operatingSystem ) {
102
+ exist = true ;
103
+ break ;
125
104
}
126
105
}
106
+ if ( exist === true ) {
107
+ const empty = {
108
+ deviceType : '' ,
109
+ manufacturer : '' ,
110
+ model : '' ,
111
+ operatingSystem : '' ,
112
+ } ;
113
+ this . setState ( {
114
+ newDevice : empty ,
115
+ isEdit : false ,
116
+ indexNo : null ,
117
+ isSubmit : false ,
118
+ } ) ;
119
+ clearDeviceState ( ) ;
120
+ setImmediate ( ( ) => {
121
+ toastr . error ( 'Looks like you\'ve already entered this device.' ) ;
122
+ } ) ;
123
+ return ;
124
+ }
127
125
this . showConsent ( this . onAddDevice . bind ( this ) ) ;
128
126
}
129
127
You can’t perform that action at this time.
0 commit comments