text: (window.webpackJsonp=window.webpackJsonp||[]).push([[0],{17:function(e,t,n){e.exports=n(52)},51:function(e,t,n){},52:function(e,t,n){"use strict";n.r(t);var o=n(0),a=n.n(o),r=n(10),c=n.n(r),i=n(5),s=n(11),l=n(12),d=n(15),m=n(13),u=n(16);function h(){return a.a.createElement("h1",{className:"header"},"Flickr most recent public photos")}function p(e){var t=e.btnFixed,n=e.ascending,o=e.sortPhotos;return a.a.createElement("div",{className:"sort-btn-container ".concat(t?"fixed":"")},n?a.a.createElement("i",{onClick:o,className:"fas fa-sort-alpha-down sort-btn",role:"none"}):a.a.createElement("i",{onClick:o,className:"fas fa-sort-alpha-up sort-btn",role:"none"}))}function f(e){var t=e.photo,n=t.farm,o=t.server,r=t.id,c=t.secret,i=t.title;return a.a.createElement("div",{className:"photo-container"},a.a.createElement("div",{className:"photo-wrapper"},a.a.createElement("img",{className:"photo",src:"https://farm".concat(n,".staticflickr.com/").concat(o,"/").concat(r,"_").concat(c,".jpg"),alt:i})))}function v(e){var t=e.title;return a.a.createElement("div",{className:"title-container"},t&&a.a.createElement("div",{className:"title-wrapper"},a.a.createElement("div",{className:"title"},t)))}function w(e){return a.a.createElement("div",{className:"photos"},e.photos.map(function(e){return a.a.createElement("div",{className:"card-container",key:e.id},a.a.createElement("div",{className:"card-wrapper"},a.a.createElement(f,{photo:e}),a.a.createElement(v,{title:e.title})))}))}var g=n(14);function E(){return a.a.createElement("div",{className:"dotLoader"},a.a.createElement(g.DotLoader,{sizeUnit:"px",size:50,loading:!0}))}var b=function(e){function t(e){var n;return Object(s.a)(this,t),(n=Object(d.a)(this,Object(m.a)(t).call(this,e))).connection=new WebSocket(window.location.origin.replace(/^http/,"ws")),n.onScroll=function(){n.loadMorePhotos(),n.fixSearchBtn()},n.loadMorePhotos=function(){var e=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;window.innerHeight+e>=document.documentElement.offsetHeight-500&&!n.state.isLoading&&n.setState({isLoading:!0},function(){n.connection.send({})})},n.fixSearchBtn=function(){var e=document.querySelector(".header").offsetHeight,t=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;e<=t&&!n.state.btnFixed&&n.setState({btnFixed:!0}),e>t&&n.state.btnFixed&&n.setState({btnFixed:!1})},n.sortPhotos=function(){n.setState(function(e){var t=e.photos.sort(function(t,n){return t.title.toLowerCase()<n.title.toLowerCase()?e.ascending?-1:1:t.title.toLowerCase()>n.title.toLowerCase()?e.ascending?1:-1:0});return{photos:Object(i.a)(t),ascending:!e.ascending}})},n.state={photos:[],isLoading:!1,ascending:!0,btnFixed:!1},n}return Object(u.a)(t,e),Object(l.a)(t,[{key:"componentDidMount",value:function(){var e=this;this.connection.onmessage=function(t){var n=JSON.parse(t.data);e.setState(function(e){var t=n.photo.filter(function(t){for(var n=0;n<e.photos.length;n++)if(t.id===e.photos[n].id)return!1;return!0});return{photos:[].concat(Object(i.a)(e.photos),Object(i.a)(t)),isLoading:!1}})},window.addEventListener("scroll",this.onScroll,!1),this.interval=setInterval(function(){e.connection.send("ping")},25e3)}},{key:"componentWillUnmount",value:function(){window.removeEventListener("scroll",this.onScroll,!1),clearInterval(this.interval)}},{key:"render",value:function(){return a.a.createElement(o.Fragment,null,a.a.createElement(h,null),a.a.createElement(p,{btnFixed:this.state.btnFixed,ascending:this.state.ascending,sortPhotos:this.sortPhotos}),a.a.createElement(w,{photos:this.state.photos}),(0===this.state.photos.length||this.state.isLoading)&&a.a.createElement(E,null))}}]),t}(o.Component);n(51);Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));c.a.render(a.a.createElement(function(){return a.a.createElement(o.Fragment,null,a.a.createElement(b,null))},null),document.getElementById("root")),"serviceWorker"in navigator&&navigator.serviceWorker.ready.then(function(e){e.unregister()})}},[[17,1,2]]]);
  //# sourceMappingURL=main.a7655f0e.chunk.js.map