Commit 062ba87a4ce889d44904dbbe5023ec253bdc8988

Authored by Andrew Buss
1 parent ea02266eeb
Exists in master

show authorship on feed

Showing 3 changed files with 14 additions and 6 deletions Side-by-side Diff

scripts/CardGridController.js View file @ 062ba87
... ... @@ -72,7 +72,6 @@
72 72  
73 73 $scope.refreshLayout = function() {
74 74 numCols = Math.max(1, Math.floor(($window.innerWidth - 17) / 250));
75   -
76 75 // check if we actually need to refresh the whole layout
77 76 if (numCols == $scope.numCols) return $scope.refreshColumnWidth();
78 77 $scope.numCols = numCols;
scripts/DeckFactory.js View file @ 062ba87
... ... @@ -19,13 +19,14 @@
19 19 data = JSON.parse(message.data);
20 20 console.log('message', data);
21 21 if (data.event_type == 'card_pulled') {
22   - if(obj.cards[data.flashcard.id]) console.log("Pulled a card already in our deck?");
  22 + if (obj.cards[data.flashcard.id]) console.log("Pulled a card already in our deck?");
23 23 card = new Flashcard(data.flashcard);
  24 + if (data.flashcard.is_authored_by_user) card.is_authored_by_user = true;
24 25 obj.cards[card.id] = card;
25 26 if (callbacks.cardPullCallback) callbacks.cardPullCallback(card);
26 27 }
27 28 if (data.event_type == 'card_unpulled') {
28   - if(!obj.cards[data.flashcard.id]) return console.log("Unpulled a card not in our deck?");
  29 + if (!obj.cards[data.flashcard.id]) return console.log("Unpulled a card not in our deck?");
29 30 card = new Flashcard(data.flashcard);
30 31 obj.cards[card.id] = undefined;
31 32 if (callbacks.cardUnpullCallback) callbacks.cardUnpullCallback(card);
... ... @@ -37,7 +38,7 @@
37 38 if (callbacks.cardHideCallback) callbacks.cardHideCallback(card);
38 39 }
39 40 if (data.event_type == 'card_unhidden') {
40   - if(obj.cards[data.flashcard.id]) return;
  41 + if (obj.cards[data.flashcard.id]) return;
41 42 card = new Flashcard(data.flashcard);
42 43 card.is_hidden = false;
43 44 if (callbacks.cardUnhideCallback) callbacks.cardUnhideCallback(card);
... ... @@ -49,7 +50,11 @@
49 50 }
50 51 });
51 52 this.deckPromise = $http.get('/api/sections/' + sectionId + '/deck/').success(function (data) {
52   - for (i in data) obj.cards[data[i].id] = new Flashcard(data[i], obj);
  53 + for (i in data) {
  54 + obj.cards[data[i].id] = new Flashcard(data[i], obj);
  55 + //obj.cards[data[i].id].is_authored_by_user = data.is_authored_by_user;
  56 + }
  57 +
53 58 console.log("got user's deck", data);
54 59 });
55 60 this.cleanup = function () {
scripts/FeedController.js View file @ 062ba87
... ... @@ -118,7 +118,11 @@
118 118 data = JSON.parse(e.data);
119 119 console.log(data.event_type, 'message', data.flashcard);
120 120 if (data.event_type == 'new_card') {
121   - $scope.addCardToGrid(new Flashcard(data.flashcard, $scope.deck));
  121 + // don't trust the backend for feed's authored_by_user
  122 + card = data.flashcard;
  123 + delete card['is_authored_by_user'];
  124 + card = new Flashcard(card);
  125 + $scope.addCardToGrid(card, $scope.deck);
122 126 } else if (data.event_type == 'score_change') {
123 127 card = new Flashcard(data.flashcard); // doesnt create a card if it exists
124 128 //card.score = data.flashcard.score;