diff --git a/backend/app/controllers/channel.controller.js b/backend/app/controllers/channel.controller.js index a2e3748..e9a90f4 100644 --- a/backend/app/controllers/channel.controller.js +++ b/backend/app/controllers/channel.controller.js @@ -125,13 +125,25 @@ export async function toggleSubscription(req, res) { // Unsubscribe const deleteQuery = `DELETE FROM subscriptions WHERE channel = $1 AND owner = $2`; await client.query(deleteQuery, [id, userId]); + + // Send back the number of remaining subscriptions + const countQuery = `SELECT COUNT(*) FROM subscriptions WHERE channel = $1`; + const countResult = await client.query(countQuery, [id]); + const remainingSubscriptions = countResult.rows[0].count; + logger.write("Successfully unsubscribed from channel", 200); - res.status(200).json({message: 'Unsubscribed successfully'}); + res.status(200).json({message: 'Unsubscribed successfully', subscriptions: remainingSubscriptions}); } else { // Subscribe const insertQuery = `INSERT INTO subscriptions (channel, owner) VALUES ($1, $2)`; await client.query(insertQuery, [id, userId]); + + // Send back the number of subscriptions after subscribing + const countQuery = `SELECT COUNT(*) FROM subscriptions WHERE channel = $1`; + const countResult = await client.query(countQuery, [id]); + const totalSubscriptions = countResult.rows[0].count; + logger.write("Successfully subscribed to channel", 200); - res.status(200).json({message: 'Subscribed successfully'}); + res.status(200).json({message: 'Subscribed successfully', subscriptions: totalSubscriptions}); } } \ No newline at end of file diff --git a/backend/app/controllers/video.controller.js b/backend/app/controllers/video.controller.js index 5a141fd..1e674cb 100644 --- a/backend/app/controllers/video.controller.js +++ b/backend/app/controllers/video.controller.js @@ -230,13 +230,25 @@ export async function toggleLike(req, res) { if (likeResult.rows.length === 0) { const query = `INSERT INTO likes (video, owner) VALUES ($1, $2)`; await client.query(query, [id, userId]); + + // GET LIKES COUNT + const likesCountQuery = `SELECT COUNT(*) AS like_count FROM likes WHERE video = $1`; + const likesCountResult = await client.query(likesCountQuery, [id]); + const likesCount = likesCountResult.rows[0].like_count; + logger.write("no likes found adding likes for video " + id, 200); - res.status(200).json({"message": "Successfully added like"}); + res.status(200).json({"message": "Successfully added like", "likes": likesCount}); } else { const query = `DELETE FROM likes WHERE owner = $1 AND video = $2`; await client.query(query, [userId, id]); + + // GET LIKES COUNT + const likesCountQuery = `SELECT COUNT(*) AS like_count FROM likes WHERE video = $1`; + const likesCountResult = await client.query(likesCountQuery, [id]); + const likesCount = likesCountResult.rows[0].like_count; + logger.write("likes found, removing like for video " + id, 200); - res.status(200).json({"message": "Successfully removed like"}); + res.status(200).json({"message": "Successfully removed like", "likes": likesCount}); } diff --git a/backend/logs/access.log b/backend/logs/access.log index 7ac66e8..0863867 100644 --- a/backend/logs/access.log +++ b/backend/logs/access.log @@ -831,245 +831,4 @@ [2025-07-19 23:05:34.319] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 [2025-07-19 23:05:34.328] [undefined] GET(/:id/views): try to add views for video 3 [2025-07-19 23:05:34.333] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:17:13.385] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:17:13.394] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:17:13.404] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:17:13.412] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:17:13.428] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:17:13.435] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:17:15.012] [undefined] GET(/:id): try to get video 2 -[2025-07-20 08:17:15.020] [undefined] GET(/:id): successfully get video 2 with status 200 -[2025-07-20 08:17:15.030] [undefined] GET(/:id/similar): try to get similar videos for video 2 -[2025-07-20 08:17:15.037] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 2 with status 200 -[2025-07-20 08:17:15.048] [undefined] GET(/:id/views): try to add views for video 2 -[2025-07-20 08:17:15.053] [undefined] GET(/:id/views): successfully added views for video 2 with status 200 -[2025-07-20 08:17:15.577] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:17:15.585] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:17:15.593] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:17:15.600] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:17:15.610] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:17:15.615] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:17:22.613] [undefined] DELETE(/:id): try to delete comment 1 -[2025-07-20 08:17:22.619] [undefined] DELETE(/:id): successfully deleted comment with status 200 -[2025-07-20 08:17:24.642] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:17:24.650] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:17:24.661] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:17:24.671] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:17:24.683] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:17:24.699] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:19:39.097] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:19:39.106] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:19:39.118] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:19:39.129] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:19:39.143] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:19:39.151] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:19:43.001] [undefined] POST(/): try to post comment -[2025-07-20 08:19:43.008] [undefined] POST(/): successfully post comment with status 200 -[2025-07-20 08:19:44.352] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:19:44.360] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:19:44.369] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:19:44.381] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:19:44.412] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:19:44.419] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:19:45.960] [undefined] DELETE(/:id): try to delete comment 5 -[2025-07-20 08:19:45.967] [undefined] DELETE(/:id): successfully deleted comment with status 200 -[2025-07-20 08:20:16.598] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:20:16.606] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:20:16.615] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:20:16.626] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:20:16.649] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:20:16.657] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:20:20.460] [undefined] POST(/): try to post comment -[2025-07-20 08:20:20.467] [undefined] POST(/): successfully post comment with status 200 -[2025-07-20 08:20:21.812] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:20:21.819] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:20:21.830] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:20:21.840] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:20:21.858] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:20:21.865] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:20:23.080] [undefined] DELETE(/:id): try to delete comment 6 -[2025-07-20 08:20:23.085] [undefined] DELETE(/:id): successfully deleted comment with status 200 -[2025-07-20 08:20:23.093] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:20:23.101] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:20:23.110] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:20:23.117] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:20:23.126] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:20:23.132] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:20:59.078] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:20:59.087] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:20:59.095] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:20:59.105] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:20:59.121] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:20:59.129] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:21:02.851] [undefined] POST(/): try to post comment -[2025-07-20 08:21:02.860] [undefined] POST(/): successfully post comment with status 200 -[2025-07-20 08:21:04.022] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:21:04.030] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:21:04.043] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:21:04.052] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:21:04.066] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:21:04.076] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:22:32.802] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:22:32.810] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:22:32.819] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:22:32.830] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:22:32.850] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:22:32.857] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:22:36.610] [undefined] POST(/): try to post comment -[2025-07-20 08:22:36.617] [undefined] POST(/): successfully post comment with status 200 -[2025-07-20 08:23:17.340] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:23:17.350] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:23:17.360] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:23:17.371] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:23:17.390] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:23:17.397] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:23:19.938] [undefined] POST(/): try to post comment -[2025-07-20 08:23:19.944] [undefined] POST(/): successfully post comment with status 200 -[2025-07-20 08:23:31.546] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:24:03.520] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:24:03.531] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:24:03.542] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:24:03.555] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:24:03.571] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:24:03.578] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:24:06.139] [undefined] DELETE(/:id): try to delete comment 7 -[2025-07-20 08:24:06.144] [undefined] DELETE(/:id): successfully deleted comment with status 200 -[2025-07-20 08:24:06.152] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:24:06.160] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:24:06.168] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:24:06.175] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:24:06.184] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:24:06.190] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:24:06.902] [undefined] DELETE(/:id): try to delete comment 8 -[2025-07-20 08:24:06.907] [undefined] DELETE(/:id): successfully deleted comment with status 200 -[2025-07-20 08:24:06.915] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:24:06.923] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:24:06.931] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:24:06.938] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:24:06.946] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:24:06.952] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:24:07.728] [undefined] DELETE(/:id): try to delete comment 9 -[2025-07-20 08:24:07.733] [undefined] DELETE(/:id): successfully deleted comment with status 200 -[2025-07-20 08:24:07.741] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:24:07.748] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:24:07.756] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:24:07.764] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:24:07.773] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:24:07.779] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:24:54.566] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:24:54.574] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:24:54.584] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:24:54.594] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:24:54.610] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:24:54.617] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:25:46.381] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:25:46.391] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:25:46.405] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:25:46.417] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:25:46.433] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:25:46.442] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:25:50.563] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:25:50.572] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:25:50.581] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:25:50.592] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:25:50.610] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:25:50.618] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:25:54.456] [undefined] POST(/): try to post comment -[2025-07-20 08:25:54.463] [undefined] POST(/): successfully post comment with status 200 -[2025-07-20 08:25:55.690] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:25:55.697] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:25:55.706] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:25:55.716] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:25:55.731] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:25:55.738] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:29:04.387] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:29:04.395] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:29:04.403] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:29:04.413] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:29:04.427] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:29:04.435] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:29:06.717] [undefined] POST(/): try to post comment -[2025-07-20 08:29:06.724] [undefined] POST(/): successfully post comment with status 200 -[2025-07-20 08:29:49.666] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:29:49.674] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:29:49.684] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:29:49.694] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:29:49.706] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:29:49.714] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:29:52.277] [undefined] POST(/): try to post comment -[2025-07-20 08:29:52.283] [undefined] POST(/): successfully post comment with status 200 -[2025-07-20 08:29:57.910] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:29:57.919] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:29:57.931] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:29:57.940] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:29:57.965] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:29:57.971] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:30:02.939] [undefined] POST(/): try to post comment -[2025-07-20 08:30:02.945] [undefined] POST(/): successfully post comment with status 200 -[2025-07-20 08:30:38.602] [undefined] DELETE(/:id): try to delete comment 10 -[2025-07-20 08:30:38.608] [undefined] DELETE(/:id): successfully deleted comment with status 200 -[2025-07-20 08:30:38.616] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:30:38.623] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:30:38.631] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:30:38.639] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:30:38.648] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:30:38.653] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:30:39.035] [undefined] DELETE(/:id): try to delete comment 11 -[2025-07-20 08:30:39.040] [undefined] DELETE(/:id): successfully deleted comment with status 200 -[2025-07-20 08:30:39.048] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:30:39.055] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:30:39.063] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:30:39.071] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:31:14.966] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:31:14.978] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:31:14.991] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:31:15.002] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:31:15.021] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:31:15.029] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:31:16.736] [undefined] DELETE(/:id): try to delete comment 12 -[2025-07-20 08:31:16.742] [undefined] DELETE(/:id): successfully deleted comment with status 200 -[2025-07-20 08:31:16.750] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:31:16.758] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:31:16.766] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:31:16.774] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:31:16.783] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:31:16.789] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:31:17.876] [undefined] DELETE(/:id): try to delete comment 13 -[2025-07-20 08:31:17.882] [undefined] DELETE(/:id): successfully deleted comment with status 200 -[2025-07-20 08:31:17.890] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:31:17.897] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:31:17.906] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:31:17.914] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:31:17.924] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:31:17.930] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:33:16.918] [undefined] POST(/): try to post comment -[2025-07-20 08:33:16.925] [undefined] POST(/): successfully post comment with status 200 -[2025-07-20 08:33:18.845] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:33:18.854] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:33:18.864] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:33:18.873] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:33:18.912] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:33:18.921] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:35:42.164] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:35:42.175] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:35:42.190] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:35:42.201] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:35:42.228] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:35:42.236] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:35:45.179] [undefined] POST(/): try to post comment -[2025-07-20 08:35:45.185] [undefined] POST(/): successfully post comment with status 200 -[2025-07-20 08:35:46.285] [undefined] GET(/video/:id): Invalid token with status 401 -[2025-07-20 08:36:01.025] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:36:01.034] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:36:01.044] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:36:01.053] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:36:01.089] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:36:01.098] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:37:01.957] [undefined] GET(/:id): try to get video 3 -[2025-07-20 08:37:01.965] [undefined] GET(/:id): successfully get video 3 with status 200 -[2025-07-20 08:37:01.975] [undefined] GET(/:id/similar): try to get similar videos for video 3 -[2025-07-20 08:37:01.986] [undefined] GET(/:id/similar): successfully retrieved similar videos for video 3 with status 200 -[2025-07-20 08:37:02.019] [undefined] GET(/:id/views): try to add views for video 3 -[2025-07-20 08:37:02.029] [undefined] GET(/:id/views): successfully added views for video 3 with status 200 -[2025-07-20 08:37:03.963] [undefined] POST(/): try to post comment -[2025-07-20 08:37:03.970] [undefined] POST(/): successfully post comment with status 200 + diff --git a/frontend/src/pages/Video.jsx b/frontend/src/pages/Video.jsx index 2b64c8b..6f8e2d0 100644 --- a/frontend/src/pages/Video.jsx +++ b/frontend/src/pages/Video.jsx @@ -197,8 +197,16 @@ export default function Video() { const data = await response.json(); console.log('Subscription successful:', data); - // You could update the UI here to show subscription status - alert('Successfully subscribed!'); + const subscriptionCount = data.subscriptions || 0; + setVideo((prevVideo) => { + return { + ...prevVideo, + creator: { + ...prevVideo.creator, + subscribers: subscriptionCount + } + }; + }) } catch (error) { console.error('Error subscribing:', error); @@ -233,6 +241,16 @@ export default function Video() { throw new Error('Failed to like video'); } + const data = await response.json(); + console.log('Video liked successfully:', data); + + setVideo((prevVideo) => { + return { + ...prevVideo, + likes: data.likes || prevVideo.likes + 1 // Update likes count + }; + }) + } catch (error) { console.error('Error liking video:', error); }