@communecter/cocolight-api-client 1.0.74 → 1.0.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cocolight-api-client.browser.js +1 -1
- package/dist/cocolight-api-client.cjs +1 -1
- package/dist/cocolight-api-client.mjs.js +1 -1
- package/dist/cocolight-api-client.vite.mjs.js +1 -1
- package/dist/cocolight-api-client.vite.mjs.js.map +1 -1
- package/package.json +1 -1
- package/src/api/BaseEntity.ts +8 -4
package/package.json
CHANGED
package/src/api/BaseEntity.ts
CHANGED
|
@@ -548,12 +548,16 @@ export class BaseEntity<TServerData = any> {
|
|
|
548
548
|
const transformed = this._transformServerData(newData);
|
|
549
549
|
const incoming = (transformed ?? {});
|
|
550
550
|
if (this._serverData && isReactive(this._serverData)) {
|
|
551
|
-
// Delete
|
|
551
|
+
// Delete only properties that no longer exist in the incoming data to ensure fields removed on the server are also removed locally
|
|
552
552
|
for (const key of Object.keys(this._serverData)) {
|
|
553
|
-
|
|
553
|
+
if (!(key in incoming)) {
|
|
554
|
+
delete (this._serverData as any)[key];
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
// Update or add properties from the incoming data (preserves reactive signals)
|
|
558
|
+
for (const key of Object.keys(incoming)) {
|
|
559
|
+
(this._serverData as any)[key] = (incoming as any)[key];
|
|
554
560
|
}
|
|
555
|
-
// Assign new properties
|
|
556
|
-
Object.assign(this._serverData, incoming);
|
|
557
561
|
} else {
|
|
558
562
|
this._serverData = reactive({ ...incoming }) as TServerData & ReactiveData;
|
|
559
563
|
}
|