pleroma/priv/static/packs/flavours/glitch/async/home_timeline.js
2020-05-20 07:55:14 +02:00

2 lines
No EOL
18 KiB
JavaScript

(window.webpackJsonp=window.webpackJsonp||[]).push([[70],{1272:function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return U}));var a,i,o,s=n(0),c=n(2),r=n(9),u=n(6),l=n(8),d=n(1),m=n(3),p=n.n(m),h=n(21),b=n(216),g=n.n(b),f=n(16),j=n.n(f),v=n(5),O=n.n(v),_=n(41),y=n(25),M=n(7),R=n(18),x=n(99),k=n.n(x),C=n(14),w=n.n(C),A=n(544),N=n(589),I=n(473),E=n.n(I),P=n(35),L=n.n(P);function q(e){return function(){var t,n=Object(u.a)(e);if(S()){var a=Object(u.a)(this).constructor;t=Reflect.construct(n,arguments,a)}else t=n.apply(this,arguments);return Object(r.a)(this,t)}}function S(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}var D=Object(M.f)({close:{id:"lightbox.close",defaultMessage:"Close"},previous:{id:"lightbox.previous",defaultMessage:"Previous"},next:{id:"lightbox.next",defaultMessage:"Next"}}),z=function(e){Object(l.a)(t,e);q(t);function t(){for(var t,n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return t=e.call.apply(e,[this].concat(a))||this,Object(d.a)(Object(c.a)(t),"setRef",(function(e){t.node=e})),Object(d.a)(Object(c.a)(t),"onMentionClick",(function(e,n){!t.context.router||0!==n.button||n.ctrlKey||n.metaKey||(n.preventDefault(),t.context.router.history.push("/accounts/"+e.get("id")))})),Object(d.a)(Object(c.a)(t),"onHashtagClick",(function(e,n){e=e.replace(/^#/,""),!t.context.router||0!==n.button||n.ctrlKey||n.metaKey||(n.preventDefault(),t.context.router.history.push("/timelines/tag/"+e))})),Object(d.a)(Object(c.a)(t),"onStatusClick",(function(e,n){!t.context.router||0!==n.button||n.ctrlKey||n.metaKey||(n.preventDefault(),t.context.router.history.push("/statuses/"+e.get("id")))})),Object(d.a)(Object(c.a)(t),"handleEmojiMouseEnter",(function(e){var t=e.target;t.src=t.getAttribute("data-original")})),Object(d.a)(Object(c.a)(t),"handleEmojiMouseLeave",(function(e){var t=e.target;t.src=t.getAttribute("data-static")})),t}var n=t.prototype;return n.componentDidMount=function(){this._updateLinks(),this._updateEmojis()},n.componentDidUpdate=function(){this._updateLinks(),this._updateEmojis()},n._updateEmojis=function(){var e=this.node;if(e&&!R.a)for(var t=e.querySelectorAll(".custom-emoji"),n=0;n<t.length;n++){var a=t[n];a.classList.contains("status-emoji")||(a.classList.add("status-emoji"),a.addEventListener("mouseenter",this.handleEmojiMouseEnter,!1),a.addEventListener("mouseleave",this.handleEmojiMouseLeave,!1))}},n._updateLinks=function(){var e=this,t=this.node;if(t)for(var n=t.querySelectorAll("a"),a=function(){var t=n[i];if(t.classList.contains("status-link"))return"continue";t.classList.add("status-link");var a=e.props.announcement.get("mentions").find((function(e){return t.href===e.get("url")}));if(a)t.addEventListener("click",e.onMentionClick.bind(e,a),!1),t.setAttribute("title",a.get("acct"));else if("#"===t.textContent[0]||t.previousSibling&&t.previousSibling.textContent&&"#"===t.previousSibling.textContent[t.previousSibling.textContent.length-1])t.addEventListener("click",e.onHashtagClick.bind(e,t.text),!1);else{var o=e.props.announcement.get("statuses").find((function(e){return t.href===e.get("url")}));o&&t.addEventListener("click",e.onStatusClick.bind(e,o),!1),t.setAttribute("title",t.href),t.classList.add("unhandled-link")}t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer")},i=0;i<n.length;++i)a()},n.render=function(){var e=this.props.announcement;return(p.a.createElement("div",{className:"announcements__item__content",ref:this.setRef,dangerouslySetInnerHTML:{__html:e.get("contentHtml")}}))},t}(h.a);Object(d.a)(z,"contextTypes",{router:O.a.object}),Object(d.a)(z,"propTypes",{announcement:j.a.map.isRequired});var T=e.env.CDN_HOST||"",F=function(e){Object(l.a)(t,e);q(t);function t(){return e.apply(this,arguments)||this}return t.prototype.render=function(){var e=this.props,t=e.emoji,n=e.emojiMap,a=e.hovered;if(k.a[t]){var i=k.a[this.props.emoji],o=i.filename,c=i.shortCode,r=c?":"+c+":":"";return Object(s.a)("img",{draggable:"false",className:"emojione",alt:t,title:r,src:T+"/emoji/"+o+".svg"})}if(n.get(t)){var u=R.a||a?n.getIn([t,"url"]):n.getIn([t,"static_url"]),l=":"+t+":";return Object(s.a)("img",{draggable:"false",className:"emojione custom-emoji",alt:l,title:l,src:u})}return null},t}(p.a.PureComponent),H=function(e){Object(l.a)(t,e);q(t);function t(){for(var t,n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return t=e.call.apply(e,[this].concat(a))||this,Object(d.a)(Object(c.a)(t),"state",{hovered:!1}),Object(d.a)(Object(c.a)(t),"handleClick",(function(){var e=t.props,n=e.reaction,a=e.announcementId,i=e.addReaction,o=e.removeReaction;n.get("me")?o(a,n.get("name")):i(a,n.get("name"))})),Object(d.a)(Object(c.a)(t),"handleMouseEnter",(function(){return t.setState({hovered:!0})})),Object(d.a)(Object(c.a)(t),"handleMouseLeave",(function(){return t.setState({hovered:!1})})),t}return t.prototype.render=function(){var e=this.props.reaction,t=e.get("name");return k.a[t]&&(t=k.a[t].shortCode),Object(s.a)("button",{className:w()("reactions-bar__item",{active:e.get("me")}),onClick:this.handleClick,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,title:":"+t+":",style:this.props.style},void 0,Object(s.a)("span",{className:"reactions-bar__item__emoji"},void 0,Object(s.a)(F,{hovered:this.state.hovered,emoji:e.get("name"),emojiMap:this.props.emojiMap})),Object(s.a)("span",{className:"reactions-bar__item__count"},void 0,Object(s.a)(N.a,{value:e.get("count")})))},t}(h.a);Object(d.a)(H,"propTypes",{announcementId:O.a.string.isRequired,reaction:j.a.map.isRequired,addReaction:O.a.func.isRequired,removeReaction:O.a.func.isRequired,emojiMap:j.a.map.isRequired,style:O.a.object});var Y=function(e){Object(l.a)(t,e);q(t);function t(){for(var t,n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return t=e.call.apply(e,[this].concat(a))||this,Object(d.a)(Object(c.a)(t),"handleEmojiPick",(function(e){var n=t.props;(0,n.addReaction)(n.announcementId,e.native.replace(/:/g,""))})),t}var n=t.prototype;return n.willEnter=function(){return{scale:R.p?1:0}},n.willLeave=function(){return{scale:R.p?0:L()(0,{stiffness:170,damping:26})}},n.render=function(){var e=this,t=this.props.reactions.filter((function(e){return e.get("count")>0})),n=t.map((function(e){return{key:e.get("name"),data:e,style:{scale:R.p?1:L()(1,{stiffness:150,damping:13})}}})).toArray();return Object(s.a)(E.a,{styles:n,willEnter:this.willEnter,willLeave:this.willLeave},void 0,(function(n){return Object(s.a)("div",{className:w()("reactions-bar",{"reactions-bar--empty":t.isEmpty()})},void 0,n.map((function(t){var n=t.key,a=t.data,i=t.style;return(Object(s.a)(H,{reaction:a,style:{transform:"scale("+i.scale+")",position:i.scale<.5?"absolute":"static"},announcementId:e.props.announcementId,addReaction:e.props.addReaction,removeReaction:e.props.removeReaction,emojiMap:e.props.emojiMap},n))})),t.size<8&&Object(s.a)(A.a,{onPickEmoji:e.handleEmojiPick,button:Object(s.a)(y.a,{id:"plus"})}))}))},t}(h.a);Object(d.a)(Y,"propTypes",{announcementId:O.a.string.isRequired,reactions:j.a.list.isRequired,addReaction:O.a.func.isRequired,removeReaction:O.a.func.isRequired,emojiMap:j.a.map.isRequired});var K=function(e){Object(l.a)(t,e);q(t);function t(){for(var t,n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return t=e.call.apply(e,[this].concat(a))||this,Object(d.a)(Object(c.a)(t),"state",{unread:!t.props.announcement.get("read")}),t}var n=t.prototype;return n.componentDidUpdate=function(){var e=this.props,t=e.selected,n=e.announcement;t||this.state.unread===!n.get("read")||this.setState({unread:!n.get("read")})},n.render=function(){var e=this.props.announcement,t=this.state.unread,n=e.get("starts_at")&&new Date(e.get("starts_at")),a=e.get("ends_at")&&new Date(e.get("ends_at")),i=new Date,o=n&&a,c=o&&n.getFullYear()===a.getFullYear()&&a.getFullYear()===i.getFullYear(),r=o&&n.getDate()===a.getDate()&&n.getMonth()===a.getMonth()&&n.getFullYear()===a.getFullYear(),u=e.get("all_day");return Object(s.a)("div",{className:"announcements__item"},void 0,Object(s.a)("strong",{className:"announcements__item__range"},void 0,Object(s.a)(M.b,{id:"announcement.announcement",defaultMessage:"Announcement"}),o&&Object(s.a)("span",{},void 0," · ",Object(s.a)(M.a,{value:n,hour12:!1,year:c||n.getFullYear()===i.getFullYear()?void 0:"numeric",month:"short",day:"2-digit",hour:u?void 0:"2-digit",minute:u?void 0:"2-digit"})," - ",Object(s.a)(M.a,{value:a,hour12:!1,year:c||a.getFullYear()===i.getFullYear()?void 0:"numeric",month:r?void 0:"short",day:r?void 0:"2-digit",hour:u?void 0:"2-digit",minute:u?void 0:"2-digit"}))),Object(s.a)(z,{announcement:e}),Object(s.a)(Y,{reactions:e.get("reactions"),announcementId:e.get("id"),addReaction:this.props.addReaction,removeReaction:this.props.removeReaction,emojiMap:this.props.emojiMap}),t&&Object(s.a)("span",{className:"announcements__item__unread"}))},t}(h.a);Object(d.a)(K,"propTypes",{announcement:j.a.map.isRequired,emojiMap:j.a.map.isRequired,addReaction:O.a.func.isRequired,removeReaction:O.a.func.isRequired,intl:O.a.object.isRequired,selected:O.a.bool});var U=Object(M.g)((o=i=function(e){Object(l.a)(t,e);q(t);function t(){for(var t,n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return t=e.call.apply(e,[this].concat(a))||this,Object(d.a)(Object(c.a)(t),"state",{index:0}),Object(d.a)(Object(c.a)(t),"handleChangeIndex",(function(e){t.setState({index:e%t.props.announcements.size})})),Object(d.a)(Object(c.a)(t),"handleNextClick",(function(){t.setState({index:(t.state.index+1)%t.props.announcements.size})})),Object(d.a)(Object(c.a)(t),"handlePrevClick",(function(){t.setState({index:(t.props.announcements.size+t.state.index-1)%t.props.announcements.size})})),t}t.getDerivedStateFromProps=function(e,t){return e.announcements.size>0&&t.index>=e.announcements.size?{index:e.announcements.size-1}:null};var n=t.prototype;return n.componentDidMount=function(){this._markAnnouncementAsRead()},n.componentDidUpdate=function(){this._markAnnouncementAsRead()},n._markAnnouncementAsRead=function(){var e=this.props,t=e.dismissAnnouncement,n=e.announcements,a=this.state.index,i=n.get(a);i.get("read")||t(i.get("id"))},n.render=function(){var e=this,t=this.props,n=t.announcements,a=t.intl,i=this.state.index;return n.isEmpty()?null:Object(s.a)("div",{className:"announcements"},void 0,"mascot && ( ",Object(s.a)("img",{className:"announcements__mastodon",alt:"",draggable:"false",src:R.k})," )",Object(s.a)("div",{className:"announcements__container"},void 0,Object(s.a)(g.a,{animateHeight:!R.p,adjustHeight:R.p,index:i,onChangeIndex:this.handleChangeIndex},void 0,n.map((function(t,n){return Object(s.a)(K,{announcement:t,emojiMap:e.props.emojiMap,addReaction:e.props.addReaction,removeReaction:e.props.removeReaction,intl:a,selected:i===n},t.get("id"))}))),n.size>1&&Object(s.a)("div",{className:"announcements__pagination"},void 0,Object(s.a)(_.a,{disabled:1===n.size,title:a.formatMessage(D.previous),icon:"chevron-left",onClick:this.handlePrevClick,size:13}),Object(s.a)("span",{},void 0,i+1," / ",n.size),Object(s.a)(_.a,{disabled:1===n.size,title:a.formatMessage(D.next),icon:"chevron-right",onClick:this.handleNextClick,size:13}))))},t}(h.a),Object(d.a)(i,"propTypes",{announcements:j.a.list,emojiMap:j.a.map.isRequired,dismissAnnouncement:O.a.func.isRequired,addReaction:O.a.func.isRequired,removeReaction:O.a.func.isRequired,intl:O.a.object.isRequired}),a=o))||a}).call(this,n(50))},726:function(e,t,n){"use strict";var a=n(0),i=(n(3),n(25));t.a=function(e){var t,n=e.id,o=e.count,s=e.className;return(Object(a.a)("i",{className:"icon-with-badge"},void 0,Object(a.a)(i.a,{id:n,fixedWidth:!0,className:s}),o>0&&Object(a.a)("i",{className:"icon-with-badge__badge"},void 0,(t=o)>40?"40+":t)))}},839:function(e,t,n){"use strict";n.r(t),n.d(t,"default",(function(){return q}));var a,i=n(0),o=n(2),s=(n(9),n(6),n(8)),c=n(1),r=n(3),u=n.n(r),l=n(15),d=n(34),m=n(1059),p=n(760),h=n(758),b=n(252),g=n(7),f=n(1101),j=n(1102);var v,O=Object(g.f)({filter_regex:{id:"home.column_settings.filter_regex",defaultMessage:"Filter out by regular expressions"},settings:{id:"home.settings",defaultMessage:"Column settings"}}),_=Object(g.g)(a=function(e){Object(s.a)(n,e);var t;t=n;function n(){return e.apply(this,arguments)||this}return n.prototype.render=function(){var e=this.props,t=e.settings,n=e.onChange,a=e.intl;return(Object(i.a)("div",{},void 0,Object(i.a)("span",{className:"column-settings__section"},void 0,Object(i.a)(g.b,{id:"home.column_settings.basic",defaultMessage:"Basic"})),Object(i.a)("div",{className:"column-settings__row"},void 0,Object(i.a)(f.a,{prefix:"home_timeline",settings:t,settingPath:["shows","reblog"],onChange:n,label:Object(i.a)(g.b,{id:"home.column_settings.show_reblogs",defaultMessage:"Show boosts"})})),Object(i.a)("div",{className:"column-settings__row"},void 0,Object(i.a)(f.a,{prefix:"home_timeline",settings:t,settingPath:["shows","reply"],onChange:n,label:Object(i.a)(g.b,{id:"home.column_settings.show_replies",defaultMessage:"Show replies"})})),Object(i.a)("div",{className:"column-settings__row"},void 0,Object(i.a)(f.a,{prefix:"home_timeline",settings:t,settingPath:["shows","direct"],onChange:n,label:Object(i.a)(g.b,{id:"home.column_settings.show_direct",defaultMessage:"Show DMs"})})),Object(i.a)("span",{className:"column-settings__section"},void 0,Object(i.a)(g.b,{id:"home.column_settings.advanced",defaultMessage:"Advanced"})),Object(i.a)("div",{className:"column-settings__row"},void 0,Object(i.a)(j.a,{prefix:"home_timeline",settings:t,settingPath:["regex","body"],onChange:n,label:a.formatMessage(O.filter_regex)}))))},n}(u.a.PureComponent))||a,y=n(73),M=Object(l.connect)((function(e){return{settings:e.getIn(["settings","home"])}}),(function(e){return{onChange:function(t,n){e(Object(y.c)(["home"].concat(t),n))},onSave:function(){e(Object(y.d)())}}}))(_),R=n(322),x=n(71),k=n(1272),C=n(57),w=n(4),A=Object(C.a)([function(e){return e.get("custom_emojis")}],(function(e){return e.reduce((function(e,t){return e.set(t.get("shortcode"),t)}),Object(w.Map)())})),N=Object(l.connect)((function(e){return{announcements:e.getIn(["announcements","items"]),emojiMap:A(e)}}),(function(e){return{dismissAnnouncement:function(t){return e(Object(x.o)(t))},addReaction:function(t,n){return e(Object(x.m)(t,n))},removeReaction:function(t,n){return e(Object(x.q)(t,n))}}}))(k.a),I=n(14),E=n.n(I),P=n(726);var L=Object(g.f)({title:{id:"column.home",defaultMessage:"Home"},show_announcements:{id:"home.show_announcements",defaultMessage:"Show announcements"},hide_announcements:{id:"home.hide_announcements",defaultMessage:"Hide announcements"}}),q=Object(l.connect)((function(e){return{hasUnread:e.getIn(["timelines","home","unread"])>0,isPartial:e.getIn(["timelines","home","isPartial"]),hasAnnouncements:!e.getIn(["announcements","items"]).isEmpty(),unreadAnnouncements:e.getIn(["announcements","items"]).count((function(e){return!e.get("read")})),showAnnouncements:e.getIn(["announcements","show"])}}))(v=Object(g.g)(v=function(e){Object(s.a)(n,e);var t;t=n;function n(){for(var t,n=arguments.length,a=new Array(n),i=0;i<n;i++)a[i]=arguments[i];return t=e.call.apply(e,[this].concat(a))||this,Object(c.a)(Object(o.a)(t),"handlePin",(function(){var e=t.props,n=e.columnId,a=e.dispatch;a(n?Object(b.h)(n):Object(b.e)("HOME",{}))})),Object(c.a)(Object(o.a)(t),"handleMove",(function(e){var n=t.props,a=n.columnId;(0,n.dispatch)(Object(b.g)(a,e))})),Object(c.a)(Object(o.a)(t),"handleHeaderClick",(function(){t.column.scrollTop()})),Object(c.a)(Object(o.a)(t),"setRef",(function(e){t.column=e})),Object(c.a)(Object(o.a)(t),"handleLoadMore",(function(e){t.props.dispatch(Object(d.u)({maxId:e}))})),Object(c.a)(Object(o.a)(t),"handleToggleAnnouncementsClick",(function(e){e.stopPropagation(),t.props.dispatch(Object(x.r)())})),t}var a=n.prototype;return a.componentDidMount=function(){this.props.dispatch(Object(x.p)()),this._checkIfReloadNeeded(!1,this.props.isPartial)},a.componentDidUpdate=function(e){this._checkIfReloadNeeded(e.isPartial,this.props.isPartial)},a.componentWillUnmount=function(){this._stopPolling()},a._checkIfReloadNeeded=function(e,t){var n=this.props.dispatch;e!==t&&(!e&&t?this.polling=setInterval((function(){n(Object(d.u)())}),3e3):e&&!t&&this._stopPolling())},a._stopPolling=function(){this.polling&&(clearInterval(this.polling),this.polling=null)},a.render=function(){var e=this.props,t=e.intl,n=e.hasUnread,a=e.columnId,o=e.multiColumn,s=e.hasAnnouncements,c=e.unreadAnnouncements,r=e.showAnnouncements,l=!!a,d=null;return s&&(d=Object(i.a)("button",{className:E()("column-header__button",{active:r}),title:t.formatMessage(r?L.hide_announcements:L.show_announcements),"aria-label":t.formatMessage(r?L.hide_announcements:L.show_announcements),"aria-pressed":r?"true":"false",onClick:this.handleToggleAnnouncementsClick},void 0,Object(i.a)(P.a,{id:"bullhorn",count:c}))),u.a.createElement(p.a,{bindToDocument:!o,ref:this.setRef,name:"home",label:t.formatMessage(L.title)},Object(i.a)(h.a,{icon:"home",active:n,title:t.formatMessage(L.title),onPin:this.handlePin,onMove:this.handleMove,onClick:this.handleHeaderClick,pinned:l,multiColumn:o,extraButton:d,appendContent:s&&r&&Object(i.a)(N,{})},void 0,Object(i.a)(M,{})),Object(i.a)(m.a,{trackScroll:!l,scrollKey:"home_timeline-"+a,onLoadMore:this.handleLoadMore,timelineId:"home",emptyMessage:Object(i.a)(g.b,{id:"empty_column.home",defaultMessage:"Your home timeline is empty! Visit {public} or use search to get started and meet other users.",values:{public:Object(i.a)(R.a,{to:"/timelines/public"},void 0,Object(i.a)(g.b,{id:"empty_column.home.public_timeline",defaultMessage:"the public timeline"}))}}),bindToDocument:!o}))},n}(u.a.PureComponent))||v)||v}}]);
//# sourceMappingURL=home_timeline.js.map