bulltrackers-module 1.0.685 → 1.0.687
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.
|
@@ -392,7 +392,10 @@ const manageUserWatchlist = async (db, userId, instruction, payload = {}) => {
|
|
|
392
392
|
const sanitizedUserId = sanitizeCid(userId);
|
|
393
393
|
|
|
394
394
|
// 1. Determine Watchlist ID and Reference
|
|
395
|
-
|
|
395
|
+
// Handle both 'id' (from frontend) and 'watchlistId' (legacy)
|
|
396
|
+
const watchlistId = payload.id ? sanitizeDocId(payload.id)
|
|
397
|
+
: payload.watchlistId ? sanitizeDocId(payload.watchlistId)
|
|
398
|
+
: `watchlist_${Date.now()}_${Math.random().toString(16).substr(2, 8)}`;
|
|
396
399
|
const userDocRef = db.collection('SignedInUsers').doc(sanitizedUserId).collection('watchlists').doc(watchlistId);
|
|
397
400
|
|
|
398
401
|
try {
|
|
@@ -414,6 +417,11 @@ const manageUserWatchlist = async (db, userId, instruction, payload = {}) => {
|
|
|
414
417
|
// 3. Calculate Deltas based on Instruction
|
|
415
418
|
if (instruction === 'create') {
|
|
416
419
|
addedItems = payload.items || [];
|
|
420
|
+
|
|
421
|
+
// DEBUG: Log what we're receiving
|
|
422
|
+
console.log('[manageUserWatchlist DEBUG] payload received:', JSON.stringify(payload));
|
|
423
|
+
console.log('[manageUserWatchlist DEBUG] payload.type:', payload.type);
|
|
424
|
+
|
|
417
425
|
// Create the User Document
|
|
418
426
|
const newDocData = {
|
|
419
427
|
...payload,
|
|
@@ -424,6 +432,11 @@ const manageUserWatchlist = async (db, userId, instruction, payload = {}) => {
|
|
|
424
432
|
copyCount: 0,
|
|
425
433
|
isAutoGenerated: false
|
|
426
434
|
};
|
|
435
|
+
|
|
436
|
+
// DEBUG: Log what we're about to save
|
|
437
|
+
console.log('[manageUserWatchlist DEBUG] newDocData to save:', JSON.stringify(newDocData));
|
|
438
|
+
console.log('[manageUserWatchlist DEBUG] newDocData.type:', newDocData.type);
|
|
439
|
+
|
|
427
440
|
batch.set(userDocRef, newDocData);
|
|
428
441
|
}
|
|
429
442
|
|
|
@@ -20,11 +20,15 @@ const router = express.Router();
|
|
|
20
20
|
const watchlistManageSchema = z.object({
|
|
21
21
|
instruction: z.enum(['create', 'update', 'delete', 'add_item', 'remove_item', 'update_item']),
|
|
22
22
|
payload: z.object({
|
|
23
|
-
|
|
23
|
+
id: z.string().optional(), // Frontend sends "id"
|
|
24
|
+
watchlistId: z.string().optional(), // Keep for backward compatibility
|
|
24
25
|
name: z.string().max(200).optional(),
|
|
25
26
|
description: z.string().max(1000).optional(),
|
|
27
|
+
type: z.enum(['static', 'dynamic']).optional(),
|
|
28
|
+
visibility: z.enum(['public', 'private']).optional(),
|
|
26
29
|
items: z.array(z.any()).optional(),
|
|
27
|
-
item: z.any().optional()
|
|
30
|
+
item: z.any().optional(),
|
|
31
|
+
dynamicConfig: z.any().optional()
|
|
28
32
|
})
|
|
29
33
|
});
|
|
30
34
|
|