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