Don't add hide_ui when not present

This commit is contained in:
Cadence Ember 2025-02-10 14:09:41 +13:00
parent 23d473a56b
commit 4ae8da84e0
2 changed files with 34 additions and 0 deletions

View file

@ -87,6 +87,12 @@ function diffKState(actual, target) {
diff[key] = temp
}
} else if (key === "chat.schildi.hide_ui/read_receipts") {
// Special handling: don't add this key if it's new. Do overwrite if already present.
if (key in actual) {
diff[key] = target[key]
}
} else if (key in actual) {
// diff
if (!isDeepStrictEqual(actual[key], target[key])) {

View file

@ -234,3 +234,31 @@ test("diffKState: kstate keys must contain a slash separator", t => {
, /does not contain a slash separator/)
t.pass()
})
test("diffKState: don't add hide_ui when not present", t => {
test("diffKState: detects new properties", t => {
t.deepEqual(
diffKState({
}, {
"chat.schildi.hide_ui/read_receipts/": {}
}),
{
}
)
})
})
test("diffKState: overwriten hide_ui when present", t => {
test("diffKState: detects new properties", t => {
t.deepEqual(
diffKState({
"chat.schildi.hide_ui/read_receipts/": {hidden: true}
}, {
"chat.schildi.hide_ui/read_receipts/": {}
}),
{
"chat.schildi.hide_ui/read_receipts/": {}
}
)
})
})