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 lines552553554555556557558559560561562563564565566551 unmodified linesif (existingChannel) {// Case A: Update existing connectionconsole.log(`♻️ Updating existing channel: ${channel.id}`);await db.from('channels').update(channelData).eq('id', existingChannel.id);} else if (placeholder) {// Case B: Fill the first empty slotconsole.log(`📥 Filling placeholder slot: ${placeholder.id}`);await db.from('channels').update(channelData).eq('id', placeholder.id);} 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]);}}res.send('<h1>✅ YouTube Connected!</h1><p>Close this and refresh your dashboard.</p>');551 unmodified lines552553554555556557558559560561562563564565566567568569551 unmodified linesif (existingChannel) {// Case A: Update existing connectionconsole.log(`♻️ Updating existing channel: ${channel.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 slotconsole.log(`📥 Filling placeholder slot: ${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}`);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