mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
FEATURE: automatically unpin topic when user reaches bottom
This commit is contained in:
parent
ff0c12efa2
commit
7436a3feb3
1 changed files with 9 additions and 0 deletions
|
@ -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);
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue