UNPKG

@r3l/app

Version:
2 lines 12.4 kB
(window.__LOADABLE_LOADED_CHUNKS__=window.__LOADABLE_LOADED_CHUNKS__||[]).push([[42],{"./src/modules/discover/utils.ts":function(e,t,r){"use strict";r.d(t,"b",(function(){return a})),r.d(t,"a",(function(){return i}));var s=r("../../node_modules/@babel/runtime/helpers/toConsumableArray.js"),o=r.n(s),n=[{key:"top",title:"Relevant"},{key:"stake",title:"Hot"},{key:"new",title:"New"},{key:"spam",title:"Spam"},{key:"flagged",title:"Flagged"}],a=function(e){if(e)return n;var t=n.findIndex((function(e){return"flagged"===e.key}));return[].concat(o()(n.slice(0,t)),o()(n.slice(t+1,0)))};function i(e,t){var r=e.match.params.sort;return r&&r!==t.sort?{tabIndex:t.routes.findIndex((function(e){return e.key===r})),routes:n,sort:r}:r?null:{tabIndex:-1,routes:n,sort:r}}},"./src/modules/discover/web/discover.container.js":function(e,t,r){"use strict";r.r(t),r.d(t,"Discover",(function(){return q}));var s=r("../../node_modules/@babel/runtime/helpers/asyncToGenerator.js"),o=r.n(s),n=r("../../node_modules/@babel/runtime/helpers/extends.js"),a=r.n(n),i=r("../../node_modules/@babel/runtime/helpers/classCallCheck.js"),l=r.n(i),u=r("../../node_modules/@babel/runtime/helpers/createClass.js"),c=r.n(u),p=r("../../node_modules/@babel/runtime/helpers/assertThisInitialized.js"),d=r.n(p),h=r("../../node_modules/@babel/runtime/helpers/inherits.js"),f=r.n(h),m=r("../../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"),v=r.n(m),b=r("../../node_modules/@babel/runtime/helpers/getPrototypeOf.js"),y=r.n(b),g=r("../../node_modules/@babel/runtime/helpers/defineProperty.js"),j=r.n(g),k=r("../../node_modules/@babel/runtime/regenerator/index.js"),_=r.n(k),L=r("../../node_modules/react/index.js"),w=r.n(L),O=r("../../node_modules/redux/es/redux.js"),R=r("../../node_modules/react-redux/es/index.js"),S=r("../../node_modules/prop-types/index.js"),P=r.n(S),x=r("../../node_modules/react-router/esm/react-router.js"),C=r("./src/modules/auth/auth.actions.js"),D=r("./src/modules/post/post.actions.js"),M=r("./src/modules/user/user.actions.js"),T=r("./src/modules/navigation/navigation.actions.js"),E=r("./src/modules/listview/web/infScroll.component.js"),I=r("./src/modules/post/web/post.component.js");function N(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,s=y()(e);if(t){var o=y()(this).constructor;r=Reflect.construct(s,arguments,o)}else r=s.apply(this,arguments);return v()(this,r)}}var W=function(e){f()(r,e);var t=N(r);function r(e){var s;return l()(this,r),(s=t.call(this,e)).load=s.load.bind(d()(s)),s.hasMore=!0,s}return c()(r,[{key:"getData",value:function(e,t){return(t?this.props.posts.topics[e][t]:this.props.posts[e])||[]}},{key:"load",value:function(e,t){this.hasMore=e*this.props.pageSize<=t,this.hasMore&&this.props.load(null,null,t)}},{key:"renderDiscover",value:function(e,t){var r=this,s=t?this.props.posts.topics[e][t]:this.props.posts[e],o=this.props.posts.posts;return(s||[]).map((function(t){var s,n=o[t];if(!n)return null;var a=r.props.posts.links[n.metaPost],i=null==n||null===(s=n[e])||void 0===s?void 0:s[0],l=o[i],u=n.repost?r.props.posts.posts[n.repost.post]:null;return w.a.createElement(I.a,{key:t,post:n,link:a,repost:u,comment:l})}))}},{key:"render",value:function(){var e=this,t=this.props,r=t.sort,s=t.tag,o=this.getData(r,s),n=this.renderDiscover(r,s),a=n.length;return w.a.createElement("div",{style:{position:"relative"}},w.a.createElement(E.a,{key:this.props.auth.community,className:"parent",data:o,loadMore:function(t){return e.load(t,a)},hasMore:this.hasMore,style:{position:"relative"}},n))}}]),r}(L.Component);j()(W,"propTypes",{posts:P.a.object,pageSize:P.a.number,load:P.a.func,sort:P.a.string,tag:P.a.string,auth:P.a.object});var B=W,z=r("./src/modules/discover/utils.ts"),A=r("./src/modules/styled/index.ts");function H(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}function U(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?H(Object(r),!0).forEach((function(t){j()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):H(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function K(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,s=y()(e);if(t){var o=y()(this).constructor;r=Reflect.construct(s,arguments,o)}else r=s.apply(this,arguments);return v()(this,r)}}var q=function(e){f()(s,e);var t,r=K(s);function s(e,t){var o;l()(this,s),o=r.call(this,e,t),j()(d()(o),"state",{tabIndex:1,routes:z.b(!0)}),j()(d()(o),"lastRefresh",0),j()(d()(o),"load",(function(e,t,r){var s=o.props,n=s.actions,a=s.auth,i=o.state,l=i.routes,u=i.tabIndex;if(l[u]){var c=a.community;e=e||l[u].key;var p=(t=t||o.props).match.params.tag?[t.match.params.tag]:[],d=r||0;n.getPosts(d,p,e,15,c)}}));var n=o.props.match.params.sort;return n&&(o.state.tabIndex=o.state.routes.findIndex((function(e){return e.key===n}))),o}return c()(s,[{key:"componentDidMount",value:function(){this.props.actions.setScrollTab("discover",this.props.match.params)}},{key:"componentDidUpdate",value:function(e){var t,r,s,o,n,a,i,l=this.props.match.params,u=l.tag,c=l.sort,p=l.community,d=null==e||null===(t=e.match)||void 0===t||null===(r=t.params)||void 0===r?void 0:r.tag,h=null==e||null===(s=e.match)||void 0===s||null===(o=s.params)||void 0===o?void 0:o.sort,f=null==e||null===(n=e.match)||void 0===n||null===(a=n.params)||void 0===a?void 0:a.community;return u===d&&c===h&&p===f||this.props.actions.setScrollTab("discover",this.props.match.params),this.props.refresh&&this.props.refresh>this.lastRefresh?(this.lastRefresh=this.props.refresh,this.load(c,this.props),void(i=!0)):(this.props.auth.user?this.props.auth.user._id:null)===(e.auth.user?e.auth.user._id:null)||i?(u!==e.match.params.tag&&(this.load(c,this.props),i=!0),void(this.props.reload!==e.reload&&(this.load(c,this.props),i=!0))):(this.load(c,this.props),void(i=!0))}},{key:"componentWillUnmount",value:function(){this.props.actions.setScrollTab("discover",{})}},{key:"getLoadedState",value:function(){var e=this.props.posts,t=this.state.routes[this.state.tabIndex].key,r=this.props.match.params.tag,s=r?e.loaded.topics[r]:e.loaded;return null==s?void 0:s[t]}},{key:"render",value:function(){var e=this.state,t=e.routes,r=e.tabIndex;if(!t[r])return null;var s=t[r].key,o=this.props.match.params.tag;return w.a.createElement(A.K,{sx:{pb:4}},w.a.createElement(B,a()({key:"posts"+s+o,sort:s,load:this.load,tag:o,pageSize:15},this.props)))}}],[{key:"fetchData",value:(t=o()(_.a.mark((function e(t,r){var s,o,n,a;return _.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=r.sort,o=r.tag,n=r.community,a=o?[o]:[],e.abrupt("return",t(D.getPosts(0,a,s,15,n)));case 4:case"end":return e.stop()}}),e)}))),function(e,r){return t.apply(this,arguments)})},{key:"getDerivedStateFromProps",value:function(e,t){return z.a(e,t)}}]),s}(L.Component);j()(q,"propTypes",{match:P.a.object,refresh:P.a.number,auth:P.a.object,posts:P.a.object,user:P.a.object,actions:P.a.object,reload:P.a.number});t.default=Object(x.h)(Object(R.b)((function(e){return{auth:e.auth,user:e.user,posts:e.posts,tags:e.tags,investments:e.investments,myPostInv:e.investments.myPostInv,refresh:e.navigation.discover.refresh,reload:e.navigation.reload}}),(function(e){return{actions:Object(O.b)(U(U(U(U({},C),D),M),T),e)}}))(q))},"./src/modules/listview/web/infScroll.component.js":function(e,t,r){"use strict";r.d(t,"a",(function(){return O}));var s=r("../../node_modules/@babel/runtime/helpers/objectWithoutProperties.js"),o=r.n(s),n=r("../../node_modules/@babel/runtime/helpers/classCallCheck.js"),a=r.n(n),i=r("../../node_modules/@babel/runtime/helpers/createClass.js"),l=r.n(i),u=r("../../node_modules/@babel/runtime/helpers/assertThisInitialized.js"),c=r.n(u),p=r("../../node_modules/@babel/runtime/helpers/inherits.js"),d=r.n(p),h=r("../../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js"),f=r.n(h),m=r("../../node_modules/@babel/runtime/helpers/getPrototypeOf.js"),v=r.n(m),b=r("../../node_modules/@babel/runtime/helpers/defineProperty.js"),y=r.n(b),g=r("../../node_modules/react/index.js"),j=r.n(g),k=r("../../node_modules/prop-types/index.js"),_=r.n(k),L=["children","element","hasMore","initialLoad","isReverse","loader","loadMore","pageStart","threshold","useCapture","useWindow","data"];function w(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,s=v()(e);if(t){var o=v()(this).constructor;r=Reflect.construct(s,arguments,o)}else r=s.apply(this,arguments);return f()(this,r)}}var O=function(e){d()(r,e);var t=w(r);function r(e){var s;return a()(this,r),(s=t.call(this,e)).scrollListener=s.scrollListener.bind(c()(s)),s.attachScrollListener=s.attachScrollListener.bind(c()(s)),s}return l()(r,[{key:"componentDidMount",value:function(){this.pageLoaded=this.props.pageStart,this.attachScrollListener(),this.data=this.props.data,this.data&&this.data.length||this.props.loadMore(this.pageLoaded)}},{key:"componentDidUpdate",value:function(){this.data.length!==this.props.data.length&&(this.attachScrollListener(),this.data=this.props.data),!this.props.data.length<this.data.length&&(this.pageLoaded=this.props.pageStart)}},{key:"componentWillUnmount",value:function(){this.detachScrollListener()}},{key:"setDefaultLoader",value:function(e){this.defaultLoader=e}},{key:"detachScrollListener",value:function(){var e=window;!1===this.props.useWindow&&(e=this.scrollComponent.parentNode),e.removeEventListener("scroll",this.scrollListener,this.props.useCapture),e.removeEventListener("resize",this.scrollListener,this.props.useCapture)}},{key:"attachScrollListener",value:function(){if(this.props.hasMore){var e=window;!1===this.props.useWindow&&(e=this.scrollComponent.parentNode),e.addEventListener("scroll",this.scrollListener,this.props.useCapture),e.addEventListener("resize",this.scrollListener,this.props.useCapture),this.props.initialLoad&&this.scrollListener()}}},{key:"scrollListener",value:function(){if(this.props.data&&this.props.data.length){var e,t=this.scrollComponent,r=window;if(this.props.useWindow){var s=void 0!==r.pageYOffset?r.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;e=this.props.isReverse?s:this.calculateTopPosition(t)+(t.offsetHeight-s-window.innerHeight)}else e=this.props.isReverse?t.parentNode.scrollTop:t.scrollHeight-t.parentNode.scrollTop-t.parentNode.clientHeight;e<Number(this.props.threshold)&&(this.detachScrollListener(),"function"==typeof this.props.loadMore&&this.props.loadMore(this.pageLoaded+=1))}}},{key:"calculateTopPosition",value:function(e){return e?e.offsetTop+this.calculateTopPosition(e.offsetParent):0}},{key:"render",value:function(){var e=this,t=this.props,r=t.children,s=t.element,n=t.hasMore,a=(t.initialLoad,t.isReverse,t.loader),i=(t.loadMore,t.pageStart,t.threshold,t.useCapture,t.useWindow,t.data,o()(t,L));return i.ref=function(t){e.scrollComponent=t},j.a.createElement(s,i,r,n&&(a||this.defaultLoader))}}]),r}(g.Component);y()(O,"propTypes",{data:_.a.array}),O.propTypes={element:_.a.string,hasMore:_.a.bool,initialLoad:_.a.bool,isReverse:_.a.bool,loadMore:_.a.func.isRequired,pageStart:_.a.number,threshold:_.a.number,useCapture:_.a.bool,useWindow:_.a.bool,children:_.a.oneOfType([_.a.object,_.a.array]).isRequired,loader:_.a.object},O.defaultProps={element:"div",hasMore:!1,initialLoad:!0,pageStart:0,threshold:250,useWindow:!0,isReverse:!1,useCapture:!1,loader:null}}}]); //# sourceMappingURL=discover-web-discover-container.bundle.88d1d30f5827e1067735.js.map