Skip to content

Commit

Permalink
There were more than one values for the same property in the saved data.
Browse files Browse the repository at this point in the history
  • Loading branch information
atsushieno committed Mar 5, 2024
1 parent 05697ca commit 081ee9a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ fun PropertyValueEditor(isLocalEditor: Boolean,
}

if (isTextRenderable) {
// FIXME: we have state loss problem here, value vanishes after "Commit changes"
val bodyText = MidiCIConverter.decodeASCIIToString(body.toByteArray().decodeToString())
if (isEditable) {
Row(verticalAlignment = Alignment.CenterVertically) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ class ServiceObservablePropertyList(values: MutableList<PropertyValue>, private

init {
initializeCatalogUpdatedEvent()
internalValues.addAll(propertyService.getMetadataList() ?.map {
internalValues.addAll(propertyService.getMetadataList()
?.filter { p -> !internalValues.any { v -> v.id == p.propertyId } }
?.map {
PropertyValue(it.propertyId, it.mediaTypes?.firstOrNull() ?: "", listOf())
} ?: listOf())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CommonRulesPropertyService(private val device: MidiCIDevice)
get() = device.config.jsonSchemaString
@JvmName("set_jsonSchemaString")
set(value) { device.config.jsonSchemaString = value }
private val values
private val values: List<PropertyValue>
@JvmName("get_propertyValues")
get() = device.config.propertyValues
private val metadataList
Expand Down Expand Up @@ -289,7 +289,7 @@ class CommonRulesPropertyService(private val device: MidiCIDevice)
else if (existing != null)
existing.body = decodedBody
else
values.add(PropertyValue(header.resource, header.mediaType ?: CommonRulesKnownMimeTypes.APPLICATION_JSON, decodedBody))
device.config.propertyValues.add(PropertyValue(header.resource, header.mediaType ?: CommonRulesKnownMimeTypes.APPLICATION_JSON, decodedBody))
return Result.success(getReplyHeaderJson(PropertyCommonReplyHeader(PropertyExchangeStatus.OK)))
}

Expand Down

0 comments on commit 081ee9a

Please sign in to comment.