Skip to content

Commit

Permalink
fix(connection): fix can not update user properties to null
Browse files Browse the repository at this point in the history
  • Loading branch information
ysfscream committed Dec 8, 2021
1 parent 52a65c8 commit 4fdc73e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/components/KeyValueEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = []
Expand All @@ -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) {
Expand All @@ -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
}
Expand Down
15 changes: 10 additions & 5 deletions src/database/services/ConnectionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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')
Expand Down
6 changes: 3 additions & 3 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4fdc73e

Please sign in to comment.