1
1
import { DashLayoutPath , DashComponent , BaseDashProps } from '../types/component' ;
2
- import { getComponentLayout , stringifyPath } from './wrapping' ;
2
+ import { getComponentLayout , stringifyPath , checkChildrenLayoutHashes } from './wrapping' ;
3
+ import { pathOr } from 'ramda'
3
4
4
5
type SelectDashProps = [ DashComponent , BaseDashProps , number , object , string ] ;
5
6
7
+ interface ChangedPropsRecord {
8
+ hash : number ;
9
+ changedProps : Record < string , any > ;
10
+ renderType : string ;
11
+ }
12
+
13
+ const previousHashes = { }
14
+
15
+ function determineChangedProps ( state : any , strPath : string ) : ChangedPropsRecord {
16
+ let combinedHash = 0 ;
17
+ let renderType = 'update' ; // Default render type, adjust as needed
18
+ Object . entries ( state . layoutHashes ) . forEach ( ( [ updatedPath , pathHash ] ) => {
19
+ if ( updatedPath . startsWith ( strPath ) ) {
20
+ const previousHash : any = pathOr ( { } , [ updatedPath ] , previousHashes ) ;
21
+ combinedHash += pathOr ( 0 , [ 'hash' ] , pathHash )
22
+ if ( previousHash !== pathHash ) {
23
+ previousHash [ updatedPath ] = pathHash
24
+ }
25
+ }
26
+ } ) ;
27
+
28
+ return {
29
+ hash : combinedHash ,
30
+ changedProps : { } ,
31
+ renderType
32
+ } ;
33
+ }
34
+
6
35
export const selectDashProps =
7
36
( componentPath : DashLayoutPath ) =>
8
37
( state : any ) : SelectDashProps => {
@@ -12,7 +41,12 @@ export const selectDashProps =
12
41
// Then it can be easily compared without having to compare the props.
13
42
const strPath = stringifyPath ( componentPath ) ;
14
43
15
- const hash = state . layoutHashes [ strPath ] ;
44
+ let hash ;
45
+ if ( checkChildrenLayoutHashes ( c ) ) {
46
+ hash = determineChangedProps ( state , strPath )
47
+ } else {
48
+ hash = state . layoutHashes [ strPath ] ;
49
+ }
16
50
let h = 0 ;
17
51
let changedProps : object = { } ;
18
52
let renderType = '' ;
0 commit comments