Skip to content

Commit ccaaf15

Browse files
committed
refactor(state): drop support for state files v3.0.0 and earlier
1 parent f5ee37e commit ccaaf15

1 file changed

Lines changed: 1 addition & 109 deletions

File tree

src/io/state-file/migrations.ts

Lines changed: 1 addition & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,4 @@
11
import { pipe } from '@/src/utils/functional';
2-
import { makeDefaultSegmentGroupName } from '@/src/store/segmentGroups';
3-
4-
const LABELMAP_PALETTE_2_1_0 = {
5-
'1': {
6-
value: 1,
7-
name: 'Segment 1',
8-
color: [153, 153, 0, 255],
9-
},
10-
'2': {
11-
value: 2,
12-
name: 'Segment 2',
13-
color: [76, 76, 0, 255],
14-
},
15-
'3': {
16-
value: 3,
17-
name: 'Segment 3',
18-
color: [255, 255, 0, 255],
19-
},
20-
'4': {
21-
value: 4,
22-
name: 'Segment 4',
23-
color: [0, 76, 0, 255],
24-
},
25-
'5': {
26-
value: 5,
27-
name: 'Segment 5',
28-
color: [0, 153, 0, 255],
29-
},
30-
'6': {
31-
value: 6,
32-
name: 'Segment 6',
33-
color: [0, 255, 0, 255],
34-
},
35-
'7': {
36-
value: 7,
37-
name: 'Segment 7',
38-
color: [76, 0, 0, 255],
39-
},
40-
'8': {
41-
value: 8,
42-
name: 'Segment 8',
43-
color: [153, 0, 0, 255],
44-
},
45-
'9': {
46-
value: 9,
47-
name: 'Segment 9',
48-
color: [255, 0, 0, 255],
49-
},
50-
'10': {
51-
value: 10,
52-
name: 'Segment 10',
53-
color: [0, 76, 76, 255],
54-
},
55-
'11': {
56-
value: 11,
57-
name: 'Segment 11',
58-
color: [0, 153, 153, 255],
59-
},
60-
'12': {
61-
value: 12,
62-
name: 'Segment 12',
63-
color: [0, 255, 255, 255],
64-
},
65-
'13': {
66-
value: 13,
67-
name: 'Segment 13',
68-
color: [0, 0, 76, 255],
69-
},
70-
'14': {
71-
value: 14,
72-
name: 'Segment 14',
73-
color: [0, 0, 153, 255],
74-
},
75-
};
762

773
const migrateOrPass =
784
(versions: Array<string>, migrationFunc: (manifest: any) => any) =>
@@ -83,38 +9,6 @@ const migrateOrPass =
839
return inputManifest;
8410
};
8511

86-
const migrateBefore210 = (inputManifest: any) => {
87-
const manifest = JSON.parse(JSON.stringify(inputManifest));
88-
manifest.version = '2.1.0';
89-
return manifest;
90-
};
91-
92-
const migrate210To300 = (inputManifest: any) => {
93-
const manifest = JSON.parse(JSON.stringify(inputManifest));
94-
manifest.tools.paint.activeSegmentGroupID =
95-
inputManifest.tools.paint.activeLabelmapID;
96-
delete manifest.tools.paint.activeLabelmapID;
97-
98-
const order = Object.keys(LABELMAP_PALETTE_2_1_0).map((key) => Number(key));
99-
manifest.labelMaps = inputManifest.labelMaps.map(
100-
(labelMap: any, index: number) => ({
101-
id: labelMap.id,
102-
path: labelMap.path,
103-
metadata: {
104-
parentImage: labelMap.parent,
105-
name: makeDefaultSegmentGroupName('My Image', index),
106-
segments: {
107-
order,
108-
byValue: LABELMAP_PALETTE_2_1_0,
109-
},
110-
},
111-
})
112-
);
113-
114-
manifest.version = '3.0.0';
115-
return manifest;
116-
};
117-
11812
const migrate501To600 = (inputManifest: any) => {
11913
const manifest = JSON.parse(JSON.stringify(inputManifest));
12014

@@ -264,10 +158,8 @@ export const migrateManifest = (manifestString: string) => {
264158
const inputManifest = JSON.parse(manifestString);
265159
return pipe(
266160
inputManifest,
267-
migrateOrPass(['1.1.0', '1.0.0', '0.5.0'], migrateBefore210),
268-
migrateOrPass(['2.1.0'], migrate210To300),
269161
migrateOrPass(['5.0.1'], migrate501To600),
270162
migrateOrPass(['6.0.0'], migrate600To610),
271-
migrateOrPass(['6.1.0'], migrate610To620)
163+
migrateOrPass(['6.1.0', '6.1.1'], migrate610To620)
272164
);
273165
};

0 commit comments

Comments
 (0)