Przeglądaj źródła

fixed playlist bug

Akira Laine 9 lat temu
rodzic
commit
48a9c1b542
2 zmienionych plików z 11 dodań i 5 usunięć
  1. 2 1
      app/client/scripts/events.js
  2. 9 4
      app/server/server.js

+ 2 - 1
app/client/scripts/events.js

@@ -862,7 +862,8 @@ Template.manageStation.events({
         newSong.duration = Number($("#duration").val());
         newSong.skipDuration = $("#skip-duration").val();
         newSong.requestedBy = Session.get("song").requestedBy;
-        Meteor.call("updatePlaylistSong", Session.get("genre"), Session.get("song"), newSong, function(err, res) {
+        newSong.genres = Session.get("song").genres;
+        Meteor.call("updatePlaylistSong", newSong.mid, newSong, function(err, res) {
             console.log(err, res);
             if (err) {
                 var $toastContent = $('<span><strong>Song not saved.</strong> ' + err.reason + '</span>');

+ 9 - 4
app/server/server.js

@@ -983,7 +983,7 @@ Meteor.methods({
                 "id": newSong.id,
                 "img": newSong.img,
                 "duration" : newSong.duration,
-                "skipDuration" : newSong.skipDuration,
+                "skipDuration" : newSong.skipDuration
             }}, function(err) {
                 console.log(err);
                 if (err) {
@@ -998,9 +998,14 @@ Meteor.methods({
     },
     updatePlaylistSong: function (mid, newSong) {
         if (isModerator() && !isBanned()) {
-            newSong.mid = mid;
-            newSong.approvedBy = Meteor.userId();
-            Playlists.update({mid: mid}, newSong, function(err) {
+            Songs.update({mid: mid}, {$set: {
+                "title": newSong.title,
+                "artist": newSong.artist,
+                "id": newSong.id,
+                "img": newSong.img,
+                "duration": newSong.duration,
+                "skipDuration": newSong.skipDuration
+        }}, function(err) {
                 console.log(err);
                 if (err) {
                     throw err.sanitizedError;