Skip to content

Commit e0ba58e

Browse files
authored
fix: improve name persistence. (#2996)
1 parent 27cfc2b commit e0ba58e

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
import { DEFAULT_DEVICE_NAME } from '../../util/constants.js';
23
import { assertEnum, assertFloat, assertInt16, assertUInt16, assertUInt32, assertUInt8 } from '../assert.js';
34
import { resolveSwitchKeymapActions } from '../resolve-switch-keymap-actions.js';
45
import { UhkBuffer } from '../uhk-buffer.js';
@@ -537,7 +538,7 @@ export class UserConfiguration implements AdvancedSecondaryRoleConfiguration, Mo
537538

538539
private setDefaultDeviceName(): void {
539540
if (!this.deviceName || this.deviceName.trim().length === 0) {
540-
this.deviceName = 'My UHK';
541+
this.deviceName = DEFAULT_DEVICE_NAME;
541542
}
542543
}
543544

packages/uhk-common/src/util/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ export const AGENT_CONTRIBUTORS_GITHUB_API_URL = 'https://api.github.com/repos/U
44
export const MAX_ALLOWED_MACROS = 255;
55
export const MAX_ALLOWED_MACROS_TOOLTIP = `No more than ${MAX_ALLOWED_MACROS} macros are supported.`;
66

7+
export const DEFAULT_DEVICE_NAME = 'My UHK';
8+
79
export const UHK_EEPROM_SIZE = 32768;
810
export const ERR_UPDATER_INVALID_SIGNATURE = 'ERR_UPDATER_INVALID_SIGNATURE'

packages/uhk-web/src/app/store/effects/user-config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { saveAs } from 'file-saver';
1010
import {
1111
BackupUserConfigurationInfo,
1212
Buffer,
13+
DEFAULT_DEVICE_NAME,
1314
getHardwareConfigFromDeviceResponse,
1415
getUserConfigFromDeviceResponse,
1516
ConfigurationReply,
@@ -337,7 +338,9 @@ export class UserConfigEffects {
337338

338339
// Keep the connected keyboard's name when importing a config, so a single config
339340
// can be shared across multiple keyboards while each retains its own name.
340-
userConfig.deviceName = deviceName;
341+
if (deviceName !== DEFAULT_DEVICE_NAME) {
342+
userConfig.deviceName = deviceName;
343+
}
341344

342345
if (payload.autoSave) {
343346
return new ApplyUserConfigurationFromFileAction({

0 commit comments

Comments
 (0)