Browse Source

Fixed some issues with profile page.

KrisVos130 9 years ago
parent
commit
a971c221de
3 changed files with 69 additions and 49 deletions
  1. 18 12
      app/client/scripts/helpers.js
  2. 36 36
      app/client/templates/profile.html
  3. 15 1
      app/server/server.js

+ 18 - 12
app/client/scripts/helpers.js

@@ -193,24 +193,30 @@ Template.profile.helpers({
     },
     likedSongs: function () {
         var likedArr = [];
-        Session.get("liked").forEach(function (mid) {
-            Songs.find().forEach(function (data) {
-                if (data.mid === mid) {
-                    likedArr.push({title: data.title, artist: data.artist});
-                }
+        var liked = Session.get("liked");
+        if (liked !== undefined) {
+            liked.forEach(function (mid) {
+                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) {
-            Songs.find().forEach(function (data) {
-                if (data.mid === mid) {
-                    dislikedArr.push({title: data.title, artist: data.artist});
-                }
+        var disliked = Session.get("disliked");
+        if (disliked !== undefined) {
+            disliked.forEach(function (mid) {
+                Songs.find().forEach(function (data) {
+                    if (data.mid === mid) {
+                        dislikedArr.push({title: data.title, artist: data.artist});
+                    }
+                });
             });
-        });
+        }
         return dislikedArr;
     },
     isUser: function () {

+ 36 - 36
app/client/templates/profile.html

@@ -1,47 +1,47 @@
 <template name="profile">
     {{> header}}
     <div class="row">
-      <div class="col s12 m12 l10 push-l1 pull-l1">
-        <div class="card">
-            <div class="row" style="margin-top: 40px;">
-              <div class="col s12 m8 push-m2 pull-m2 l2 push-l5 pull-l5">
-                <img src="/notes.png" style="width: 100%;background-color: rgb(245, 245, 245);margin-top: 40px;" class="circle center-align" />
+        <div class="col s12 m12 l10 push-l1 pull-l1">
+            <div class="card">
+                <div class="row" style="margin-top: 40px;">
+                    <div class="col s12 m8 push-m2 pull-m2 l2 push-l5 pull-l5">
+                        <img src="/notes.png" style="width: 100%;background-color: rgb(245, 245, 245);margin-top: 40px;" class="circle center-align"/>
+                    </div>
+                </div>
                 <h1 id="profile-name" class="center-align black-text thin">{{username}}</h1>
-              </div>
-            </div>
                 <div class="container row center" style="list-style-type: none;">
-                  <div class="col s12 m12 l4">
-                    <h4>User Info</h4>
-                    <!--<p>Name: {{real_name}}</p>-->
-                    <p>Username: {{username}}</p>
-                    <p>First Joined: {{first_joined}}</p>
-                    <p>Rank: {{rank}}</p>
-                    <p>Requested Songs: {{songs_requested}}</p>
-                  </div>
-                  <div class="col s12 m12 l4">
-                    <h4>Liked songs</h4>
-                    <div style="height: 300px;overflow-y: scroll;">
-                    {{#each likedSongs}}
-                        <li>
-                            <h5>{{title}}</h5>
-                            <h6>{{artist}}</h6>
-                        </li>
-                    {{/each}}
+                    <div class="col s12 m12 l4">
+                        <h4>User Info</h4>
+                        <!--<p>Name: {{real_name}}</p>-->
+                        <p>Username: {{username}}</p>
+                        <p>First Joined: {{first_joined}}</p>
+                        <p>Rank: {{rank}}</p>
+                        <p>Requested Songs: {{songs_requested}}</p>
+                    </div>
+                    <div class="col s12 m12 l4">
+                        <h4>Liked songs</h4>
+                        <div style="height: 300px;overflow-y: scroll;">
+                            {{#each likedSongs}}
+                                <li>
+                                    <h5>{{title}}</h5>
+                                    <h6>{{artist}}</h6>
+                                </li>
+                            {{/each}}
+                        </div>
                     </div>
-                  </div>
-                  <div class="col s12 m12 l4">
-                    <h4>Disliked songs</h4>
-                    <div style="height: 300px;overflow-y: scroll;">
-                    {{#each dislikedSongs}}
-                        <li>
-                            <h5>{{title}}</h5>
-                            <h6>{{artist}}</h6>
-                        </li>
-                    {{/each}}
+                    <div class="col s12 m12 l4">
+                        <h4>Disliked songs</h4>
+                        <div style="height: 300px;overflow-y: scroll;">
+                            {{#each dislikedSongs}}
+                                <li>
+                                    <h5>{{title}}</h5>
+                                    <h6>{{artist}}</h6>
+                                </li>
+                            {{/each}}
+                        </div>
                     </div>
-                  </div>
                 </div>
             </div>
-          </div>
         </div>
+    </div>
 </template>

+ 15 - 1
app/server/server.js

@@ -748,7 +748,7 @@ Meteor.publish("userData", function (userId) {
 });
 
 Meteor.publish("usernames", function () {
-    return Meteor.users.find({}, {fields: {"profile.username": 1}})
+    return Meteor.users.find({}, {fields: {"profile.username": 1, "profile.usernameL": 1}})
 });
 
 Meteor.publish("playlists", function () {
@@ -817,6 +817,20 @@ Meteor.publish("chat", function () {
 });
 
 Meteor.publish("userProfiles", function (username) {
+    username = username.toLowerCase();
+    console.log(username);
+    console.log(Meteor.users.find({"profile.usernameL": username}, {
+        fields: {
+        "profile.username": 1,
+        "profile.usernameL": 1,
+        "profile.rank": 1,
+        createdAt: 1,
+        "profile.liked": 1,
+        "profile.disliked": 1,
+        "profile.settings": 1,
+        "profile.realname": 1
+        }
+    }).fetch());
     var settings = Meteor.users.findOne({"profile.usernameL": username}, {fields: {"profile.settings": 1}});
     if (settings !== undefined && settings.profile.settings) {
         settings = settings.profile.settings;