@@ -20,12 +20,8 @@ import { generateViewpoint as generateViewpointV4, getNodesIdsFromSharedIds, toS
20
20
import { formatMessage } from '@/v5/services/intl' ;
21
21
import { dispatch , getState } from '@/v4/modules/store' ;
22
22
import { isEmpty , isString } from 'lodash' ;
23
- import { TreeActions } from '@/v4/modules/tree' ;
24
23
import { selectCurrentTeamspace } from '../store/teamspaces/teamspaces.selectors' ;
25
- import { TicketsCardActionsDispatchers } from '../services/actionsDispatchers' ;
26
24
import { ViewpointsActions } from '@/v4/modules/viewpoints' ;
27
- import { GroupsActions } from '@/v4/modules/groups' ;
28
- import { SequencesActions } from '@/v4/modules/sequences' ;
29
25
30
26
export const convertToV5GroupNodes = ( objects ) => objects . map ( ( object ) => ( {
31
27
container : object . model as string ,
@@ -133,6 +129,8 @@ const convertToV4Group = (groupOverride: GroupOverride) => {
133
129
return group ;
134
130
} ;
135
131
132
+ const mergeGroups = ( groups : any [ ] ) => ( { objects : groups . flatMap ( ( group ) => group . objects ) } ) ;
133
+
136
134
export const viewpointV5ToV4 = ( viewpoint : Viewpoint ) => {
137
135
let v4Viewpoint :any = { } ;
138
136
if ( viewpoint . camera ) {
@@ -153,6 +151,15 @@ export const viewpointV5ToV4 = (viewpoint: Viewpoint) => {
153
151
v4Viewpoint . transformation_groups = viewpoint . state . transformed . map ( convertToV4Group ) ;
154
152
}
155
153
154
+
155
+ if ( ! isEmpty ( viewpoint . state ?. colored ) ) {
156
+ v4Viewpoint . override_groups = viewpoint . state . colored . map ( convertToV4Group ) ;
157
+ }
158
+
159
+ if ( ! isEmpty ( viewpoint . state ?. hidden ) ) {
160
+ v4Viewpoint . hidden_group = mergeGroups ( viewpoint . state . hidden . map ( convertToV4Group ) ) ;
161
+ }
162
+
156
163
return { viewpoint : v4Viewpoint } ;
157
164
} ;
158
165
@@ -207,19 +214,5 @@ export const goToView = async (view: Viewpoint) => {
207
214
return ;
208
215
}
209
216
210
- // This is not very clean but will be fixed with the overrides refactor
211
- dispatch ( GroupsActions . clearColorOverridesSuccess ( ) ) ;
212
- dispatch ( ViewpointsActions . clearColorOverrides ( ) ) ;
213
- dispatch ( SequencesActions . clearColorOverrides ( ) ) ;
214
-
215
- const overrides = toGroupPropertiesDicts ( view ?. state ?. colored || [ ] ) ;
216
- TicketsCardActionsDispatchers . setOverrides ( overrides ) ;
217
- const v4HiddenObjects = convertToV4GroupNodes ( view . state ?. hidden ?. flatMap ( ( hiddenOverride ) => ( hiddenOverride . group as Group ) ?. objects || [ ] ) ) ;
218
- if ( v4HiddenObjects . length ) {
219
- dispatch ( TreeActions . hideNodesBySharedIds ( v4HiddenObjects , true ) ) ;
220
- } else {
221
- dispatch ( TreeActions . showAllNodes ( ) ) ;
222
- }
223
-
224
217
dispatch ( ViewpointsActions . showViewpoint ( null , null , viewpointV5ToV4 ( view ) ) ) ;
225
218
} ;
0 commit comments