PageSourceSearch

https://twitter-lite-619.netlify.app/static/js/main.30c23384.chunk.js

js twitter-lite-619.netlify.app collected 2026-10-03 11:33:19 UTC 18,630 bytes, 2 lines download raw bytes

1(this.webpackJsonpclient=this.webpackJsonpclient||[]).push([[0],{235:function(e,t,n){},236:function(e,t,n){"use strict";n.r(t);var a=n(3),r=n(0),s=n(83),c=n.n(s),o=n(21),i=n(208),j=n(17),l=n(45),u=n(202),b={user:null};if(localStorage.getItem("jwtToken")){var d=Object(u.a)(localStorage.getItem("jwtToken"));1e3*d.exp<Date.now()?localStorage.removeItem("jwtToken"):b.user=d}var m=Object(r.createContext)({user:null,login:function(e){},logout:function(){}}),O=function(e,t){switch(t.type){case"LOGIN":return Object(l.a)(Object(l.a)({},e),{},{user:t.payload});case"LOGOUT":return Object(l.a)(Object(l.a)({},e),{},{user:null});default:return e}},h=function(e){var t=Object(r.useReducer)(O,b),n=Object(j.a)(t,2),s=n[0],c=n[1];return Object(a.jsx)(m.Provider,Object(l.a)({value:{user:s.user,login:function(e){localStorage.setItem("jwtToken",e.token),c({type:"LOGIN",payload:e})},logout:function(){localStorage.removeItem("jwtToken"),c({type:"LOGOUT"})}}},e))},x=n(31),p=n(18),g=(n(223),n(256)),f=n(267),v=n(268),C=n(265),y=n(260),w=n(264),I=n(207),k=n(111),D=n.n(k),S=n(266),P=n(115),$=n(161),A=n(61),L=n(35),N=n.n(L);function T(){var e=Object(A.a)(["\n    mutation createComment (\n        $postID: ID!\n        $body: String!\n    ) {\n        createComment (\n            postID: $postID\n            body: $body\n        ) {\n            id\n            commentsCount\n            comments {\n                id\n                body\n                username\n                createdAt\n            }\n        }\n    }\n"]);return T=function(){return e},e}function M(){var e=Object(A.a)(["\n    mutation deleteComment (\n        $postID: ID!\n        $commentID: ID!\n    ) {\n        deleteComment (\n            postID: $postID\n            commentID: $commentID\n        ) {\n            id\n            commentsCount\n            comments {\n                id\n                username\n                body\n                createdAt\n            }\n        }\n    }\n"]);return M=function(){return e},e}function _(){var e=Object(A.a)(["\n    mutation deletePost ($postID: ID!) {\n        deletePost (postID: $postID)\n    }\n"]);return _=function(){return e},e}function E(){var e=Object(A.a)(["\n    query getPost ($postID: ID!) {\n        getPost (postID: $postID) {\n            id\n            username\n            body\n            createdAt\n            likesCount\n            likes {\n                username\n            }\n            commentsCount\n            comments {\n                id\n                username\n                createdAt\n                body\n            }\n        }\n    }\n"]);return E=function(){return e},e}function Q(){var e=Object(A.a)(["\n    mutation toggleLikePost ($postID: ID!) {\n        toggleLikePost (postID: $postID) {\n            id\n            likesCount\n            likes {\n                id\n                username\n            }\n        }\n    }\n"]);return Q=function(){return e},e}function R(){var e=Object(A.a)(["\n    mutation createPost ($body: String!) {\n        createPost (body: $body) {\n            id\n            username\n            createdAt\n            likesCount\n            likes {\n                id\n                username\n                createdAt\n            }\n            commentsCount\n            comments {\n                id\n                username\n                body\n                createdAt\n            }\n        }\n    }\n"]);return R=function(){return e},e}function F(){var e=Object(A.a)(["\nmutation register (\n    $username: String!\n    $email: String!\n    $password: String!\n    $confirmPassword: String!\n) {\n    register (\n        registerInput: {\n            username: $username\n            email: $email\n            password: $password\n            confirmPassword: $confirmPassword\n        }\n    ) {\n        id\n        username\n        email\n        createdAt\n        token\n    }\n}\n"]);return F=function(){return e},e}function G(){var e=Object(A.a)(["\nmutation login (\n    $username: String!\n    $password: String!\n) {\n    login (\n        username: $username\n        password: $password\n    ) {\n        id\n        username\n        email\n        createdAt\n        token\n    }\n}\n"]);return G=function(){return e},e}function H(){var e=Object(A.a)(["\nquery getPosts {\n    getPosts {\n        id\n        username\n        author {\n            email\n            createdAt\n        }
1\n        body\n        createdAt\n        likesCount\n        likes {\n            id\n            username\n        }\n        commentsCount\n        comments {\n            id\n            username\n            body\n        }\n    }\n}\n"]);return H=function(){return e},e}var q=N()(H()),B=N()(G()),z=N()(F()),U=N()(R()),V=N()(Q()),J=N()(E()),W=N()(_()),Y=N()(M()),K=N()(T()),X=n(257);var Z=function(e){var t=e.content,n=e.children,r=e.header;return Object(a.jsx)(X.a,{content:t,trigger:n,inverted:!0,header:r||!1})};var ee=function(e){var t=e.post,n=t.id,s=t.likesCount,c=t.likes,i=e.user,l=Object(r.useState)(!1),u=Object(j.a)(l,2),b=u[0],d=u[1];Object(r.useEffect)((function(){i&&c.find((function(e){return e.username===i.username}))?d(!0):d(!1)}),[i,c]);var m=Object(o.useMutation)(V,{variables:{postID:n}}),O=Object(j.a)(m,1)[0];return Object(a.jsx)(Z,{content:b?"Unlike":"Like",children:Object(a.jsxs)(S.a,{as:"div",labelPosition:"right",children:[i?Object(a.jsx)(S.a,{color:"teal",basic:!b,onClick:O,children:Object(a.jsx)(P.a,{name:"heart"})}):Object(a.jsx)(S.a,{color:"teal",basic:!0,as:x.b,to:"/login",children:Object(a.jsx)(P.a,{name:"heart"})}),Object(a.jsx)($.a,{basic:!0,color:"teal",pointing:"left",children:s})]})})},te=n(160),ne=n(262);var ae=function(e){var t=e.postID,n=e.redirect,s=e.commentID,c=Object(p.f)(),i=Object(r.useState)(!1),l=Object(j.a)(i,2),u=l[0],b=l[1],d=s?Y:W,m=Object(o.useMutation)(d,{variables:{postID:t,commentID:s},update:function(e,t){if(b(!1),!s){var a=e.readQuery({query:q});e.writeQuery({query:q,data:{getPosts:Object(te.a)(a.getPosts.filter((function(e){return e.id!==t.data.deletePost})))}})}n&&c.push("/")}}),O=Object(j.a)(m,1)[0];return Object(a.jsxs)(a.Fragment,{children:[Object(a.jsx)(Z,{content:s?"Delete Comment":"Delete Tweet",children:Object(a.jsx)(S.a,{as:"div",color:"red",floated:"right",onClick:function(){return b(!0)},children:Object(a.jsx)(P.a,{name:"trash alternate outline",style:{margin:0}})})}),Object(a.jsx)(ne.a,{size:"mini",open:u,onCancel:function(){return b(!1)},onConfirm:O})]})};var re=function(e){var t=e.postID,n=e.commentsCount,s=e.handleOnClick,c=Object(r.useContext)(m);return Object(a.jsx)(Z,{content:"Comment on Tweet",children:s&&c.user?Object(a.jsxs)(S.a,{labelPosition:"right",as:"div",onClick:s,children:[Object(a.jsx)(S.a,{color:"blue",basic:!0,children:Object(a.jsx)(P.a,{name:"comments"})}),Object(a.jsx)($.a,{basic:!0,color:"blue",pointing:"left",children:n})]}):Object(a.jsxs)(S.a,{labelPosition:"right",as:x.b,to:c.user?"posts/".concat(t):"/login",children:[Object(a.jsx)(S.a,{color:"blue",basic:!0,children:Object(a.jsx)(P.a,{name:"comments"})}),Object(a.jsx)($.a,{basic:!0,color:"blue",pointing:"left",children:n})]})})};var se=function(e){var t=e.post,n=t.id,s=t.username,c=t.body,o=t.createdAt,i=t.likesCount,j=t.likes,l=t.commentsCount,u=t.author,b=Object(r.useContext)(m);return Object(a.jsxs)(w.a,{fluid:!0,children:[Object(a.jsxs)(w.a.Content,{as:x.b,to:"/posts/".concat(n),children:[Object(a.jsx)(Z,{header:u.email,content:"Joined ".concat(D()(u.createdAt).from()),children:Object(a.jsx)(I.a,{floated:"right",size:"mini",src:"https://avatars.dicebear.com/api/human/".concat(s,".svg")})}),Object(a.jsx)(w.a.Header,{children:s}),Object(a.jsx)(w.a.Meta,{children:D()(o).fromNow()}),Object(a.jsx)(w.a.Description,{children:c})]}),Object(a.jsxs)(w.a.Content,{extra:!0,children:[Object(a.jsx)(ee,{post:{id:n,likesCount:i,likes:j},user:b.user}),Object(a.jsx)(re,{postID:n,commentsCount:l}),b.user&&b.user.username===s&&Object(a.jsx)(ae,{postID:n,redirect:!1})]})]})},ce=n(258),oe=n(254),ie=n(135),je=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0,n=Object(r.useState)(e),a=Object(j.a)(n,2),s=a[0],c=a[1],o=function(e){c(Object(l.a)(Object(l.a)({},s),{},Object(ie.a)({},e.target.name,e.target.value)))},i=function(e){e.preventDefault(),t()};return{inputValues:s,handleOnChange:o,handleOnSubmit:i}};var le=function(){var e=je({body:""},(function(){return d()})),t=e.inputValues,n=e.handleOnChange,s=e.handleOnSubmit,c=Object(r.useState)({}),i=Object(j.a)(c,2),l=i[0],u=i[1],b=Object(o.useMutation)(U,{variables:t,update:function(e,n){var a=e.readQuery({query:q});e.writeQuery({query:q,data:{getPosts:[n.data.createPost].concat(Object(te.a)(a.getPosts))}}),t.body=""},onError:function(e){return u(e.graphQLErrors[0].extensions.errors)}}),d=Object(j.a)(b,1)[0];return Object(a.jsxs)(a.Fragment,{children:[Object(a.jsxs)(ce.a,{onSubmit:s,className:"postForm__formWrapper",children:[Object(a.jsx)("h2",{children:"Say Something!"}
1),Object(a.jsxs)(ce.a.Field,{className:"postForm__textAreaWrapper",children:[Object(a.jsx)(oe.a,{className:"postForm__textArea",rows:2,placeholder:"Hi World!",name:"body",value:t.body,onChange:n}),Object(a.jsx)(S.a,{type:"submit",color:"teal",className:"postForm__submitBtn",children:"Tweet"})]})]}),Object.keys(l).length>0&&Object(a.jsx)("div",{className:"ui error message",children:Object(a.jsx)("ul",{className:"list",children:Object.values(l).map((function(e){return Object(a.jsx)("li",{children:e},e)}))})})]})};var ue=function(){var e=Object(r.useContext)(m),t=Object(o.useQuery)(q),n=t.loading,s=t.data;return Object(a.jsxs)(f.a,{columns:3,children:[e.user?Object(a.jsx)(f.a.Row,{children:Object(a.jsx)(le,{})}):Object(a.jsx)(f.a.Row,{children:Object(a.jsx)("h1",{className:"home__heading",children:"Tweets"})}),Object(a.jsx)(f.a.Row,{children:n?new Array(9).fill(0).map((function(e,t){return Object(a.jsx)(f.a.Column,{style:{marginBottom:30},children:Object(a.jsx)(v.a,{raised:!0,children:Object(a.jsxs)(C.a,{children:[Object(a.jsxs)(C.a.Header,{image:!0,children:[Object(a.jsx)(C.a.Line,{}),Object(a.jsx)(C.a.Line,{})]}),Object(a.jsxs)(C.a.Paragraph,{children:[Object(a.jsx)(C.a.Line,{length:"long"}),Object(a.jsx)(C.a.Line,{length:"medium"}),Object(a.jsx)(C.a.Line,{length:"short"})]})]})})},"".concat((new Date).toISOString()).concat(t))})):Object(a.jsx)(y.a.Group,{children:null===s||void 0===s?void 0:s.getPosts.map((function(e){return Object(a.jsx)(f.a.Column,{style:{marginBottom:"30px"},children:Object(a.jsx)(se,{post:e})},e.id)}))})})]})};var be=function(){var e=Object(r.useContext)(m),t=je({username:"",email:"",password:"",confirmPassword:""},(function(){return x()})),n=t.inputValues,s=t.handleOnChange,c=t.handleOnSubmit,i=Object(r.useState)({}),l=Object(j.a)(i,2),u=l[0],b=l[1],d=Object(p.f)(),O=Object(o.useMutation)(z,{variables:n,update:function(t,n){e.login(n.data.register),d.push("/")},onError:function(e){return b(e.graphQLErrors[0].extensions.errors)}}),h=Object(j.a)(O,2),x=h[0],g=h[1].loading;return Object(a.jsxs)("div",{className:"register",children:[Object(a.jsxs)(ce.a,{onSubmit:c,loading:g,children:[Object(a.jsx)("h1",{children:"Register"}),Object(a.jsx)(ce.a.Input,{type:"text",label:"Username",placeholder:"user_name",name:"username",value:n.username,onChange:s,error:!!u.username}),Object(a.jsx)(ce.a.Input,{type:"email",label:"Email",placeholder:"[email protected]",name:"email",value:n.email,onChange:s,error:!!u.email}),Object(a.jsx)(ce.a.Input,{type:"password",label:"Password",placeholder:"secret123",name:"password",value:n.password,onChange:s,error:!!u.password}),Object(a.jsx)(ce.a.Input,{type:"password",label:"Confirm Password",placeholder:"secret123",name:"confirmPassword",value:n.confirmPassword,onChange:s,error:!!u.password}),Object(a.jsx)(S.a,{type:"submit",primary:!0,children:"Register"})]}),Object.keys(u).length>0&&Object(a.jsx)("div",{className:"ui error message",children:Object(a.jsx)("ul",{className:"list",children:Object.values(u).map((function(e){return Object(a.jsx)("li",{children:e},e)}))})})]})};var de=function(){var e=Object(r.useContext)(m),t=je({username:"",password:""},(function(){return x()})),n=t.inputValues,s=t.handleOnChange,c=t.handleOnSubmit,i=Object(r.useState)({}),l=Object(j.a)(i,2),u=l[0],b=l[1],d=Object(p.f)(),O=Object(o.useMutation)(B,{variables:n,update:function(t,n){e.login(n.data.login),d.push("/")},onError:function(e){return b(e.graphQLErrors[0].extensions.errors)}}),h=Object(j.a)(O,2),x=h[0],g=h[1].loading;return Object(a.jsxs)("div",{className:"register",children:[Object(a.jsxs)(ce.a,{onSubmit:c,loading:g,children:[Object(a.jsx)("h1",{children:"Login"}),Object(a.jsx)(ce.a.Input,{type:"text",label:"Username",placeholder:"user_name",name:"username",value:n.username,onChange:s,error:!!u.username}),Object(a.jsx)(ce.a.Input,{type:"password",label:"Password",placeholder:"secret123",name:"password",value:n.password,onChange:s,error:!!u.password}),Object(a.jsx)(S.a,{type:"submit",primary:!0,children:"Login"})]}),Object.keys(u).length>0&&Object(a.jsx)("div",{className:"ui error message",children:Object(a.jsx)("ul",{className:"list",children:Object.values(u).map((function(e){return Object(a.jsx)("li",{children:e},e)}))})})]})},me=n(259),Oe=function(){var e=Object(r.useContext)(m),t="/"===window.location.pathname?"home":window.location.pathname.substr(1),n=Object(r.useState)(t),s=Object(j.a)(n,2),c=s[0],o=s[1],i=function(e,t){var n=t.name;return o(n)};return Object(a.jsx)("div",{children:e.user?Object(a.jsxs)(me.a,{pointing:!0,secondary:!0,size:"massive",color:"teal",children:[Object(a.jsx)(me.a.Item,{name:e.user.username,active:!0,as:x.b,to:"/"}),Object(a.jsx)(me.a.Menu,{position:"right",children:Object(a.jsx)(me.a.Item,{name:"logout",onClick:e.logout})})]}):Object(a.jsxs)(me.a,{pointing:!0,secondary:!0,size:"massive",color:"teal",children:[Object(a.jsx)(me.a.Item,{name:"home",active:"home"===c,onClick:i,as:x.b,to:"/"}),Object(a.jsxs)(me.a.Menu,{position:"right",children:[Object(a.jsx)(me.a.Item,{name:"login",active:"login"===c,onClick:i,as:x.b,to:"/login"}),Object(a.jsx)(me.a.Item,{name:"register",active:"register"===c,onClick:i,as:x.b,to:"/register"})]})]})})},he=n(209),xe=function(e){var t=e.component,n=Object(he.a)(e,["component"]),s=Object(r.useContext)(m);return Object(a.jsx)(p.b,Object(l.a)(Object(l.a)({},n),{},{render:function(e){return s.user?Object(a.jsx)(p.a,{to:"/"}):Object(a.jsx)(t,Object(l.a)({},e))}}))},pe=n(263),ge=n(255),fe=n(261),ve=n(269);var Ce=function(e){var t=e.match.params.postID,n=Object(r.useContext)(m),s=Object(r.useState)(""),c=Object(j.a)(s,2),i=c[0],l=c[1],u=Object(r.useRef)(null),b=Object(o.useQuery)(J,{variables:{postID:t}}),d=b.loading,O=b.data,h=(O=void 0===O?{}:O).getPost,x=(h=void 0===h?{}:h).id,p=h.body,g=h.username,v=h.createdAt,y=h.likesCount,w=h.likes,I=h.commentsCount,k=h.comments,S=Object(o.useMutation)(K,{variables:{postID:t,body:i},update:function(){l(""),u.current.blur()}}),P=Object(j.a)(S,2),$=P[0],A=P[1].loading;return d?Object(a.jsxs)(f.a,{style:{marginTop:20},children:[Object(a.jsxs)(f.a.Row,{children:[Object(a.jsx)(f.a.Column,{width:3,children:Object(a.jsx)(C.a,{children:Object(a.jsx)(C.a.Image,{style:{height:175,width:150}})})}),Object(a.jsx)(f.a.Column,{width:9,children:Object(a.jsxs)(C.a,{children:[Object(a.jsxs)(C.a.Header,{children:[Object(a.jsx)(C.a.Line,{}),Object(a.jsx)(C.a.Line,{})]}),Object(a.jsxs)(C.a.Paragraph,{children:[Object(a.jsx)(C.a.Line,{length:"full"}),Object(a.jsx)(C.a.Line,{length:"long"}),Object(a.jsx)(C.a.Line,{length:"medium"})]})]})})]}),Object(a.jsxs)(f.a.Row,{children:[Object(a.jsx)(f.a.Column,{width:3}),Object(a.jsx)(f.a.Column,{width:9,children:new Array(5).fill(0).map((function(e,t){return Object(a.jsx)(C.a,{children:Object(a.jsxs)(C.a.Header,{image:!0,children:[Object(a.jsx)(C.a.Line,{}),Object(a.jsx)(C.a.Line,{})]})},"".concat((new Date).toISOString()).concat(t))}))})]})]}):Object(a.jsx)(pe.a.Group,{relaxed:!0,children:Object(a.jsxs)(pe.a,{children:[Object(a.jsx)(pe.a.Image,{src:"https://avatars.dicebear.com/api/human/".concat(g,".svg")}),Object(a.jsxs)(pe.a.Content,{verticalAlign:"middle",children:[Object(a.jsx)(pe.a.Header,{children:n.user&&n.user.username===g?"You Said...":"".concat(g," tweeted...")}),Object(a.jsx)(pe.a.Meta,{children:D()(v).fromNow()}),Object(a.jsx)(pe.a.Description,{children:p}),Object(a.jsx)(ge.a,{}
1),Object(a.jsxs)(pe.a.Extra,{children:[Object(a.jsx)(ee,{post:{id:x,likesCount:y,likes:w},user:n.user}),Object(a.jsx)(re,{commentsCount:I,handleOnClick:function(){return u.current.focus()}}),n.user&&n.user.username===g&&Object(a.jsx)(ae,{postID:x,redirect:!0})]}),Object(a.jsxs)(fe.a.Group,{style:{marginBottom:50},children:[Object(a.jsx)(ve.a,{as:"h3",dividing:!0,children:"Comments"}),n.user&&Object(a.jsx)(ce.a,{loading:A,style:{margin:"20px 0"},children:Object(a.jsxs)("div",{className:"ui action input fluid",children:[Object(a.jsx)("input",{type:"text",placeholder:"comment...",value:i,onChange:function(e){return l(e.target.value)},ref:u}),Object(a.jsx)("button",{type:"submit",className:"ui button teal",disabled:""===i.trim(),onClick:$,children:"Comment"})]})}),k.map((function(e){var r;return Object(a.jsxs)(fe.a,{children:[Object(a.jsx)(fe.a.Avatar,{src:"https://avatars.dicebear.com/api/human/".concat(e.username,".svg")}),Object(a.jsxs)(fe.a.Content,{children:[Object(a.jsx)(fe.a.Author,{children:e.username}),Object(a.jsx)(fe.a.Metadata,{children:D()(e.createdAt).fromNow()}),Object(a.jsx)(fe.a.Text,{children:e.body}),(null===(r=n.user)||void 0===r?void 0:r.username)===e.username&&Object(a.jsx)(fe.a.Actions,{style:{display:"flex"},children:Object(a.jsx)(fe.a.Action,{style:{marginLeft:"auto"},children:Object(a.jsx)(ae,{postID:t,commentID:e.id})})})]})]},e.id)}))]})]})]})})};n(235);var ye=function(){return Object(a.jsx)(x.a,{children:Object(a.jsxs)(g.a,{children:[Object(a.jsx)(Oe,{}),Object(a.jsx)(p.b,{exact:!0,path:"/",component:ue}),Object(a.jsx)(xe,{exact:!0,path:"/register",component:be}),Object(a.jsx)(xe,{exact:!0,path:"/login",component:de}),Object(a.jsx)(p.b,{exact:!0,path:"/posts/:postID",component:Ce})]})})},we=Object(o.createHttpLink)({uri:"https://twitter-lite-619.herokuapp.com/"}),Ie=Object(i.a)((function(){var e=localStorage.getItem("jwtToken");return{headers:{Authorization:e?"Bearer ".concat(e):""}}})),ke=new o.ApolloClient({link:Ie.concat(we),cache:new o.InMemoryCache});c.a.render(Object(a.jsx)(o.ApolloProvider,{client:ke,children:Object(a.jsx)(h,{children:Object(a.jsx)(ye,{})})}),document.getElementById("root"))}},[[236,1,2]]]);
2//# sourceMappingURL=main.30c23384.chunk.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.