akkoma/priv/static/packs/flavours/glitch/async/notifications.js
2019-01-31 10:35:44 +01:00

2 lines
17 KiB
JavaScript

(window.webpackJsonp=window.webpackJsonp||[]).push([[68],{699:function(t,e,n){"use strict";n.r(e);var p=n(1),i=n(6),a=n(0),s=n(2),o=n(53),c=n.n(o),l=n(3),O=n.n(l),r=n(20),j=n(429),v=n(427),f=n(33),u=n(202),d=n(166),b=n(5),g=n.n(b),h=n(26),m=n.n(h),M=n(24),C=n(632),w=n(7),_=n(176),y=n(319),k=n(624),P=n(528),N=function(o){function t(){for(var i,t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return i=o.call.apply(o,[this].concat(e))||this,Object(s.a)(Object(a.a)(Object(a.a)(i)),"handleMoveUp",function(){var t=i.props,e=t.notification;(0,t.onMoveUp)(e.get("id"))}),Object(s.a)(Object(a.a)(Object(a.a)(i)),"handleMoveDown",function(){var t=i.props,e=t.notification;(0,t.onMoveDown)(e.get("id"))}),Object(s.a)(Object(a.a)(Object(a.a)(i)),"handleOpen",function(){i.handleOpenProfile()}),Object(s.a)(Object(a.a)(Object(a.a)(i)),"handleOpenProfile",function(){var t=i.props.notification;i.context.router.history.push("/accounts/"+t.getIn(["account","id"]))}),Object(s.a)(Object(a.a)(Object(a.a)(i)),"handleMention",function(t){t.preventDefault();var e=i.props,n=e.notification;(0,e.onMention)(n.get("account"),i.context.router.history)}),i}Object(i.a)(t,o);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.render=function(){var t=this.props,e=t.account,n=t.notification,i=t.hidden,o=e.get("display_name_html")||e.get("username"),a=Object(p.a)("bdi",{},void 0,Object(p.a)(y.a,{className:"notification__display-name",href:e.get("url"),title:e.get("acct"),to:"/accounts/"+e.get("id"),dangerouslySetInnerHTML:{__html:o}}));return Object(p.a)(_.HotKeys,{handlers:this.getHandlers()},void 0,Object(p.a)("div",{className:"notification notification-follow focusable",tabIndex:"0"},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)(w.b,{id:"notification.follow",defaultMessage:"{name} followed you",values:{name:a}})),Object(p.a)(k.a,{hidden:i,id:e.get("id"),withNote:!1}),Object(p.a)(P.a,{notification:n})))},t}(M.a);Object(s.a)(N,"propTypes",{hidden:g.a.bool,id:g.a.string.isRequired,account:m.a.map.isRequired,notification:m.a.map.isRequired});var I=function(t){function e(){return t.apply(this,arguments)||this}return Object(i.a)(e,t),e.prototype.render=function(){var t=this.props,e=t.hidden,n=t.notification,i=t.onMoveDown,o=t.onMoveUp,a=t.onMention,s=t.getScrollPosition,c=t.updateScrollBottom;switch(n.get("type")){case"follow":return Object(p.a)(N,{hidden:e,id:n.get("id"),account:n.get("account"),notification:n,onMoveDown:i,onMoveUp:o,onMention:a});case"mention":return Object(p.a)(C.a,{containerId:n.get("id"),hidden:e,id:n.get("status"),notification:n,onMoveDown:i,onMoveUp:o,onMention:a,contextType:"notifications",getScrollPosition:s,updateScrollBottom:c,withDismiss:!0});case"favourite":return Object(p.a)(C.a,{containerId:n.get("id"),hidden:e,id:n.get("status"),account:n.get("account"),prepend:"favourite",muted:!0,notification:n,onMoveDown:i,onMoveUp:o,onMention:a,getScrollPosition:s,updateScrollBottom:c,withDismiss:!0});case"reblog":return Object(p.a)(C.a,{containerId:n.get("id"),hidden:e,id:n.get("status"),account:n.get("account"),prepend:"reblog",muted:!0,notification:n,onMoveDown:i,onMoveUp:o,onMention:a,getScrollPosition:s,updateScrollBottom:c,withDismiss:!0});default:return null}},e}(M.a);Object(s.a)(I,"propTypes",{notification:m.a.map.isRequired,hidden:g.a.bool,onMoveUp:g.a.func.isRequired,onMoveDown:g.a.func.isRequired,onMention:g.a.func.isRequired,getScrollPosition:g.a.func,updateScrollBottom:g.a.func});var S,x,U,D,F=n(19),q=Object(r.connect)(function(){var n=Object(d.e)();return function(t,e){return{notification:n(t,e.notification,e.accountId),notifCleaning:t.getIn(["notifications","cleaningMode"])}}},function(n){return{onMention:function(t,e){n(Object(F.U)(t,e))}}})(I),T=function(t){function e(){return t.apply(this,arguments)||this}return Object(i.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)(w.b,{id:"notifications.clear",defaultMessage:"Clear notifications"}))},e}(O.a.Component),A=n(910),L=function(o){function t(){for(var n,t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return n=o.call.apply(o,[this].concat(e))||this,Object(s.a)(Object(a.a)(Object(a.a)(n)),"onPushChange",function(t,e){n.props.onChange(["push"].concat(t),e)}),n}return Object(i.a)(t,o),t.prototype.render=function(){var t=this.props,e=t.settings,n=t.pushSettings,i=t.onChange,o=t.onClear,a=Object(p.a)(w.b,{id:"notifications.column_settings.filter_bar.show",defaultMessage:"Show"}),s=Object(p.a)(w.b,{id:"notifications.column_settings.filter_bar.advanced",defaultMessage:"Display all categories"}),c=Object(p.a)(w.b,{id:"notifications.column_settings.alert",defaultMessage:"Desktop notifications"}),l=Object(p.a)(w.b,{id:"notifications.column_settings.show",defaultMessage:"Show in column"}),r=Object(p.a)(w.b,{id:"notifications.column_settings.sound",defaultMessage:"Play sound"}),f=n.get("browserSupport")&&n.get("isSubscribed"),u=f&&Object(p.a)(w.b,{id:"notifications.column_settings.push",defaultMessage:"Push notifications"}),d=f&&Object(p.a)(w.b,{id:"notifications.column_settings.push_meta",defaultMessage:"This device"});return Object(p.a)("div",{},void 0,Object(p.a)("div",{className:"column-settings__row"},void 0,Object(p.a)(T,{onClick:o})),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)(w.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)(A.a,{id:"show-filter-bar",prefix:"notifications",settings:e,settingPath:["quickFilter","show"],onChange:i,label:a}),Object(p.a)(A.a,{id:"show-filter-bar",prefix:"notifications",settings:e,settingPath:["quickFilter","advanced"],onChange:i,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)(w.b,{id:"notifications.column_settings.follow",defaultMessage:"New followers:"})),Object(p.a)("div",{className:"column-settings__row"},void 0,Object(p.a)(A.a,{prefix:"notifications_desktop",settings:e,settingPath:["alerts","follow"],onChange:i,label:c}),f&&Object(p.a)(A.a,{prefix:"notifications_push",settings:n,settingPath:["alerts","follow"],meta:d,onChange:this.onPushChange,label:u}),Object(p.a)(A.a,{prefix:"notifications",settings:e,settingPath:["shows","follow"],onChange:i,label:l}),Object(p.a)(A.a,{prefix:"notifications",settings:e,settingPath:["sounds","follow"],onChange:i,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)(w.b,{id:"notifications.column_settings.favourite",defaultMessage:"Favourites:"})),Object(p.a)("div",{className:"column-settings__row"},void 0,Object(p.a)(A.a,{prefix:"notifications_desktop",settings:e,settingPath:["alerts","favourite"],onChange:i,label:c}),f&&Object(p.a)(A.a,{prefix:"notifications_push",settings:n,settingPath:["alerts","favourite"],meta:d,onChange:this.onPushChange,label:u}),Object(p.a)(A.a,{prefix:"notifications",settings:e,settingPath:["shows","favourite"],onChange:i,label:l}),Object(p.a)(A.a,{prefix:"notifications",settings:e,settingPath:["sounds","favourite"],onChange:i,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)(w.b,{id:"notifications.column_settings.mention",defaultMessage:"Mentions:"})),Object(p.a)("div",{className:"column-settings__row"},void 0,Object(p.a)(A.a,{prefix:"notifications_desktop",settings:e,settingPath:["alerts","mention"],onChange:i,label:c}),f&&Object(p.a)(A.a,{prefix:"notifications_push",settings:n,settingPath:["alerts","mention"],meta:d,onChange:this.onPushChange,label:u}),Object(p.a)(A.a,{prefix:"notifications",settings:e,settingPath:["shows","mention"],onChange:i,label:l}),Object(p.a)(A.a,{prefix:"notifications",settings:e,settingPath:["sounds","mention"],onChange:i,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)(w.b,{id:"notifications.column_settings.reblog",defaultMessage:"Boosts:"})),Object(p.a)("div",{className:"column-settings__row"},void 0,Object(p.a)(A.a,{prefix:"notifications_desktop",settings:e,settingPath:["alerts","reblog"],onChange:i,label:c}),f&&Object(p.a)(A.a,{prefix:"notifications_push",settings:n,settingPath:["alerts","reblog"],meta:d,onChange:this.onPushChange,label:u}),Object(p.a)(A.a,{prefix:"notifications",settings:e,settingPath:["shows","reblog"],onChange:i,label:l}),Object(p.a)(A.a,{prefix:"notifications",settings:e,settingPath:["sounds","reblog"],onChange:i,label:r}))))},t}(O.a.PureComponent),R=n(82),B=n(180),H=n(44),z=Object(w.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"}}),E=Object(w.g)(Object(r.connect)(function(t){return{settings:t.getIn(["settings","notifications"]),pushSettings:t.get("push_notifications")}},function(n,t){var e=t.intl;return{onChange:function(t,e){"push"===t[0]?n(Object(B.e)(t.slice(1),e)):"quickFilter"===t[0]?(n(Object(R.c)(["notifications"].concat(t),e)),n(Object(f.z)("all"))):n(Object(R.c)(["notifications"].concat(t),e))},onClear:function(){n(Object(H.d)("CONFIRM",{message:e.formatMessage(z.clearMessage),confirm:e.formatMessage(z.clearConfirm),onConfirm:function(){return n(Object(f.q)())}}))}}})(L)),G=Object(w.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"}}),J=Object(w.g)(S=function(t){function e(){return t.apply(this,arguments)||this}Object(i.a)(e,t);var n=e.prototype;return n.onClick=function(t){var e=this;return function(){return e.props.selectFilter(t)}},n.render=function(){var t=this.props,e=t.selectedFilter,n=t.advancedMode,i=t.intl;return n?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)(w.b,{id:"notifications.filter.all",defaultMessage:"All"})),Object(p.a)("button",{className:"mention"===e?"active":"",onClick:this.onClick("mention"),title:i.formatMessage(G.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:i.formatMessage(G.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:i.formatMessage(G.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:i.formatMessage(G.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)(w.b,{id:"notifications.filter.all",defaultMessage:"All"})),Object(p.a)("button",{className:"mention"===e?"active":"",onClick:this.onClick("mention")},void 0,Object(p.a)(w.b,{id:"notifications.filter.mentions",defaultMessage:"Mentions"})))},e}(O.a.PureComponent))||S,K=Object(r.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(f.z)(t))}}})(J),Q=n(57),W=n(4),Y=n(648),V=n(649);n.d(e,"default",function(){return $});var X=Object(w.f)({title:{id:"column.notifications",defaultMessage:"Notifications"}}),Z=Object(Q.a)([function(t){return t.getIn(["settings","notifications","quickFilter","show"])},function(t){return t.getIn(["settings","notifications","quickFilter","active"])},function(t){return Object(W.List)(t.getIn(["settings","notifications","shows"]).filter(function(t){return!t}).keys())},function(t){return t.getIn(["notifications","items"])}],function(t,e,n,i){return t&&"all"!==e?i.filter(function(t){return null!==t&&e===t.get("type")}):i.filterNot(function(t){return null!==t&&n.includes(t.get("type"))})}),$=Object(r.connect)(function(t){return{showFilterBar:t.getIn(["settings","notifications","quickFilter","show"]),notifications:Z(t),localSettings:t.get("local_settings"),isLoading:t.getIn(["notifications","isLoading"],!0),isUnread:0<t.getIn(["notifications","unread"]),hasMore:t.getIn(["notifications","hasMore"]),notifCleaningActive:t.getIn(["notifications","cleaningMode"])}},function(e){return{onEnterCleaningMode:function(t){e(Object(f.s)(t))},onMount:function(){e(Object(f.w)())},onUnmount:function(){e(Object(f.A)())},dispatch:e}})(x=Object(w.g)((D=U=function(o){function t(){for(var i,t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return i=o.call.apply(o,[this].concat(e))||this,Object(s.a)(Object(a.a)(Object(a.a)(i)),"handleLoadGap",function(t){i.props.dispatch(Object(f.t)({maxId:t}))}),Object(s.a)(Object(a.a)(Object(a.a)(i)),"handleLoadOlder",c()(function(){var t=i.props.notifications.last();i.props.dispatch(Object(f.t)({maxId:t&&t.get("id")}))},300,{leading:!0})),Object(s.a)(Object(a.a)(Object(a.a)(i)),"handleScrollToTop",c()(function(){i.props.dispatch(Object(f.y)(!0))},100)),Object(s.a)(Object(a.a)(Object(a.a)(i)),"handleScroll",c()(function(){i.props.dispatch(Object(f.y)(!1))},100)),Object(s.a)(Object(a.a)(Object(a.a)(i)),"handlePin",function(){var t=i.props,e=t.columnId,n=t.dispatch;n(e?Object(u.h)(e):Object(u.e)("NOTIFICATIONS",{}))}),Object(s.a)(Object(a.a)(Object(a.a)(i)),"handleMove",function(t){var e=i.props,n=e.columnId;(0,e.dispatch)(Object(u.g)(n,t))}),Object(s.a)(Object(a.a)(Object(a.a)(i)),"handleHeaderClick",function(){i.column.scrollTop()}),Object(s.a)(Object(a.a)(Object(a.a)(i)),"setColumnRef",function(t){i.column=t}),Object(s.a)(Object(a.a)(Object(a.a)(i)),"handleMoveUp",function(e){var t=i.props.notifications.findIndex(function(t){return null!==t&&t.get("id")===e})-1;i._selectChild(t)}),Object(s.a)(Object(a.a)(Object(a.a)(i)),"handleMoveDown",function(e){var t=i.props.notifications.findIndex(function(t){return null!==t&&t.get("id")===e})+1;i._selectChild(t)}),i}Object(i.a)(t,o);var e=t.prototype;return e._selectChild=function(t){var e=this.column.node.querySelector("article:nth-of-type("+(t+1)+") .focusable");e&&e.focus()},e.componentDidMount=function(){var t=this.props.onMount;t&&t()},e.componentWillUnmount=function(){var t=this.props.onUnmount;t&&t()},e.render=function(){var n=this,t=this.props,e=t.intl,i=t.notifications,o=t.shouldUpdateScroll,a=t.isLoading,s=t.isUnread,c=t.columnId,l=t.multiColumn,r=t.hasMore,f=t.showFilterBar,u=!!c,d=Object(p.a)(w.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)(K,{}):null;b=a&&this.scrollableContent?this.scrollableContent:0<i.size||r?i.map(function(t,e){return null===t?Object(p.a)(V.a,{disabled:a,maxId:0<e?i.getIn([e-1,"id"]):null,onClick:n.handleLoadGap},"gap:"+i.getIn([e+1,"id"])):Object(p.a)(q,{notification:t,accountId:t.get("account"),onMoveUp:n.handleMoveUp,onMoveDown:n.handleMoveDown},t.get("id"))}):null,this.scrollableContent=b;var h=Object(p.a)(Y.a,{scrollKey:"notifications-"+c,trackScroll:!u,isLoading:a,showLoading:a&&0===i.size,hasMore:r,emptyMessage:d,onLoadMore:this.handleLoadOlder,onScrollToTop:this.handleScrollToTop,onScroll:this.handleScroll,shouldUpdateScroll:o},void 0,b);return O.a.createElement(j.a,{ref:this.setColumnRef,name:"notifications",extraClasses:this.props.notifCleaningActive?"notif-cleaning":null,label:e.formatMessage(X.title)},Object(p.a)(v.a,{icon:"bell",active:s,title:e.formatMessage(X.title),onPin:this.handlePin,onMove:this.handleMove,onClick:this.handleHeaderClick,pinned:u,multiColumn:l,localSettings:this.props.localSettings,notifCleaning:!0,notifCleaningActive:this.props.notifCleaningActive,onEnterCleaningMode:this.props.onEnterCleaningMode},void 0,Object(p.a)(E,{})),g,h)},t}(O.a.PureComponent),Object(s.a)(U,"defaultProps",{trackScroll:!0}),x=D))||x)||x}}]);
//# sourceMappingURL=notifications.js.map