Cleaned up overview-posts ctrl. Fixed bug from dupl. field in ret'd obj.
@@ -24,6 +24,7 @@ class OverviewPostsController {
constructor() {
attach(this, serviceDependencies, arguments);
this.selection = 1;
+ window.ovp4dbg = this;
const selectFromState = (state) => {
const unreadEvents = selectUnreadEvents(state);
@@ -38,12 +39,8 @@ class OverviewPostsController {
else{
unseenMatchesCounts = unseenMatchesCounts.set(receiverNeed, count + 1);
}
-
});
-
-
-
//won.EVENT.HINT_RECEIVED -> matches
//won.EVENT.WON_MESSAGE_RECEIVED -> convoMessages (!= convos with new messages <- we want this)
//won.EVENT.CONNECT_RECEIVED -> incomingRequests
@@ -51,22 +48,22 @@ class OverviewPostsController {
//goal: unseenCounts = { <uri> : { matches: 11, conversations: 0, incomingRequests: 2 }, <uri>:...}
//TODO use memoized selector to avoid running this calculation on every tick
-
-
const ownNeeds = selectOwnNeeds(state);
- const activePosts = ownNeeds.filter(post =>
+ let activePosts = ownNeeds.filter(post =>
post.getIn(['won:isInState', '@id']) === won.WON.ActiveCompacted
);
- const inactivePosts = ownNeeds.filter(post =>
+ activePosts = activePosts? activePosts.toArray() : [];
+
+ let inactivePosts = ownNeeds.filter(post =>
post.getIn(['won:isInState', '@id']) === won.WON.InactiveCompacted
);
+ inactivePosts = inactivePosts? inactivePosts.toArray() : [];
+
return {
- activePosts: activePosts? activePosts.toArray() : [],
- activePostsUris: activePosts? activePosts.toArray().map(p => p.get('@id')) : [],
- activePostsCount: activePosts? activePosts.size : 0,
- inactivePosts: inactivePosts? inactivePosts.toArray() : [],
- activePostsUris: inactivePosts? inactivePosts.toArray().map(p => p.get('@id')) : [],
- inactivePostsCount: inactivePosts? inactivePosts.size : 0,
+ activePostsUris: activePosts.map(p => p.get('@id')),
+ activePostsCount: activePosts.length,
+ inactivePostsUris: inactivePosts.map(p => p.get('@id')),
+ inactivePostsCount: inactivePosts.length,
unreadEvents,
unreadCounts: selectUnreadCountsByNeedAndType(state),
//unreadMatchEventsOfNeed: unseenMatchesCounts,
@@ -78,10 +75,6 @@ class OverviewPostsController {
}
}
- window.opc = this;
-/* this.$scope.getMatches = function(uri){
- this.$filter('filterEventByType')(this.$scope.unreadEvents,uri,won.EVENT.HINT_RECEIVED)
- }*/
const disconnect = this.$ngRedux.connect(selectFromState, actionCreators)(this);
this.$scope.$on('$destroy', disconnect);
}
