FEATURE: automatically unpin topic when user reaches bottom

This commit is contained in:
Régis Hanol 2015-11-02 18:26:26 +01:00
parent ff0c12efa2
commit 7436a3feb3
1 changed files with 9 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import ClickTrack from 'discourse/lib/click-track';
import { listenForViewEvent } from 'discourse/lib/app-events';
import { categoryBadgeHTML } from 'discourse/helpers/category-link';
import Scrolling from 'discourse/mixins/scrolling';
import isElementInViewport from "discourse/lib/is-element-in-viewport";
const TopicView = Ember.View.extend(AddCategoryClass, AddArchetypeClass, Scrolling, {
templateName: 'topic',
@ -117,6 +118,14 @@ const TopicView = Ember.View.extend(AddCategoryClass, AddArchetypeClass, Scrolli
headerController.set('showExtraInfo', topic.get('postStream.firstPostNotLoaded'));
}
// automatically unpin topics when the user reaches the bottom
if (topic.get("pinned")) {
const $topicFooterButtons = $("#topic-footer-buttons");
if ($topicFooterButtons.length > 0 && isElementInViewport($topicFooterButtons)) {
Em.run.next(() => topic.clearPin());
}
}
// Trigger a scrolled event
this.appEvents.trigger('topic:scrolled', offset);
},