@communecter/cocolight-api-client 1.0.71 → 1.0.72
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 +13 -0
package/package.json
CHANGED
package/src/api/BaseEntity.ts
CHANGED
|
@@ -547,6 +547,11 @@ export class BaseEntity<TServerData = any> {
|
|
|
547
547
|
const transformed = this._transformServerData(newData);
|
|
548
548
|
const incoming = (transformed ?? {});
|
|
549
549
|
if (this._serverData && isReactive(this._serverData)) {
|
|
550
|
+
// Delete all existing properties to ensure fields removed on the server are also removed locally
|
|
551
|
+
for (const key of Object.keys(this._serverData)) {
|
|
552
|
+
delete this._serverData[key];
|
|
553
|
+
}
|
|
554
|
+
// Assign new properties
|
|
550
555
|
Object.assign(this._serverData, incoming);
|
|
551
556
|
} else {
|
|
552
557
|
this._serverData = reactive({ ...incoming }) as TServerData & ReactiveData;
|
|
@@ -589,6 +594,14 @@ export class BaseEntity<TServerData = any> {
|
|
|
589
594
|
}
|
|
590
595
|
|
|
591
596
|
_updateDraftPreservingUserChanges(draft: Record<string, any>): void {
|
|
597
|
+
// First, remove keys from draftData that are no longer in the incoming draft
|
|
598
|
+
for (const key of Object.keys(this._draftData || {})) {
|
|
599
|
+
if (!(key in draft)) {
|
|
600
|
+
delete this._draftData[key];
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
// Then, update or add keys from the incoming draft (preserving user modifications)
|
|
592
605
|
for (const key of Object.keys(draft)) {
|
|
593
606
|
const current = this._draftData?.[key];
|
|
594
607
|
const initialValue = this._initialDraftData?.[key];
|