diff --git a/src/components/KeyValueEditor.vue b/src/components/KeyValueEditor.vue index f6be35726..b78c751a8 100644 --- a/src/components/KeyValueEditor.vue +++ b/src/components/KeyValueEditor.vue @@ -44,7 +44,7 @@ interface KeyValueObj { export default class KeyValueEditor extends Vue { @Prop({ required: false, default: '' }) private title!: string @Prop({ required: false, default: '100%' }) private maxHeight!: string - @Model('change', { type: Object }) private readonly value!: { [key: string]: string } + @Model('change', { type: Object }) private readonly value!: { [key: string]: string } | null private dataList: KeyValueObj[] = [] @@ -70,7 +70,7 @@ export default class KeyValueEditor extends Vue { this.handleInputChange() } else if (this.dataList.length === 1) { this.dataList = [{ key: '', value: '', checked: true }] - this.$emit('change', undefined) + this.$emit('change', null) } } private checkItem(index: number) { @@ -79,7 +79,7 @@ export default class KeyValueEditor extends Vue { } private processObjToArry() { - if (this.value === undefined) { + if (this.value === undefined || this.value === null) { this.dataList = [{ key: '', value: '', checked: true }] return } diff --git a/src/database/services/ConnectionService.ts b/src/database/services/ConnectionService.ts index 3ef0d17a6..ca361a3b7 100644 --- a/src/database/services/ConnectionService.ts +++ b/src/database/services/ConnectionService.ts @@ -79,10 +79,13 @@ export default class ConnectionService { topicAliasMaximum, requestResponseInformation, requestProblemInformation, - userProperties, authenticationMethod, authenticationData, } = data.properties + let userProperties = null + if (data.properties.userProperties) { + userProperties = JSON.stringify(data.properties.userProperties) + } return { ...data, sessionExpiryInterval, @@ -93,12 +96,12 @@ export default class ConnectionService { requestProblemInformation, authenticationMethod, authenticationData: authenticationData?.toString('utf8'), - userProperties: JSON.stringify(userProperties), + userProperties, } } return { ...data, - } as ConnectionEntity + } } // update connection's collection ID @@ -178,6 +181,7 @@ export default class ConnectionService { data.parentId = queryModel.parentId // END FIXME const res: ConnectionModel = query ? this.deepMerge(queryModel, data) : data + // Will Message table if (res.will) { const { id, @@ -206,10 +210,10 @@ export default class ConnectionService { res.will = await this.willRepository.save({ id, ...data, - } as WillEntity) + }) } else { // no will relation in database - res.will = await this.willRepository.save(data as WillEntity) + res.will = await this.willRepository.save(data) } } else { // no will relation in memory or database @@ -221,6 +225,7 @@ export default class ConnectionService { lastWillRetain: false, }) } + // Subscriptions table if (res.subscriptions && Array.isArray(res.subscriptions)) { const curSubs: SubscriptionEntity[] = await this.subscriptionRepository .createQueryBuilder('sub') diff --git a/src/types/global.d.ts b/src/types/global.d.ts index a8f1d0421..9b7d7afab 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -260,9 +260,9 @@ declare global { topicAliasMaximum?: number | null requestResponseInformation?: boolean | null requestProblemInformation?: boolean | null - userProperties?: Object - authenticationMethod?: string - authenticationData?: Buffer + userProperties?: Object | null + authenticationMethod?: string | null + authenticationData?: Buffer | null } interface PushOptions {