@zodic/shared 0.0.179 → 0.0.181
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/app/durable/ConceptNameDO.ts +19 -4
- package/package.json +1 -1
|
@@ -99,19 +99,34 @@ export class ConceptNameDO {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
async addName(language: 'en-us' | 'pt-br', name: string): Promise<void> {
|
|
102
|
-
await this.getNames(); // Ensure latest
|
|
102
|
+
await this.getNames(); // Ensure latest name list is loaded
|
|
103
|
+
await this.loadCount(); // ✅ Load latest count before modifying
|
|
103
104
|
|
|
104
105
|
if (!this.names[language].includes(name)) {
|
|
105
106
|
this.names[language].push(name);
|
|
106
|
-
this.count
|
|
107
|
+
this.count += 1; // ✅ Increment count correctly
|
|
108
|
+
|
|
107
109
|
this.recordTimestamp();
|
|
108
110
|
|
|
109
|
-
// ✅ **
|
|
111
|
+
// ✅ **Store all updated values in a single put() call**
|
|
110
112
|
await this.state.storage.put({
|
|
111
113
|
names: this.names,
|
|
112
|
-
count: this.count,
|
|
114
|
+
count: this.count, // ✅ Store updated count properly
|
|
113
115
|
timestamps: this.timestamps,
|
|
114
116
|
});
|
|
117
|
+
|
|
118
|
+
console.log(
|
|
119
|
+
`✅ Added name "${name}" to ${language}, count is now ${this.count}`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
async loadCount(): Promise<void> {
|
|
125
|
+
const storedCount = await this.state.storage.get<number>('count');
|
|
126
|
+
if (typeof storedCount === 'number') {
|
|
127
|
+
this.count = storedCount; // ✅ Ensure we always load the latest count
|
|
128
|
+
} else {
|
|
129
|
+
this.count = 0; // ✅ Ensure count is initialized properly
|
|
115
130
|
}
|
|
116
131
|
}
|
|
117
132
|
|