فهرست منبع

Fixed issue where renaming playlist name would break some things.

KrisVos130 8 سال پیش
والد
کامیت
c40e83a61e
2فایلهای تغییر یافته به همراه8 افزوده شده و 0 حذف شده
  1. 1 0
      app/client/scripts/events.js
  2. 7 0
      app/server/server.js

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

@@ -1938,6 +1938,7 @@ Template.communityStation.events({
                 } else {
                     var $toastContent = $('<span><strong>Playlist name changed.</strong></span>');
                     Materialize.toast($toastContent, 2000);
+                    Session.set("editingPlaylistName", newName)
                 }
             });
         }

+ 7 - 0
app/server/server.js

@@ -1352,7 +1352,14 @@ Meteor.updatedMethods({
             var pl = PrivatePlaylists.findOne({owner: Meteor.userId(), name: name});
             if (pl !== undefined) {
                 if (PrivatePlaylists.findOne({owner: Meteor.userId(), name: newName}) === undefined) {
+                    var currentName = pl.name;
                     PrivatePlaylists.update({owner: Meteor.userId(), name: name}, {$set: {name: newName}});
+                    var stations = CommunityStations.find({owner: Meteor.userId(), playlist: currentName}).fetch();
+                    stations.forEach(function(stationObj) {
+                        getCommunityStation(stationObj.name, function(station) {
+                            station.setPlaylist(newName);
+                        });
+                    });
                 } else {
                     throw new Meteor.Error(500, "A playlist with that name already exists.");
                 }