Skip to content

Commit 5cc9850

Browse files
authored
Merge pull request #2796 from UltimateHackingKeyboard/fix-lastSave
fix: binary serialisation of lastSaveAgentTag and lastSaveFirmwareTag fields of the user configuration
2 parents 865b2af + 7190ca1 commit 5cc9850

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

packages/uhk-common/src/config-serializer/config-items/user-configuration.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,6 @@ export class UserConfiguration implements MouseSpeedConfiguration {
180180
this.userConfigMinorVersion = jsonObject.userConfigMinorVersion;
181181
this.userConfigPatchVersion = jsonObject.userConfigPatchVersion;
182182

183-
if (this.userConfigMajorVersion >= 13) {
184-
this.lastSaveAgentTag = jsonObject.lastSaveAgentTag ;
185-
this.lastSaveFirmwareTag = jsonObject.lastSaveFirmwareTag;
186-
}
187-
188183
switch (this.userConfigMajorVersion) {
189184
case 1:
190185
case 2:
@@ -244,11 +239,6 @@ export class UserConfiguration implements MouseSpeedConfiguration {
244239
this.userConfigMinorVersion = buffer.readUInt16();
245240
this.userConfigPatchVersion = buffer.readUInt16();
246241

247-
if (this.userConfigMajorVersion >= 13) {
248-
this.lastSaveAgentTag = buffer.readString();
249-
this.lastSaveFirmwareTag = buffer.readString();
250-
}
251-
252242
switch (this.userConfigMajorVersion) {
253243
case 1:
254244
case 2:
@@ -415,8 +405,6 @@ export class UserConfiguration implements MouseSpeedConfiguration {
415405
buffer.writeUInt16(this.userConfigMajorVersion);
416406
buffer.writeUInt16(this.userConfigMinorVersion);
417407
buffer.writeUInt16(this.userConfigPatchVersion);
418-
buffer.writeString(this.lastSaveAgentTag);
419-
buffer.writeString(this.lastSaveFirmwareTag);
420408
buffer.writeUInt32(this.userConfigurationLength);
421409
buffer.writeString(this.deviceName);
422410
buffer.writeUInt16(this.doubleTapSwitchLayerTimeout);
@@ -476,6 +464,8 @@ export class UserConfiguration implements MouseSpeedConfiguration {
476464
buffer.writeArray(this.keymaps, (uhkBuffer: UhkBuffer, keymap: Keymap) => {
477465
keymap.toBinary(uhkBuffer, this.getSerialisationInfo(), this);
478466
});
467+
buffer.writeString(this.lastSaveAgentTag);
468+
buffer.writeString(this.lastSaveFirmwareTag);
479469
}
480470

481471
toString(): string {
@@ -819,6 +809,12 @@ export class UserConfiguration implements MouseSpeedConfiguration {
819809
return macro;
820810
});
821811
this.keymaps = buffer.readArray<Keymap>(uhkBuffer => new Keymap().fromBinary(uhkBuffer, this.macros, serialisationInfo));
812+
813+
if (this.userConfigMajorVersion >= 13) {
814+
this.lastSaveAgentTag = buffer.readString();
815+
this.lastSaveFirmwareTag = buffer.readString();
816+
}
817+
822818
ConfigSerializer.resolveSwitchKeymapActions(this.keymaps);
823819

824820
}
@@ -1096,6 +1092,11 @@ export class UserConfiguration implements MouseSpeedConfiguration {
10961092
this.keymaps = jsonObject.keymaps.map((keymap: any) => {
10971093
return new Keymap().fromJsonObject(keymap, this.macros, serialisationInfo);
10981094
});
1095+
1096+
if (this.userConfigMajorVersion >= 13) {
1097+
this.lastSaveAgentTag = jsonObject.lastSaveAgentTag ;
1098+
this.lastSaveFirmwareTag = jsonObject.lastSaveFirmwareTag;
1099+
}
10991100
}
11001101

11011102
private migrateToV5(): boolean {

0 commit comments

Comments
 (0)