mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Dejquerify marking FAQ as read (#17001)
This commit is contained in:
parent
210d9c2b8f
commit
370df7ccb4
@ -1,3 +1,4 @@
|
|||||||
|
import { bind } from "discourse-common/utils/decorators";
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import isElementInViewport from "discourse/lib/is-element-in-viewport";
|
import isElementInViewport from "discourse/lib/is-element-in-viewport";
|
||||||
|
|
||||||
@ -11,17 +12,28 @@ export default Component.extend({
|
|||||||
|
|
||||||
const path = this.path;
|
const path = this.path;
|
||||||
if (path === "faq" || path === "guidelines") {
|
if (path === "faq" || path === "guidelines") {
|
||||||
$(window).on("load.faq resize.faq scroll.faq", () => {
|
this._markRead();
|
||||||
const faqUnread = !currentUser.get("read_faq");
|
window.addEventListener("resize", this._markRead, false);
|
||||||
if (faqUnread && isElementInViewport($(".contents p").last()[0])) {
|
window.addEventListener("scroll", this._markRead, false);
|
||||||
this.action();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
$(window).off("load.faq resize.faq scroll.faq");
|
|
||||||
|
window.removeEventListener("resize", this._markRead);
|
||||||
|
window.removeEventListener("scroll", this._markRead);
|
||||||
|
},
|
||||||
|
|
||||||
|
@bind
|
||||||
|
_markRead() {
|
||||||
|
const faqUnread = !this.currentUser.read_faq;
|
||||||
|
|
||||||
|
if (
|
||||||
|
faqUnread &&
|
||||||
|
isElementInViewport(document.querySelector(".contents p:last-child"))
|
||||||
|
) {
|
||||||
|
this.action();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user