Remove reliance on views for logic, move to controller

This commit is contained in:
Robin Ward 2013-07-11 16:55:07 -04:00
parent 19c169540c
commit bb5a9aa34b
3 changed files with 13 additions and 13 deletions

View File

@ -254,6 +254,17 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
this.get('content').destroy(Discourse.User.current());
},
resetRead: function() {
Discourse.ScreenTrack.instance().reset();
this.unsubscribe();
var topicController = this;
this.get('model').resetRead().then(function() {
topicController.set('message', I18n.t("topic.read_position_reset"));
topicController.set('postStream.loaded', false);
});
},
toggleVisibility: function() {
this.get('content').toggleStatus('visible');
},

View File

@ -46,14 +46,14 @@
{{/if}}
</li>
{{#if view.topic.canConvertToRegular}}
{{#if canConvertToRegular}}
<li>
<button {{action convertToRegular}} class='btn btn-admin'><i class='icon-minus'></i> {{i18n topic.actions.convert_to_topic}}</button>
</li>
{{/if}}
<li>
<button class='btn btn-admin' {{action resetRead target="view.parentView"}}><i class='icon-remove'></i> {{i18n topic.actions.reset_read}}</button>
<button class='btn btn-admin' {{action resetRead}}><i class='icon-remove'></i> {{i18n topic.actions.reset_read}}</button>
</li>
</ul>
</div>

View File

@ -142,17 +142,6 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
this.debounceLoadSuggested();
}.observes('topicTrackingState.incomingCount'),
resetRead: function(e) {
Discourse.ScreenTrack.instance().reset();
this.get('controller').unsubscribe();
var topicView = this;
this.get('topic').resetRead().then(function() {
topicView.set('controller.message', I18n.t("topic.read_position_reset"));
topicView.set('controller.loaded', false);
});
},
gotFocus: function(){
if (Discourse.get('hasFocus')){
this.scrolled();