Procházet zdrojové kódy

fixed liked and disliked songs on profile page

Akira Laine před 9 roky
rodič
revize
02cf5924ac

+ 10 - 22
app/client/scripts/helpers.js

@@ -154,34 +154,22 @@ Template.profile.helpers({
     likedSongs: function () {
         var likedArr = [];
         Session.get("liked").forEach(function (mid) {
-            Rooms.find().forEach(function (room) {
-                Playlists.find({type: room.type}).forEach(function (pl) {
-                    for (var i in pl.songs) {
-                        if (pl.songs[i].mid === mid) {
-                            likedArr.push({title: pl.songs[i].title, artist: pl.songs[i].artist, room: room.display});
-                        }
-                    }
-                });
-            })
+            Songs.find().forEach(function (data) {
+                if (data.mid === mid) {
+                    likedArr.push({title: data.title, artist: data.artist});
+                }
+            });
         });
         return likedArr;
     },
     dislikedSongs: function () {
         var dislikedArr = [];
         Session.get("disliked").forEach(function (mid) {
-            Rooms.find().forEach(function (room) {
-                Playlists.find({type: room.type}).forEach(function (pl) {
-                    for (var i in pl.songs) {
-                        if (pl.songs[i].mid === mid) {
-                            dislikedArr.push({
-                                title: pl.songs[i].title,
-                                artist: pl.songs[i].artist,
-                                room: room.display
-                            });
-                        }
-                    }
-                });
-            })
+            Songs.find().forEach(function (data) {
+                if (data.mid === mid) {
+                    dislikedArr.push({title: data.title, artist: data.artist});
+                }
+            });
         });
         return dislikedArr;
     },

+ 1 - 1
app/client/templates/news.html

@@ -7,7 +7,7 @@
                     <div class="card-content">
                         <span>{{title}}</span>
                         <hr>
-                        <p class="flow-text" style="word-wrap:break-word;">
+                        <p id="news-content" style="word-wrap:break-word;">
                             {{content}}
                         </p>
                     </div>

+ 12 - 16
app/client/templates/profile.html

@@ -18,15 +18,14 @@
                 <div class="card teal accent-3 profile-card">
                     <div class="card-content white-text">
                         <span class="card-title">Liked Songs</span>
-                        {{#each likedSongs}}
-                            <div class="profile-card-song">
-                                <div class="section">
-                                    <h5>Title</h5>
-                                    <p>Artist</p>
-                                </div>
-                                <div class="divider"></div>
-                            </div>
-                        {{/each}}
+                        <ul>
+                           {{#each likedSongs}}
+                               <li>
+                                   <h5>{{title}}</h5>
+                                   <h6>{{artist}}</h6>
+                               </li>
+                           {{/each}}
+                       </ul>
                     </div>
                 </div>
             </div>
@@ -35,13 +34,10 @@
                     <div class="card-content white-text">
                         <span class="card-title">Disliked Songs</span>
                         {{#each dislikedSongs}}
-                            <div class="profile-card-song">
-                                <div class="section">
-                                    <h5>Title</h5>
-                                    <p>Artist</p>
-                                </div>
-                                <div class="divider"></div>
-                            </div>
+                            <li>
+                                <h4>{{title}}</h4>
+                                <h5>{{artist}}</h5>
+                            </li>
                         {{/each}}
                     </div>
                 </div>