Spaces:
Sleeping
Sleeping
Nathan commited on
Commit ·
3cfcb2e
1
Parent(s): b671c20
Fix: Added strict error checking for multi-channel database saves
Browse files551 unmodified lines552553554555555556557558559559560561562563564563565566567568569551 unmodified lines if (existingChannel) { // Case A: Update existing connection console.log(`♻️ Updating existing channel: ${channel.id}`); await db.from('channels').update(channelData).eq('id', existingChannel.id); const { error } = await db.from('channels').update(channelData).eq('id', existingChannel.id); if (error) throw error; } else if (placeholder) { // Case B: Fill the first empty slot console.log(`📥 Filling placeholder slot: ${placeholder.id}`); await db.from('channels').update(channelData).eq('id', placeholder.id); const { error } = await db.from('channels').update(channelData).eq('id', placeholder.id); if (error) throw error; } else { // Case C: Create a brand new slot (for 2nd, 3rd channels etc) console.log(`➕ Creating new channel slot for: ${channel.id}`); await db.from('channels').insert([channelData]); const { error } = await db.from('channels').insert([channelData]); if (error) throw error; } } res.send('<h1>✅ YouTube Connected!</h1><p>Close this and refresh your dashboard.</p>');server.js+6-3