everydaytok commited on
Commit
10bad20
·
verified ·
1 Parent(s): 2f19bf4

Update stateManager.js

Browse files
Files changed (1) hide show
  1. stateManager.js +17 -3
stateManager.js CHANGED
@@ -186,9 +186,15 @@ export const StateManager = {
186
  },
187
 
188
  updateProject: async (projectId, data) => {
 
 
189
  if (activeProjects.has(projectId)) {
190
  const current = activeProjects.get(projectId);
191
- const newData = { ...current, ...data, lastActive: Date.now() };
 
 
 
 
192
  activeProjects.set(projectId, newData);
193
  }
194
 
@@ -198,7 +204,8 @@ export const StateManager = {
198
  status: data.status,
199
  stats: data.stats,
200
  description: data.description,
201
- failureCount: data.failureCount
 
202
  }
203
  };
204
 
@@ -210,7 +217,14 @@ export const StateManager = {
210
  const mergedInfo = { ...currentDb.info, ...payload.info };
211
  delete mergedInfo.commandQueue;
212
 
213
- const { error } = await supabase.from('projects').update({ info: mergedInfo }).eq('id', projectId);
 
 
 
 
 
 
 
214
  if (error) console.error("[DB ERROR] Update Project failed:", error.message);
215
  }
216
  },
 
186
  },
187
 
188
  updateProject: async (projectId, data) => {
189
+ const now = new Date().toISOString();
190
+
191
  if (activeProjects.has(projectId)) {
192
  const current = activeProjects.get(projectId);
193
+ const newData = {
194
+ ...current,
195
+ ...data,
196
+ lastActive: Date.now()
197
+ };
198
  activeProjects.set(projectId, newData);
199
  }
200
 
 
204
  status: data.status,
205
  stats: data.stats,
206
  description: data.description,
207
+ failureCount: data.failureCount,
208
+ last_edited: now // Update JSON timestamp
209
  }
210
  };
211
 
 
217
  const mergedInfo = { ...currentDb.info, ...payload.info };
218
  delete mergedInfo.commandQueue;
219
 
220
+ // Update JSON info AND Root timestamp
221
+ const { error } = await supabase.from('projects')
222
+ .update({
223
+ info: mergedInfo,
224
+ updated_at: now
225
+ })
226
+ .eq('id', projectId);
227
+
228
  if (error) console.error("[DB ERROR] Update Project failed:", error.message);
229
  }
230
  },