Clean up user activity code in preparation for topic rendering

This commit is contained in:
Robin Ward 2013-07-23 16:33:33 -04:00
parent c9c6a8fd9d
commit 82465caf97
3 changed files with 20 additions and 64 deletions

View File

@ -33,7 +33,6 @@ Discourse.UserActivityRoute = Discourse.Route.extend({
});
}
}
});
/**
@ -45,8 +44,13 @@ Discourse.UserActivityRoute = Discourse.Route.extend({
@module Discourse
**/
Discourse.UserActivityIndexRoute = Discourse.Route.extend({
privateMessageRoute: function() {
return (this.get('userActionType') === Discourse.UserAction.TYPES.messages_sent) ||
(this.get('userActionType') === Discourse.UserAction.TYPES.messages_received);
}.property('userActionType'),
model: function() {
return this.modelFor('user').findStream();
return this.modelFor('user').findStream(this.get('userActionType'));
},
setupController: function(controller, model) {
@ -61,12 +65,15 @@ Discourse.UserActivityIndexRoute = Discourse.Route.extend({
// Build all the filter routes
Object.keys(Discourse.UserAction.TYPES).forEach(function (userAction) {
Discourse["UserActivity" + userAction.classify() + "Route"] = Discourse.UserActivityIndexRoute.extend({
model: function() {
return this.modelFor('user').findStream(Discourse.UserAction.TYPES[userAction]);
}
userActionType: Discourse.UserAction.TYPES[userAction]
});
});
// Build the private message routes
Discourse.UserPrivateMessagesRoute = Discourse.UserActivityRoute.extend({});
Discourse.UserPrivateMessagesIndexRoute = Discourse.UserActivityMessagesReceivedRoute;
Discourse.UserPrivateMessagesSentRoute = Discourse.UserActivityMessagesSentRoute;
/**
Show the user's default route
@ -82,62 +89,15 @@ Discourse.UserIndexRoute = Discourse.Route.extend({
},
model: function() {
var user = this.modelFor('user');
return user.findStream();
return this.modelFor('user').findStream();
},
setupController: function(controller, stream) {
var userActivity = this.controllerFor('userActivity');
userActivity.setProperties({
model: this.modelFor('user'),
stream: stream
});
userActivity.setProperties({ model: this.modelFor('user'), stream: stream });
}
});
/**
Base route for showing private messages
@class UserPrivateMessagesRoute
@extends Discourse.UserActivityRoute
@namespace Discourse
@module Discourse
**/
Discourse.UserPrivateMessagesRoute = Discourse.UserActivityRoute.extend({});
/**
Default private messages route
@class UserPrivateMessagesIndexRoute
@extends Discourse.UserActivityIndexRoute
@namespace Discourse
@module Discourse
**/
Discourse.UserPrivateMessagesIndexRoute = Discourse.UserActivityIndexRoute.extend({
privateMessageRoute: true,
model: function() {
return this.modelFor('user').findStream(Discourse.UserAction.TYPES.messages_received);
}
});
/**
Private messages sent route
@class UserPrivateMessagesSentRoute
@extends Discourse.UserActivityIndexRoute
@namespace Discourse
@module Discourse
**/
Discourse.UserPrivateMessagesSentRoute = Discourse.UserActivityIndexRoute.extend({
privateMessageRoute: true,
model: function() {
return this.modelFor('user').findStream(Discourse.UserAction.TYPES.messages_sent);
}
});
/**
This controller supports all actions on a user's activity stream
@ -149,12 +109,6 @@ Discourse.UserPrivateMessagesSentRoute = Discourse.UserActivityIndexRoute.extend
Discourse.UserActivityController = Discourse.ObjectController.extend({
needs: ['composer'],
kickOffPrivateMessage: (function() {
if (this.get('content.openPrivateMessage')) {
this.composePrivateMessage();
}
}).observes('content.openPrivateMessage'),
composePrivateMessage: function() {
return this.get('controllers.composer').open({
action: Discourse.Composer.PRIVATE_MESSAGE,

View File

@ -1,4 +1,4 @@
{{#each view.stream.content}}
{{#with view.content}}
<div {{bindAttr class=":item hidden deleted moderator_action"}}>
<div class='clearfix info'>
<a href="{{unbound userUrl}}" class='avatar-link'><div class='avatar-wrapper'>{{avatar this imageSize="large" extraClasses="actor" ignoreTitle="true"}}</div></a>
@ -20,5 +20,5 @@
</div>
{{/each}}
</div>
{{/each}}
{{/with}}

View File

@ -7,10 +7,11 @@
@uses Discourse.Scrolling
@module Discourse
**/
Discourse.UserStreamView = Discourse.View.extend(Discourse.Scrolling, {
templateName: 'user/stream',
Discourse.UserStreamView = Ember.CollectionView.extend(Discourse.Scrolling, {
loading: false,
elementId: 'user-stream',
content: Em.computed.alias('controller.stream.content'),
itemViewClass: Ember.View.extend({ templateName: 'user/stream_item' }),
scrolled: function(e) {
var eyeline = this.get('eyeline');
@ -33,6 +34,7 @@ Discourse.UserStreamView = Discourse.View.extend(Discourse.Scrolling, {
},
didInsertElement: function() {
console.log(this.get('content'));
this.bindScrolling();
var eyeline = new Discourse.Eyeline('#user-stream .item');