@yogiswara/honcho-editor-ui 2.3.5 → 2.3.6
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/hooks/usePreset.js +9 -5
- package/package.json +1 -1
package/dist/hooks/usePreset.js
CHANGED
|
@@ -74,18 +74,22 @@ export function usePreset(controller, firebaseUid, options = {}) {
|
|
|
74
74
|
}
|
|
75
75
|
setIsLoading(true);
|
|
76
76
|
setError(null);
|
|
77
|
+
console.log('before GOINT to load 2.5. STATE UPDATE: setPresets is being called with:', presets);
|
|
77
78
|
try {
|
|
78
79
|
debugLog('Loading presets from backend...');
|
|
79
80
|
const loadedPresets = await controllerRef.current.getPresets(firebaseUidRef.current);
|
|
81
|
+
console.log('✅ 3. STATE UPDATE: setPresets is being called with:', loadedPresets);
|
|
80
82
|
setPresets(loadedPresets);
|
|
81
83
|
setIsInitialized(true);
|
|
82
84
|
debugLog('Presets loaded successfully', { count: loadedPresets.length });
|
|
83
85
|
}
|
|
84
86
|
catch (err) {
|
|
85
87
|
handleError('load presets', err);
|
|
88
|
+
console.log('4. catch ERROR!');
|
|
86
89
|
setPresets([]); // Clear presets on error
|
|
87
90
|
}
|
|
88
91
|
finally {
|
|
92
|
+
console.log('5. STATE UPDATE: setIsLoading is being called with:', false);
|
|
89
93
|
setIsLoading(false);
|
|
90
94
|
}
|
|
91
95
|
}, [debugLog, handleError]);
|
|
@@ -153,10 +157,10 @@ export function usePreset(controller, firebaseUid, options = {}) {
|
|
|
153
157
|
// Add the new preset to the local state immediately
|
|
154
158
|
setPresets(prev => [...prev, newPreset]);
|
|
155
159
|
// Fire and forget: Schedule a delayed refresh to get updated preset list
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
+
setTimeout(() => {
|
|
161
|
+
debugLog('Refreshing presets after create (fire and forget)');
|
|
162
|
+
loadInBackground();
|
|
163
|
+
}, 500); // 500ms delay to allow backend processing
|
|
160
164
|
// Return a minimal success indicator since we don't have the actual preset data
|
|
161
165
|
// return { id: 'pending', name, is_default: false } as Preset;
|
|
162
166
|
return newPreset;
|
|
@@ -169,7 +173,7 @@ export function usePreset(controller, firebaseUid, options = {}) {
|
|
|
169
173
|
setIsLoading(false);
|
|
170
174
|
}
|
|
171
175
|
// loadInBackground
|
|
172
|
-
}, [presets, debugLog, handleError]);
|
|
176
|
+
}, [presets, debugLog, handleError, loadInBackground]);
|
|
173
177
|
// Rename an existing preset
|
|
174
178
|
const rename = useCallback(async (presetId, newName) => {
|
|
175
179
|
if (!controllerRef.current || !firebaseUidRef.current) {
|