mirror of
https://github.com/flarum/core.git
synced 2025-07-23 17:51:24 +02:00
2 lines
4.3 KiB
JavaScript
2 lines
4.3 KiB
JavaScript
module.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var s=t[o]={i:o,l:!1,exports:{}};return e[o].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)n.d(o,s,function(t){return e[t]}.bind(null,s));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t){e.exports=flarum.core.compat["forum/app"]},function(e,t){e.exports=flarum.core.compat["common/extend"]},,function(e,t){e.exports=flarum.core.compat["forum/components/DiscussionList"]},function(e,t){e.exports=flarum.core.compat["forum/components/IndexPage"]},function(e,t){e.exports=flarum.core.compat["forum/components/DiscussionPage"]},function(e,t){e.exports=flarum.core.compat["common/components/Button"]},function(e,t,n){"use strict";n.r(t);var o=n(0),s=n.n(o),r=n(1),u=n(3),i=n.n(u),a=n(5),c=n.n(a),d=n(4),p=n.n(d),f=n(6),l=n.n(f);s.a.initializers.add("flarum-pusher",(function(){s.a.pusher=new Promise((function(e){$.getScript("//cdn.jsdelivr.net/npm/pusher-js@7.0.3/dist/web/pusher.min.js",(function(){var t=new Pusher(s.a.forum.attribute("pusherKey"),{authEndpoint:s.a.forum.attribute("apiUrl")+"/pusher/auth",cluster:s.a.forum.attribute("pusherCluster"),auth:{headers:{"X-CSRF-Token":s.a.session.csrfToken}}});return e({channels:{main:t.subscribe("public"),user:s.a.session.user?t.subscribe("private-user"+s.a.session.user.id()):null},pusher:t})}))})),s.a.pushedUpdates=[],Object(r.extend)(i.a.prototype,"oncreate",(function(){s.a.pusher.then((function(e){e.pusher.bind("newPost",(function(e){var t=s.a.discussions.getParams();if(!t.q&&!t.sort&&!t.filter){if(t.tags){var n=s.a.store.getBy("tags","slug",t.tags);if(-1===e.tagIds.indexOf(n.id()))return}var o=String(e.discussionId);s.a.current.get("discussion")&&o===s.a.current.get("discussion").id()||-1!==s.a.pushedUpdates.indexOf(o)||(s.a.pushedUpdates.push(o),s.a.current.matches(p.a)&&s.a.setTitleCount(s.a.pushedUpdates.length),m.redraw())}}))}))})),Object(r.extend)(i.a.prototype,"onremove",(function(){s.a.pusher.then((function(e){e.pusher.unbind("newPost")}))})),Object(r.extend)(i.a.prototype,"view",(function(e){var t=this;if(s.a.pushedUpdates){var n=s.a.pushedUpdates.length;n&&e.children.unshift(l.a.component({className:"Button Button--block DiscussionList-update",onclick:function(){t.attrs.state.refresh().then((function(){t.loadingUpdated=!1,s.a.pushedUpdates=[],s.a.setTitleCount(0),m.redraw()})),t.loadingUpdated=!0},loading:this.loadingUpdated},s.a.translator.trans("flarum-pusher.forum.discussion_list.show_updates_text",{count:n})))}})),Object(r.extend)(i.a.prototype,"addDiscussion",(function(e,t){var n=s.a.pushedUpdates.indexOf(t.id());-1!==n&&s.a.pushedUpdates.splice(n,1),s.a.current.matches(p.a)&&s.a.setTitleCount(s.a.pushedUpdates.length),m.redraw()})),Object(r.extend)(c.a.prototype,"oncreate",(function(){var e=this;s.a.pusher.then((function(t){t.pusher.bind("newPost",(function(t){var n=String(t.discussionId);if(e.discussion&&e.discussion.id()===n&&e.stream){var o=e.discussion.commentCount();s.a.store.find("discussions",e.discussion.id()).then((function(){e.stream.update().then(m.redraw),document.hasFocus()||(s.a.setTitleCount(Math.max(0,e.discussion.commentCount()-o)),$(window).one("focus",(function(){return s.a.setTitleCount(0)})))}))}}))}))})),Object(r.extend)(c.a.prototype,"onremove",(function(){s.a.pusher.then((function(e){e.pusher.unbind("newPost")}))})),Object(r.extend)(p.a.prototype,"actionItems",(function(e){e.remove("refresh")})),s.a.pusher.then((function(e){var t=e.channels;t.user&&t.user.bind("notification",(function(){s.a.session.user.pushAttributes({unreadNotificationCount:s.a.session.user.unreadNotificationCount()+1,newNotificationCount:s.a.session.user.newNotificationCount()+1}),s.a.notifications.clear(),m.redraw()}))}))}))}]);
|
|
//# sourceMappingURL=forum.js.map
|