{"action":"created","comment":{"url":"https://api.github.com/repos/Calligre/attendee-web/pulls/comments/80848751","pull_request_review_id":1872548,"id":80848751,"diff_hunk":"@@ -3,105 +3,103 @@ var $ = require('jquery');\n var _ = require('lodash');\n \n import BroadcastMessage from \"../components/BroadcastMessage\";\n-import Events from \"../components/Events\";\n+import EventStore from \"../stores/EventStore\";\n+import NotificationStore from \"../stores/NotificationStore\";\n+import Card from \"../components/Card\";\n \n import { NotificationStack } from 'react-notification';\n-import { OrderedSet } from 'immutable';\n var moment = require('moment');\n \n export default class Featured extends React.Component {\n   constructor(props) {\n-    super();\n-    this.addNotification = this.addNotification.bind(this);\n-    this.removeNotification = this.removeNotification.bind(this);\n+    super(props);\n+    this.getEvents = this.getEvents.bind(this);\n+    this.getNotifications = this.getNotifications.bind(this);\n     this.state = {\n-      messages: [],\n-      messageStack: OrderedSet(),\n+      notifications: [],\n       events: [],\n       apiBaseURL: props.route.apiBaseURL,\n     };\n-  }\n+  };\n \n-  addNotification (message) {\n-    const currTime = moment().unix();\n-    if (currTime > message.expirytime) {\n-      return;\n-    }\n-    var self = this;\n-    return this.setState({\n-      messageStack: this.state.messageStack.add({\n-        message: message.message,\n-        key: message.id,\n-        dismissAfter: (message.expirytime - currTime) * 1000\n-      })\n-    });\n-  }\n+  componentDidMount() {\n+    NotificationStore.getAll();\n+    EventStore.getAll();\n+  };\n \n-  removeNotification (count) {\n-    this.setState({\n-      messageStack: this.state.messageStack.filter(n => n.key !== count)\n-    })\n-  }\n+  componentWillMount() {\n+    NotificationStore.on(\"received\", this.getNotifications);\n+    NotificationStore.on(\"error\", this.showNotificationStoreError);\n+    EventStore.on(\"received\", this.getEvents);\n+    EventStore.on(\"error\", this.showEventStoreError);\n+  };\n \n+  componentWillUnmount() {\n+    NotificationStore.removeListener(\"received\", this.getNotifications);\n+    NotificationStore.removeListener(\"error\", this.showNotificationStoreError);\n+    EventStore.removeListener(\"received\", this.getEvents);\n+    EventStore.removeListener(\"error\", this.showEventStoreError);\n+  };\n \n-  componentDidMount() {\n-    var self = this;\n-    this.broadcastRequest = $.get(this.state.apiBaseURL + \"/broadcast\", function (result) {\n-      this.setState({\n-        messages: result.data.map(function(message) {\n-          return message.attributes;\n-        })\n-      });\n+  removeNotification (id) {\n+    this.setState({\n+      notifications: this.state.notifications.filter(n => n.key !== id)\n+    })\n+  };\n \n-      this.messageStack = new OrderedSet();\n-      this.state.messages.forEach(function(m) {\n-        self.addNotification(m);\n+  getNotifications() {\n+    var unexpired = NotificationStore.getUnexpired();\n+    let temp = [];\n+    const currTime = moment().unix();\n+    unexpired.forEach(function(notification) {\n+      temp.push({\n+        message: notification.attributes.message,\n+        key: \"notification-\" + notification.attributes.id,\n+        action: 'Dismiss',\n+        dismissAfter: (notification.attributes.expirytime - currTime) * 1000,\n+        onClick: () => this.removeNotification(\"notification-\" + notification.attributes.id),","path":"src/js/pages/Home.js","position":96,"original_position":96,"commit_id":"87b23d99db3000778b25ddff4dcd9c366b0e8d2f","original_commit_id":"87b23d99db3000778b25ddff4dcd9c366b0e8d2f","user":{"login":"larajanecka","id":5514212,"avatar_url":"https://avatars.githubusercontent.com/u/5514212?v=3","gravatar_id":"","url":"https://api.github.com/users/larajanecka","html_url":"https://github.com/larajanecka","followers_url":"https://api.github.com/users/larajanecka/followers","following_url":"https://api.github.com/users/larajanecka/following{/other_user}","gists_url":"https://api.github.com/users/larajanecka/gists{/gist_id}","starred_url":"https://api.github.com/users/larajanecka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larajanecka/subscriptions","organizations_url":"https://api.github.com/users/larajanecka/orgs","repos_url":"https://api.github.com/users/larajanecka/repos","events_url":"https://api.github.com/users/larajanecka/events{/privacy}","received_events_url":"https://api.github.com/users/larajanecka/received_events","type":"User","site_admin":false},"body":"Do notifications not have id numbers that we should be filtering on? Its a bit weird to be intentionally building this string to check against.","created_at":"2016-09-28T06:15:28Z","updated_at":"2016-09-28T06:24:21Z","html_url":"https://github.com/Calligre/attendee-web/pull/34#discussion_r80848751","pull_request_url":"https://api.github.com/repos/Calligre/attendee-web/pulls/34","_links":{"self":{"href":"https://api.github.com/repos/Calligre/attendee-web/pulls/comments/80848751"},"html":{"href":"https://github.com/Calligre/attendee-web/pull/34#discussion_r80848751"},"pull_request":{"href":"https://api.github.com/repos/Calligre/attendee-web/pulls/34"}}},"pull_request":{"url":"https://api.github.com/repos/Calligre/attendee-web/pulls/34","id":87042207,"html_url":"https://github.com/Calligre/attendee-web/pull/34","diff_url":"https://github.com/Calligre/attendee-web/pull/34.diff","patch_url":"https://github.com/Calligre/attendee-web/pull/34.patch","issue_url":"https://api.github.com/repos/Calligre/attendee-web/issues/34","number":34,"state":"open","locked":false,"title":"Cards","user":{"login":"StevenLocke","id":5084124,"avatar_url":"https://avatars.githubusercontent.com/u/5084124?v=3","gravatar_id":"","url":"https://api.github.com/users/StevenLocke","html_url":"https://github.com/StevenLocke","followers_url":"https://api.github.com/users/StevenLocke/followers","following_url":"https://api.github.com/users/StevenLocke/following{/other_user}","gists_url":"https://api.github.com/users/StevenLocke/gists{/gist_id}","starred_url":"https://api.github.com/users/StevenLocke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StevenLocke/subscriptions","organizations_url":"https://api.github.com/users/StevenLocke/orgs","repos_url":"https://api.github.com/users/StevenLocke/repos","events_url":"https://api.github.com/users/StevenLocke/events{/privacy}","received_events_url":"https://api.github.com/users/StevenLocke/received_events","type":"User","site_admin":false},"body":"TODO: Should replace `var`s with `let`s.","created_at":"2016-09-28T01:50:03Z","updated_at":"2016-09-28T06:24:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5294491459f0a30ab5c267492182003bdd5705f3","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Calligre/attendee-web/pulls/34/commits","review_comments_url":"https://api.github.com/repos/Calligre/attendee-web/pulls/34/comments","review_comment_url":"https://api.github.com/repos/Calligre/attendee-web/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Calligre/attendee-web/issues/34/comments","statuses_url":"https://api.github.com/repos/Calligre/attendee-web/statuses/87b23d99db3000778b25ddff4dcd9c366b0e8d2f","head":{"label":"Calligre:Cards","ref":"Cards","sha":"87b23d99db3000778b25ddff4dcd9c366b0e8d2f","user":{"login":"Calligre","id":19350741,"avatar_url":"https://avatars.githubusercontent.com/u/19350741?v=3","gravatar_id":"","url":"https://api.github.com/users/Calligre","html_url":"https://github.com/Calligre","followers_url":"https://api.github.com/users/Calligre/followers","following_url":"https://api.github.com/users/Calligre/following{/other_user}","gists_url":"https://api.github.com/users/Calligre/gists{/gist_id}","starred_url":"https://api.github.com/users/Calligre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Calligre/subscriptions","organizations_url":"https://api.github.com/users/Calligre/orgs","repos_url":"https://api.github.com/users/Calligre/repos","events_url":"https://api.github.com/users/Calligre/events{/privacy}","received_events_url":"https://api.github.com/users/Calligre/received_events","type":"Organization","site_admin":false},"repo":{"id":61333042,"name":"attendee-web","full_name":"Calligre/attendee-web","owner":{"login":"Calligre","id":19350741,"avatar_url":"https://avatars.githubusercontent.com/u/19350741?v=3","gravatar_id":"","url":"https://api.github.com/users/Calligre","html_url":"https://github.com/Calligre","followers_url":"https://api.github.com/users/Calligre/followers","following_url":"https://api.github.com/users/Calligre/following{/other_user}","gists_url":"https://api.github.com/users/Calligre/gists{/gist_id}","starred_url":"https://api.github.com/users/Calligre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Calligre/subscriptions","organizations_url":"https://api.github.com/users/Calligre/orgs","repos_url":"https://api.github.com/users/Calligre/repos","events_url":"https://api.github.com/users/Calligre/events{/privacy}","received_events_url":"https://api.github.com/users/Calligre/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Calligre/attendee-web","description":"Attendee web app.","fork":false,"url":"https://api.github.com/repos/Calligre/attendee-web","forks_url":"https://api.github.com/repos/Calligre/attendee-web/forks","keys_url":"https://api.github.com/repos/Calligre/attendee-web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Calligre/attendee-web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Calligre/attendee-web/teams","hooks_url":"https://api.github.com/repos/Calligre/attendee-web/hooks","issue_events_url":"https://api.github.com/repos/Calligre/attendee-web/issues/events{/number}","events_url":"https://api.github.com/repos/Calligre/attendee-web/events","assignees_url":"https://api.github.com/repos/Calligre/attendee-web/assignees{/user}","branches_url":"https://api.github.com/repos/Calligre/attendee-web/branches{/branch}","tags_url":"https://api.github.com/repos/Calligre/attendee-web/tags","blobs_url":"https://api.github.com/repos/Calligre/attendee-web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Calligre/attendee-web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Calligre/attendee-web/git/refs{/sha}","trees_url":"https://api.github.com/repos/Calligre/attendee-web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Calligre/attendee-web/statuses/{sha}","languages_url":"https://api.github.com/repos/Calligre/attendee-web/languages","stargazers_url":"https://api.github.com/repos/Calligre/attendee-web/stargazers","contributors_url":"https://api.github.com/repos/Calligre/attendee-web/contributors","subscribers_url":"https://api.github.com/repos/Calligre/attendee-web/subscribers","subscription_url":"https://api.github.com/repos/Calligre/attendee-web/subscription","commits_url":"https://api.github.com/repos/Calligre/attendee-web/commits{/sha}","git_commits_url":"https://api.github.com/repos/Calligre/attendee-web/git/commits{/sha}","comments_url":"https://api.github.com/repos/Calligre/attendee-web/comments{/number}","issue_comment_url":"https://api.github.com/repos/Calligre/attendee-web/issues/comments{/number}","contents_url":"https://api.github.com/repos/Calligre/attendee-web/contents/{+path}","compare_url":"https://api.github.com/repos/Calligre/attendee-web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Calligre/attendee-web/merges","archive_url":"https://api.github.com/repos/Calligre/attendee-web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Calligre/attendee-web/downloads","issues_url":"https://api.github.com/repos/Calligre/attendee-web/issues{/number}","pulls_url":"https://api.github.com/repos/Calligre/attendee-web/pulls{/number}","milestones_url":"https://api.github.com/repos/Calligre/attendee-web/milestones{/number}","notifications_url":"https://api.github.com/repos/Calligre/attendee-web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Calligre/attendee-web/labels{/name}","releases_url":"https://api.github.com/repos/Calligre/attendee-web/releases{/id}","deployments_url":"https://api.github.com/repos/Calligre/attendee-web/deployments","created_at":"2016-06-16T23:51:40Z","updated_at":"2016-06-27T22:55:42Z","pushed_at":"2016-09-28T01:50:03Z","git_url":"git://github.com/Calligre/attendee-web.git","ssh_url":"git@github.com:Calligre/attendee-web.git","clone_url":"https://github.com/Calligre/attendee-web.git","svn_url":"https://github.com/Calligre/attendee-web","homepage":null,"size":1833,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":23,"forks":1,"open_issues":23,"watchers":0,"default_branch":"master"}},"base":{"label":"Calligre:master","ref":"master","sha":"789aa3e6ef120baa743c5a5d0fdbf5cb53479c4c","user":{"login":"Calligre","id":19350741,"avatar_url":"https://avatars.githubusercontent.com/u/19350741?v=3","gravatar_id":"","url":"https://api.github.com/users/Calligre","html_url":"https://github.com/Calligre","followers_url":"https://api.github.com/users/Calligre/followers","following_url":"https://api.github.com/users/Calligre/following{/other_user}","gists_url":"https://api.github.com/users/Calligre/gists{/gist_id}","starred_url":"https://api.github.com/users/Calligre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Calligre/subscriptions","organizations_url":"https://api.github.com/users/Calligre/orgs","repos_url":"https://api.github.com/users/Calligre/repos","events_url":"https://api.github.com/users/Calligre/events{/privacy}","received_events_url":"https://api.github.com/users/Calligre/received_events","type":"Organization","site_admin":false},"repo":{"id":61333042,"name":"attendee-web","full_name":"Calligre/attendee-web","owner":{"login":"Calligre","id":19350741,"avatar_url":"https://avatars.githubusercontent.com/u/19350741?v=3","gravatar_id":"","url":"https://api.github.com/users/Calligre","html_url":"https://github.com/Calligre","followers_url":"https://api.github.com/users/Calligre/followers","following_url":"https://api.github.com/users/Calligre/following{/other_user}","gists_url":"https://api.github.com/users/Calligre/gists{/gist_id}","starred_url":"https://api.github.com/users/Calligre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Calligre/subscriptions","organizations_url":"https://api.github.com/users/Calligre/orgs","repos_url":"https://api.github.com/users/Calligre/repos","events_url":"https://api.github.com/users/Calligre/events{/privacy}","received_events_url":"https://api.github.com/users/Calligre/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Calligre/attendee-web","description":"Attendee web app.","fork":false,"url":"https://api.github.com/repos/Calligre/attendee-web","forks_url":"https://api.github.com/repos/Calligre/attendee-web/forks","keys_url":"https://api.github.com/repos/Calligre/attendee-web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Calligre/attendee-web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Calligre/attendee-web/teams","hooks_url":"https://api.github.com/repos/Calligre/attendee-web/hooks","issue_events_url":"https://api.github.com/repos/Calligre/attendee-web/issues/events{/number}","events_url":"https://api.github.com/repos/Calligre/attendee-web/events","assignees_url":"https://api.github.com/repos/Calligre/attendee-web/assignees{/user}","branches_url":"https://api.github.com/repos/Calligre/attendee-web/branches{/branch}","tags_url":"https://api.github.com/repos/Calligre/attendee-web/tags","blobs_url":"https://api.github.com/repos/Calligre/attendee-web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Calligre/attendee-web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Calligre/attendee-web/git/refs{/sha}","trees_url":"https://api.github.com/repos/Calligre/attendee-web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Calligre/attendee-web/statuses/{sha}","languages_url":"https://api.github.com/repos/Calligre/attendee-web/languages","stargazers_url":"https://api.github.com/repos/Calligre/attendee-web/stargazers","contributors_url":"https://api.github.com/repos/Calligre/attendee-web/contributors","subscribers_url":"https://api.github.com/repos/Calligre/attendee-web/subscribers","subscription_url":"https://api.github.com/repos/Calligre/attendee-web/subscription","commits_url":"https://api.github.com/repos/Calligre/attendee-web/commits{/sha}","git_commits_url":"https://api.github.com/repos/Calligre/attendee-web/git/commits{/sha}","comments_url":"https://api.github.com/repos/Calligre/attendee-web/comments{/number}","issue_comment_url":"https://api.github.com/repos/Calligre/attendee-web/issues/comments{/number}","contents_url":"https://api.github.com/repos/Calligre/attendee-web/contents/{+path}","compare_url":"https://api.github.com/repos/Calligre/attendee-web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Calligre/attendee-web/merges","archive_url":"https://api.github.com/repos/Calligre/attendee-web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Calligre/attendee-web/downloads","issues_url":"https://api.github.com/repos/Calligre/attendee-web/issues{/number}","pulls_url":"https://api.github.com/repos/Calligre/attendee-web/pulls{/number}","milestones_url":"https://api.github.com/repos/Calligre/attendee-web/milestones{/number}","notifications_url":"https://api.github.com/repos/Calligre/attendee-web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Calligre/attendee-web/labels{/name}","releases_url":"https://api.github.com/repos/Calligre/attendee-web/releases{/id}","deployments_url":"https://api.github.com/repos/Calligre/attendee-web/deployments","created_at":"2016-06-16T23:51:40Z","updated_at":"2016-06-27T22:55:42Z","pushed_at":"2016-09-28T01:50:03Z","git_url":"git://github.com/Calligre/attendee-web.git","ssh_url":"git@github.com:Calligre/attendee-web.git","clone_url":"https://github.com/Calligre/attendee-web.git","svn_url":"https://github.com/Calligre/attendee-web","homepage":null,"size":1833,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":23,"forks":1,"open_issues":23,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Calligre/attendee-web/pulls/34"},"html":{"href":"https://github.com/Calligre/attendee-web/pull/34"},"issue":{"href":"https://api.github.com/repos/Calligre/attendee-web/issues/34"},"comments":{"href":"https://api.github.com/repos/Calligre/attendee-web/issues/34/comments"},"review_comments":{"href":"https://api.github.com/repos/Calligre/attendee-web/pulls/34/comments"},"review_comment":{"href":"https://api.github.com/repos/Calligre/attendee-web/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Calligre/attendee-web/pulls/34/commits"},"statuses":{"href":"https://api.github.com/repos/Calligre/attendee-web/statuses/87b23d99db3000778b25ddff4dcd9c366b0e8d2f"}}}}
{"actor":{"display_login":"larajanecka"}}