pleroma/priv/static/packs/features/notifications.js
2019-01-31 10:35:44 +01:00

2 lines
No EOL
17 KiB
JavaScript

(window.webpackJsonp=window.webpackJsonp||[]).push([[35],{700:function(t,e,i){"use strict";i.r(e);var n,a,o,s,c,l,r,p=i(1),f=i(6),u=i(0),d=i(2),b=i(53),g=i.n(b),h=i(3),O=i.n(h),j=i(20),v=i(430),m=i(428),w=i(75),M=i(203),_=i(154),C=i(5),y=i.n(C),N=i(26),k=i.n(N),P=i(631),I=i(887),x=i(7),F=i(407),S=i(24),D=i(176),T=function(t,e,i){var n=[e];return n.push(t.formatDate(i,{hour:"2-digit",minute:"2-digit",month:"short",day:"numeric"})),n.join(", ")},U=Object(x.g)((o=a=function(a){function t(){for(var n,t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return n=a.call.apply(a,[this].concat(e))||this,Object(d.a)(Object(u.a)(Object(u.a)(n)),"handleMoveUp",function(){var t=n.props,e=t.notification;(0,t.onMoveUp)(e.get("id"))}),Object(d.a)(Object(u.a)(Object(u.a)(n)),"handleMoveDown",function(){var t=n.props,e=t.notification;(0,t.onMoveDown)(e.get("id"))}),Object(d.a)(Object(u.a)(Object(u.a)(n)),"handleOpen",function(){var t=n.props.notification;t.get("status")?n.context.router.history.push("/statuses/"+t.get("status")):n.handleOpenProfile()}),Object(d.a)(Object(u.a)(Object(u.a)(n)),"handleOpenProfile",function(){var t=n.props.notification;n.context.router.history.push("/accounts/"+t.getIn(["account","id"]))}),Object(d.a)(Object(u.a)(Object(u.a)(n)),"handleMention",function(t){t.preventDefault();var e=n.props,i=e.notification;(0,e.onMention)(i.get("account"),n.context.router.history)}),n}Object(f.a)(t,a);var e=t.prototype;return e.getHandlers=function(){return{moveUp:this.handleMoveUp,moveDown:this.handleMoveDown,open:this.handleOpen,openProfile:this.handleOpenProfile,mention:this.handleMention,reply:this.handleMention}},e.renderFollow=function(t,e,i){var n=this.props.intl;return Object(p.a)(D.HotKeys,{handlers:this.getHandlers()},void 0,Object(p.a)("div",{className:"notification notification-follow focusable",tabIndex:"0","aria-label":T(n,n.formatMessage({id:"notification.follow",defaultMessage:"{name} followed you"},{name:e.get("acct")}),t.get("created_at"))},void 0,Object(p.a)("div",{className:"notification__message"},void 0,Object(p.a)("div",{className:"notification__favourite-icon-wrapper"},void 0,Object(p.a)("i",{className:"fa fa-fw fa-user-plus"})),Object(p.a)("span",{title:t.get("created_at")},void 0,Object(p.a)(x.b,{id:"notification.follow",defaultMessage:"{name} followed you",values:{name:i}}))),Object(p.a)(I.a,{id:e.get("id"),withNote:!1,hidden:this.props.hidden})))},e.renderMention=function(t){return Object(p.a)(P.a,{id:t.get("status"),withDismiss:!0,hidden:this.props.hidden,onMoveDown:this.handleMoveDown,onMoveUp:this.handleMoveUp,contextType:"notifications"})},e.renderFavourite=function(t,e){var i=this.props.intl;return Object(p.a)(D.HotKeys,{handlers:this.getHandlers()},void 0,Object(p.a)("div",{className:"notification notification-favourite focusable",tabIndex:"0","aria-label":T(i,i.formatMessage({id:"notification.favourite",defaultMessage:"{name} favourited your status"},{name:t.getIn(["account","acct"])}),t.get("created_at"))},void 0,Object(p.a)("div",{className:"notification__message"},void 0,Object(p.a)("div",{className:"notification__favourite-icon-wrapper"},void 0,Object(p.a)("i",{className:"fa fa-fw fa-star star-icon"})),Object(p.a)("span",{title:t.get("created_at")},void 0,Object(p.a)(x.b,{id:"notification.favourite",defaultMessage:"{name} favourited your status",values:{name:e}}))),Object(p.a)(P.a,{id:t.get("status"),account:t.get("account"),muted:!0,withDismiss:!0,hidden:!!this.props.hidden})))},e.renderReblog=function(t,e){var i=this.props.intl;return Object(p.a)(D.HotKeys,{handlers:this.getHandlers()},void 0,Object(p.a)("div",{className:"notification notification-reblog focusable",tabIndex:"0","aria-label":T(i,i.formatMessage({id:"notification.reblog",defaultMessage:"{name} boosted your status"},{name:t.getIn(["account","acct"])}),t.get("created_at"))},void 0,Object(p.a)("div",{className:"notification__message"},void 0,Object(p.a)("div",{className:"notification__favourite-icon-wrapper"},void 0,Object(p.a)("i",{className:"fa fa-fw fa-retweet"})),Object(p.a)("span",{title:t.get("created_at")},void 0,Object(p.a)(x.b,{id:"notification.reblog",defaultMessage:"{name} boosted your status",values:{name:e}}))),Object(p.a)(P.a,{id:t.get("status"),account:t.get("account"),muted:!0,withDismiss:!0,hidden:this.props.hidden})))},e.render=function(){var t=this.props.notification,e=t.get("account"),i={__html:e.get("display_name_html")},n=Object(p.a)("bdi",{},void 0,Object(p.a)(F.a,{className:"notification__display-name",href:e.get("url"),title:e.get("acct"),to:"/accounts/"+e.get("id"),dangerouslySetInnerHTML:i}));switch(t.get("type")){case"follow":return this.renderFollow(t,e,n);case"mention":return this.renderMention(t);case"favourite":return this.renderFavourite(t,n);case"reblog":return this.renderReblog(t,n)}return null},t}(S.a),Object(d.a)(a,"contextTypes",{router:y.a.object}),Object(d.a)(a,"propTypes",{notification:k.a.map.isRequired,hidden:y.a.bool,onMoveUp:y.a.func.isRequired,onMoveDown:y.a.func.isRequired,onMention:y.a.func.isRequired,intl:y.a.object.isRequired}),n=o))||n,q=i(22),L=Object(j.connect)(function(){var i=Object(_.e)();return function(t,e){return{notification:i(t,e.notification,e.accountId)}}},function(i){return{onMention:function(t,e){i(Object(q.R)(t,e))}}})(U),R=function(t){function e(){return t.apply(this,arguments)||this}return Object(f.a)(e,t),e.prototype.render=function(){return Object(p.a)("button",{className:"text-btn column-header__setting-btn",tabIndex:"0",onClick:this.props.onClick},void 0,Object(p.a)("i",{className:"fa fa-eraser"})," ",Object(p.a)(x.b,{id:"notifications.clear",defaultMessage:"Clear notifications"}))},e}(O.a.PureComponent),H=i(918),A=function(a){function t(){for(var i,t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return i=a.call.apply(a,[this].concat(e))||this,Object(d.a)(Object(u.a)(Object(u.a)(i)),"onPushChange",function(t,e){i.props.onChange(["push"].concat(t),e)}),i}return Object(f.a)(t,a),t.prototype.render=function(){var t=this.props,e=t.settings,i=t.pushSettings,n=t.onChange,a=t.onClear,o=Object(p.a)(x.b,{id:"notifications.column_settings.filter_bar.show",defaultMessage:"Show"}),s=Object(p.a)(x.b,{id:"notifications.column_settings.filter_bar.advanced",defaultMessage:"Display all categories"}),c=Object(p.a)(x.b,{id:"notifications.column_settings.alert",defaultMessage:"Desktop notifications"}),l=Object(p.a)(x.b,{id:"notifications.column_settings.show",defaultMessage:"Show in column"}),r=Object(p.a)(x.b,{id:"notifications.column_settings.sound",defaultMessage:"Play sound"}),f=i.get("browserSupport")&&i.get("isSubscribed"),u=f&&Object(p.a)(x.b,{id:"notifications.column_settings.push",defaultMessage:"Push notifications"});return Object(p.a)("div",{},void 0,Object(p.a)("div",{className:"column-settings__row"},void 0,Object(p.a)(R,{onClick:a})),Object(p.a)("div",{role:"group","aria-labelledby":"notifications-filter-bar"},void 0,Object(p.a)("span",{id:"notifications-filter-bar",className:"column-settings__section"},void 0,Object(p.a)(x.b,{id:"notifications.column_settings.filter_bar.category",defaultMessage:"Quick filter bar"})),Object(p.a)("div",{className:"column-settings__row"},void 0,Object(p.a)(H.a,{id:"show-filter-bar",prefix:"notifications",settings:e,settingPath:["quickFilter","show"],onChange:n,label:o}),Object(p.a)(H.a,{id:"show-filter-bar",prefix:"notifications",settings:e,settingPath:["quickFilter","advanced"],onChange:n,label:s}))),Object(p.a)("div",{role:"group","aria-labelledby":"notifications-follow"},void 0,Object(p.a)("span",{id:"notifications-follow",className:"column-settings__section"},void 0,Object(p.a)(x.b,{id:"notifications.column_settings.follow",defaultMessage:"New followers:"})),Object(p.a)("div",{className:"column-settings__row"},void 0,Object(p.a)(H.a,{prefix:"notifications_desktop",settings:e,settingPath:["alerts","follow"],onChange:n,label:c}),f&&Object(p.a)(H.a,{prefix:"notifications_push",settings:i,settingPath:["alerts","follow"],onChange:this.onPushChange,label:u}),Object(p.a)(H.a,{prefix:"notifications",settings:e,settingPath:["shows","follow"],onChange:n,label:l}),Object(p.a)(H.a,{prefix:"notifications",settings:e,settingPath:["sounds","follow"],onChange:n,label:r}))),Object(p.a)("div",{role:"group","aria-labelledby":"notifications-favourite"},void 0,Object(p.a)("span",{id:"notifications-favourite",className:"column-settings__section"},void 0,Object(p.a)(x.b,{id:"notifications.column_settings.favourite",defaultMessage:"Favourites:"})),Object(p.a)("div",{className:"column-settings__row"},void 0,Object(p.a)(H.a,{prefix:"notifications_desktop",settings:e,settingPath:["alerts","favourite"],onChange:n,label:c}),f&&Object(p.a)(H.a,{prefix:"notifications_push",settings:i,settingPath:["alerts","favourite"],onChange:this.onPushChange,label:u}),Object(p.a)(H.a,{prefix:"notifications",settings:e,settingPath:["shows","favourite"],onChange:n,label:l}),Object(p.a)(H.a,{prefix:"notifications",settings:e,settingPath:["sounds","favourite"],onChange:n,label:r}))),Object(p.a)("div",{role:"group","aria-labelledby":"notifications-mention"},void 0,Object(p.a)("span",{id:"notifications-mention",className:"column-settings__section"},void 0,Object(p.a)(x.b,{id:"notifications.column_settings.mention",defaultMessage:"Mentions:"})),Object(p.a)("div",{className:"column-settings__row"},void 0,Object(p.a)(H.a,{prefix:"notifications_desktop",settings:e,settingPath:["alerts","mention"],onChange:n,label:c}),f&&Object(p.a)(H.a,{prefix:"notifications_push",settings:i,settingPath:["alerts","mention"],onChange:this.onPushChange,label:u}),Object(p.a)(H.a,{prefix:"notifications",settings:e,settingPath:["shows","mention"],onChange:n,label:l}),Object(p.a)(H.a,{prefix:"notifications",settings:e,settingPath:["sounds","mention"],onChange:n,label:r}))),Object(p.a)("div",{role:"group","aria-labelledby":"notifications-reblog"},void 0,Object(p.a)("span",{id:"notifications-reblog",className:"column-settings__section"},void 0,Object(p.a)(x.b,{id:"notifications.column_settings.reblog",defaultMessage:"Boosts:"})),Object(p.a)("div",{className:"column-settings__row"},void 0,Object(p.a)(H.a,{prefix:"notifications_desktop",settings:e,settingPath:["alerts","reblog"],onChange:n,label:c}),f&&Object(p.a)(H.a,{prefix:"notifications_push",settings:i,settingPath:["alerts","reblog"],onChange:this.onPushChange,label:u}),Object(p.a)(H.a,{prefix:"notifications",settings:e,settingPath:["shows","reblog"],onChange:n,label:l}),Object(p.a)(H.a,{prefix:"notifications",settings:e,settingPath:["sounds","reblog"],onChange:n,label:r}))))},t}(O.a.PureComponent),B=i(83),K=i(181),z=i(49),G=Object(x.f)({clearMessage:{id:"notifications.clear_confirmation",defaultMessage:"Are you sure you want to permanently clear all your notifications?"},clearConfirm:{id:"notifications.clear",defaultMessage:"Clear notifications"}}),J=Object(x.g)(Object(j.connect)(function(t){return{settings:t.getIn(["settings","notifications"]),pushSettings:t.get("push_notifications")}},function(i,t){var e=t.intl;return{onChange:function(t,e){"push"===t[0]?i(Object(K.e)(t.slice(1),e)):"quickFilter"===t[0]?(i(Object(B.c)(["notifications"].concat(t),e)),i(Object(w.k)("all"))):i(Object(B.c)(["notifications"].concat(t),e))},onClear:function(){i(Object(z.d)("CONFIRM",{message:e.formatMessage(G.clearMessage),confirm:e.formatMessage(G.clearConfirm),onConfirm:function(){return i(Object(w.h)())}}))}}})(A)),E=Object(x.f)({mentions:{id:"notifications.filter.mentions",defaultMessage:"Mentions"},favourites:{id:"notifications.filter.favourites",defaultMessage:"Favourites"},boosts:{id:"notifications.filter.boosts",defaultMessage:"Boosts"},follows:{id:"notifications.filter.follows",defaultMessage:"Follows"}}),Q=Object(x.g)(s=function(t){function e(){return t.apply(this,arguments)||this}Object(f.a)(e,t);var i=e.prototype;return i.onClick=function(t){var e=this;return function(){return e.props.selectFilter(t)}},i.render=function(){var t=this.props,e=t.selectedFilter,i=t.advancedMode,n=t.intl;return i?Object(p.a)("div",{className:"notification__filter-bar"},void 0,Object(p.a)("button",{className:"all"===e?"active":"",onClick:this.onClick("all")},void 0,Object(p.a)(x.b,{id:"notifications.filter.all",defaultMessage:"All"})),Object(p.a)("button",{className:"mention"===e?"active":"",onClick:this.onClick("mention"),title:n.formatMessage(E.mentions)},void 0,Object(p.a)("i",{className:"fa fa-fw fa-at"})),Object(p.a)("button",{className:"favourite"===e?"active":"",onClick:this.onClick("favourite"),title:n.formatMessage(E.favourites)},void 0,Object(p.a)("i",{className:"fa fa-fw fa-star"})),Object(p.a)("button",{className:"reblog"===e?"active":"",onClick:this.onClick("reblog"),title:n.formatMessage(E.boosts)},void 0,Object(p.a)("i",{className:"fa fa-fw fa-retweet"})),Object(p.a)("button",{className:"follow"===e?"active":"",onClick:this.onClick("follow"),title:n.formatMessage(E.follows)},void 0,Object(p.a)("i",{className:"fa fa-fw fa-user-plus"}))):Object(p.a)("div",{className:"notification__filter-bar"},void 0,Object(p.a)("button",{className:"all"===e?"active":"",onClick:this.onClick("all")},void 0,Object(p.a)(x.b,{id:"notifications.filter.all",defaultMessage:"All"})),Object(p.a)("button",{className:"mention"===e?"active":"",onClick:this.onClick("mention")},void 0,Object(p.a)(x.b,{id:"notifications.filter.mentions",defaultMessage:"Mentions"})))},e}(O.a.PureComponent))||s,W=Object(j.connect)(function(t){return{selectedFilter:t.getIn(["settings","notifications","quickFilter","active"]),advancedMode:t.getIn(["settings","notifications","quickFilter","advanced"])}},function(e){return{selectFilter:function(t){e(Object(w.k)(t))}}})(Q),Y=i(57),V=i(4),X=i(641),Z=i(651);i.d(e,"default",function(){return et});var $=Object(x.f)({title:{id:"column.notifications",defaultMessage:"Notifications"}}),tt=Object(Y.a)([function(t){return t.getIn(["settings","notifications","quickFilter","show"])},function(t){return t.getIn(["settings","notifications","quickFilter","active"])},function(t){return Object(V.List)(t.getIn(["settings","notifications","shows"]).filter(function(t){return!t}).keys())},function(t){return t.getIn(["notifications","items"])}],function(t,e,i,n){return t&&"all"!==e?n.filter(function(t){return null!==t&&e===t.get("type")}):n.filterNot(function(t){return null!==t&&i.includes(t.get("type"))})}),et=Object(j.connect)(function(t){return{showFilterBar:t.getIn(["settings","notifications","quickFilter","show"]),notifications:tt(t),isLoading:t.getIn(["notifications","isLoading"],!0),isUnread:0<t.getIn(["notifications","unread"]),hasMore:t.getIn(["notifications","hasMore"])}})(c=Object(x.g)((r=l=function(a){function t(){for(var n,t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return n=a.call.apply(a,[this].concat(e))||this,Object(d.a)(Object(u.a)(Object(u.a)(n)),"handleLoadGap",function(t){n.props.dispatch(Object(w.i)({maxId:t}))}),Object(d.a)(Object(u.a)(Object(u.a)(n)),"handleLoadOlder",g()(function(){var t=n.props.notifications.last();n.props.dispatch(Object(w.i)({maxId:t&&t.get("id")}))},300,{leading:!0})),Object(d.a)(Object(u.a)(Object(u.a)(n)),"handleScrollToTop",g()(function(){n.props.dispatch(Object(w.j)(!0))},100)),Object(d.a)(Object(u.a)(Object(u.a)(n)),"handleScroll",g()(function(){n.props.dispatch(Object(w.j)(!1))},100)),Object(d.a)(Object(u.a)(Object(u.a)(n)),"handlePin",function(){var t=n.props,e=t.columnId,i=t.dispatch;i(e?Object(M.h)(e):Object(M.e)("NOTIFICATIONS",{}))}),Object(d.a)(Object(u.a)(Object(u.a)(n)),"handleMove",function(t){var e=n.props,i=e.columnId;(0,e.dispatch)(Object(M.g)(i,t))}),Object(d.a)(Object(u.a)(Object(u.a)(n)),"handleHeaderClick",function(){n.column.scrollTop()}),Object(d.a)(Object(u.a)(Object(u.a)(n)),"setColumnRef",function(t){n.column=t}),Object(d.a)(Object(u.a)(Object(u.a)(n)),"handleMoveUp",function(e){var t=n.props.notifications.findIndex(function(t){return null!==t&&t.get("id")===e})-1;n._selectChild(t)}),Object(d.a)(Object(u.a)(Object(u.a)(n)),"handleMoveDown",function(e){var t=n.props.notifications.findIndex(function(t){return null!==t&&t.get("id")===e})+1;n._selectChild(t)}),n}Object(f.a)(t,a);var e=t.prototype;return e.componentWillUnmount=function(){this.handleLoadOlder.cancel(),this.handleScrollToTop.cancel(),this.handleScroll.cancel(),this.props.dispatch(Object(w.j)(!1))},e._selectChild=function(t){var e=this.column.node.querySelector("article:nth-of-type("+(t+1)+") .focusable");e&&e.focus()},e.render=function(){var i=this,t=this.props,e=t.intl,n=t.notifications,a=t.shouldUpdateScroll,o=t.isLoading,s=t.isUnread,c=t.columnId,l=t.multiColumn,r=t.hasMore,f=t.showFilterBar,u=!!c,d=Object(p.a)(x.b,{id:"empty_column.notifications",defaultMessage:"You don't have any notifications yet. Interact with others to start the conversation."}),b=null,g=f?Object(p.a)(W,{}):null;b=o&&this.scrollableContent?this.scrollableContent:0<n.size||r?n.map(function(t,e){return null===t?Object(p.a)(Z.a,{disabled:o,maxId:0<e?n.getIn([e-1,"id"]):null,onClick:i.handleLoadGap},"gap:"+n.getIn([e+1,"id"])):Object(p.a)(L,{notification:t,accountId:t.get("account"),onMoveUp:i.handleMoveUp,onMoveDown:i.handleMoveDown},t.get("id"))}):null,this.scrollableContent=b;var h=Object(p.a)(X.a,{scrollKey:"notifications-"+c,trackScroll:!u,isLoading:o,showLoading:o&&0===n.size,hasMore:r,emptyMessage:d,onLoadMore:this.handleLoadOlder,onScrollToTop:this.handleScrollToTop,onScroll:this.handleScroll,shouldUpdateScroll:a},void 0,b);return O.a.createElement(v.a,{ref:this.setColumnRef,label:e.formatMessage($.title)},Object(p.a)(m.a,{icon:"bell",active:s,title:e.formatMessage($.title),onPin:this.handlePin,onMove:this.handleMove,onClick:this.handleHeaderClick,pinned:u,multiColumn:l},void 0,Object(p.a)(J,{})),g,h)},t}(O.a.PureComponent),Object(d.a)(l,"defaultProps",{trackScroll:!0}),c=r))||c)||c}}]);
//# sourceMappingURL=notifications.js.map