Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
safetcut-app
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
atichat
safetcut-app
Commits
da24617a
Commit
da24617a
authored
Oct 03, 2019
by
HaOuiha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d76df389
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
10 deletions
+27
-10
reduxStore/actions/currentSelectedAction.js
+16
-1
screens/Private/SmartMeterScreen/SmartMeterDetailScreen.js
+11
-9
No files found.
reduxStore/actions/currentSelectedAction.js
View file @
da24617a
...
...
@@ -151,7 +151,22 @@ export const getCurrentSelectedData = (deviceId, showLoading) => async dispatch
}
};
export
const
updateSubscriptionToStore
=
newWholeShadow
=>
async
dispatch
=>
{
export
const
updateSubscriptionToStore
=
subscriptionData
=>
async
(
dispatch
,
getState
)
=>
{
const
{
currentSelectedDeviceReducer
}
=
getState
();
const
{
shadow
,
breakerStatus
}
=
currentSelectedDeviceReducer
;
console
.
log
(
'subscriptionData'
,
subscriptionData
);
console
.
log
(
's'
,
shadow
);
console
.
log
(
'b'
,
breakerStatus
);
[
'SM1'
,
'ML1'
,
'ML2'
,
'ML3'
,
'ML4'
].
map
(
item
=>
subscriptionData
.
hasOwnProperty
(
item
));
console
.
log
(
[
'SM1'
,
'ML1'
,
'ML2'
,
'ML3'
,
'ML4'
]
.
map
(
item
=>
subscriptionData
.
hasOwnProperty
(
item
))
.
some
(
item
=>
item
===
true
)
);
const
tempBreakersStatus
=
_
.
pick
(
newWholeShadow
,
[
'SM1'
,
'ML1'
,
'ML2'
,
'ML3'
,
'ML4'
]);
const
breakersStatus
=
{
...
tempBreakersStatus
,
SM1
:
{
BK_S
:
tempBreakersStatus
.
SM1
.
BK_S
}
};
...
...
screens/Private/SmartMeterScreen/SmartMeterDetailScreen.js
View file @
da24617a
...
...
@@ -54,7 +54,7 @@ class SmartMeterDetailScreen extends Component {
{
name
:
'Arcing Fault'
,
limit
:
1000
,
value
:
0
,
unit
:
''
},
],
shadow
:
null
,
//
shadow: null,
};
_mcbLinksListMounted
=
false
;
...
...
@@ -67,10 +67,10 @@ class SmartMeterDetailScreen extends Component {
document
:
SUBSCRIBE_SHADOW
,
variables
:
{
deviceid
:
this
.
deviceId
},
updateQuery
:
(
prev
,
{
subscriptionData
})
=>
{
this
.
setState
((
prevState
,
props
)
=>
({
shadow
:
{
...
prevState
.
shadow
,
...
subscriptionData
.
data
.
shadowUpdated
.
data
},
}));
this
.
props
.
updateSubscriptionToStore
(
this
.
state
.
shadow
);
//
this.setState((prevState, props) => ({
//
shadow: { ...prevState.shadow, ...subscriptionData.data.shadowUpdated.data },
//
}));
this
.
props
.
updateSubscriptionToStore
(
subscriptionData
.
data
.
shadowUpdated
.
data
);
},
});
};
...
...
@@ -81,8 +81,6 @@ class SmartMeterDetailScreen extends Component {
};
componentDidMount
=
async
()
=>
{
// console.log(this.state);
// console.log(this.props);
await
this
.
getData
();
this
.
setState
({
shadow
:
this
.
props
.
data
.
shadow
.
data
});
this
.
subscribeToNewShadow
(
this
.
props
.
data
.
subscribeToMore
);
...
...
@@ -107,7 +105,7 @@ class SmartMeterDetailScreen extends Component {
}
if
(
prevProps
.
isFocused
!==
this
.
props
.
isFocused
)
{
this
.
props
.
isFocused
===
true
&&
this
.
subscribeToNewShadow
(
this
.
props
.
data
.
subscribeToMore
);
this
.
props
.
isFocused
===
false
&&
this
.
unsubscribeShadow
();
this
.
props
.
isFocused
===
false
&&
this
.
unsubscribeShadow
&&
this
.
unsubscribeShadow
();
}
if
(
prevProps
.
shadow
!==
this
.
props
.
shadow
)
{
this
.
setState
({
...
...
@@ -125,16 +123,18 @@ class SmartMeterDetailScreen extends Component {
};
handleToggle
=
async
value
=>
{
this
.
unsubscribeShadow
&&
this
.
unsubscribeShadow
();
this
.
setState
({
isWaiting
:
true
});
await
this
.
props
.
setMainStatus
(
value
);
this
.
setState
({
isWaiting
:
false
});
this
.
subscribeToNewShadow
(
this
.
props
.
data
.
subscribeToMore
);
};
componentWillUnmount
=
()
=>
{
//reset new loading to redux; fix blink screen
this
.
props
.
loadingAction
(
true
);
this
.
props
.
loadingTimersAction
(
true
);
this
.
unsubscribeShadow
();
this
.
unsubscribeShadow
&&
this
.
unsubscribeShadow
();
};
setMainCardData
=
async
()
=>
{
...
...
@@ -268,9 +268,11 @@ class SmartMeterDetailScreen extends Component {
const
renderSubBreaker
=
(
subBreaker
,
indexSubBreakers
)
=>
{
const
handleOnPressSubBreakerSwitch
=
async
value
=>
{
this
.
unsubscribeShadow
&&
this
.
unsubscribeShadow
();
this
.
setState
({
isWaiting
:
true
});
await
this
.
props
.
setSubBreakerStatus
(
value
,
indexMcbLinks
,
indexSubBreakers
);
this
.
setState
({
isWaiting
:
false
});
this
.
subscribeToNewShadow
(
this
.
props
.
data
.
subscribeToMore
);
};
return
(
...
...
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