@umituz/react-native-ai-generation-content 1.83.11 → 1.83.12
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-ai-generation-content",
|
|
3
|
-
"version": "1.83.
|
|
3
|
+
"version": "1.83.12",
|
|
4
4
|
"description": "Provider-agnostic AI generation orchestration for React Native with result preview components",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -75,20 +75,19 @@ export function useGalleryCallbacks(props: UseGalleryCallbacksProps) {
|
|
|
75
75
|
const handleFavorite = useCallback(
|
|
76
76
|
(c: Creation) => {
|
|
77
77
|
void (async () => {
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
try {
|
|
79
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
80
|
+
console.log("[handleFavorite] Called", { id: c.id, currentFavorite: c.isFavorite, userId });
|
|
81
|
+
}
|
|
82
|
+
if (!userId) return;
|
|
83
|
+
const newFavoriteStatus = !c.isFavorite;
|
|
84
|
+
const success = await repository.updateFavorite(userId, c.id, newFavoriteStatus);
|
|
85
|
+
if (success) void refetch();
|
|
86
|
+
} catch (e) {
|
|
87
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
88
|
+
console.error("[handleFavorite] Error:", e);
|
|
89
|
+
}
|
|
80
90
|
}
|
|
81
|
-
if (!userId) return;
|
|
82
|
-
// Toggle the favorite status
|
|
83
|
-
const newFavoriteStatus = !c.isFavorite;
|
|
84
|
-
if (__DEV__) {
|
|
85
|
-
console.log("[handleFavorite] Toggling", { newFavoriteStatus });
|
|
86
|
-
}
|
|
87
|
-
const success = await repository.updateFavorite(userId, c.id, newFavoriteStatus);
|
|
88
|
-
if (__DEV__) {
|
|
89
|
-
console.log("[handleFavorite] Update result", { success });
|
|
90
|
-
}
|
|
91
|
-
if (success) void refetch();
|
|
92
91
|
})();
|
|
93
92
|
},
|
|
94
93
|
[userId, repository, refetch],
|
|
@@ -118,11 +117,17 @@ export function useGalleryCallbacks(props: UseGalleryCallbacksProps) {
|
|
|
118
117
|
(rating: number, description: string) => {
|
|
119
118
|
if (!userId || !selectedCreation) return;
|
|
120
119
|
void (async () => {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
120
|
+
try {
|
|
121
|
+
const success = await repository.rate(userId, selectedCreation.id, rating, description);
|
|
122
|
+
if (success) {
|
|
123
|
+
setSelectedCreation({ ...selectedCreation, rating, ratedAt: new Date() });
|
|
124
|
+
alert.show(AlertType.SUCCESS, AlertMode.TOAST, t("result.rateSuccessTitle"), t("result.rateSuccessMessage"));
|
|
125
|
+
void refetch();
|
|
126
|
+
}
|
|
127
|
+
} catch (e) {
|
|
128
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
129
|
+
console.error("[handleSubmitRating] Error:", e);
|
|
130
|
+
}
|
|
126
131
|
}
|
|
127
132
|
})();
|
|
128
133
|
},
|
|
@@ -178,23 +178,32 @@ export function useProcessingJobsPoller(
|
|
|
178
178
|
useEffect(() => {
|
|
179
179
|
if (!enabled || !userId || orphanJobs.length === 0) return;
|
|
180
180
|
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
|
|
181
|
+
const cleanupOrphans = async () => {
|
|
182
|
+
const staleOrphans = orphanJobs.filter((creation) => {
|
|
183
|
+
const ageMs = Date.now() - creation.createdAt.getTime();
|
|
184
|
+
return ageMs >= DEFAULT_MAX_POLL_TIME_MS;
|
|
185
|
+
});
|
|
184
186
|
|
|
187
|
+
if (staleOrphans.length === 0) return;
|
|
188
|
+
|
|
189
|
+
await Promise.allSettled(
|
|
190
|
+
staleOrphans.map(async (creation) => {
|
|
191
|
+
if (!isMountedRef.current) return;
|
|
192
|
+
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
193
|
+
console.log("[ProcessingJobsPoller] Orphan job timed out, marking as failed:", creation.id);
|
|
194
|
+
}
|
|
195
|
+
await repository.update(userId, creation.id, {
|
|
196
|
+
status: CREATION_STATUS.FAILED,
|
|
197
|
+
metadata: { ...creation.metadata, error: "Generation timed out" },
|
|
198
|
+
completedAt: new Date(),
|
|
199
|
+
});
|
|
200
|
+
}),
|
|
201
|
+
);
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
void cleanupOrphans().catch((e) => {
|
|
185
205
|
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
186
|
-
console.
|
|
187
|
-
}
|
|
188
|
-
try {
|
|
189
|
-
await repository.update(userId, creation.id, {
|
|
190
|
-
status: CREATION_STATUS.FAILED,
|
|
191
|
-
metadata: { ...creation.metadata, error: "Generation timed out" },
|
|
192
|
-
completedAt: new Date(),
|
|
193
|
-
});
|
|
194
|
-
} catch (e) {
|
|
195
|
-
if (typeof __DEV__ !== "undefined" && __DEV__) {
|
|
196
|
-
console.error("[ProcessingJobsPoller] Failed to mark orphan job:", e);
|
|
197
|
-
}
|
|
206
|
+
console.error("[ProcessingJobsPoller] Failed to clean up orphan jobs:", e);
|
|
198
207
|
}
|
|
199
208
|
});
|
|
200
209
|
}, [enabled, userId, orphanJobs, repository]);
|