text: (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-0d541475"],{"16c7":function(e,t,a){"use strict";var n=a("6ee8"),r=a.n(n);r.a},"6ee8":function(e,t,a){},ea7f:function(e,t,a){"use strict";a.r(t);var n=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("main",[a("section",{staticClass:"jumbotron"},[a("div",{staticClass:"container"},[a("h3",[e._v("Project Chat")]),a("div",{directives:[{name:"chat-scroll",rawName:"v-chat-scroll"}],staticClass:"my-3 p-3 bg-white rounded shadow-sm scroll"},[a("div",{staticClass:"media text pt-3"},[a("div",e._l(e.chats,(function(t){return a("div",{key:t.id,staticClass:"media-body pb-3 mb-0 lh-125"},[a("span",[e._v(e._s(t.value))]),a("span",{staticClass:"text-muted"},[e._v(e._s(t.sender)+", "+e._s(e.makeTimeReadable(t.timestamp)))]),e.user.uname==t.sender?a("a",{staticClass:"btn text-right text-muted",on:{click:function(a){return a.preventDefault(),e.delComment(t.value,t.sender,t.timestamp)}}},[e._v("Delete")]):e._e()])})),0)])]),a("div",{staticClass:"row"},[a("div",{staticClass:"col-12"},[a("form",[a("div",{staticClass:"input-group add-on"},[a("input",{directives:[{name:"model",rawName:"v-model",value:e.newMessage,expression:"newMessage"}],staticClass:"form-control",attrs:{type:"text",id:"newMessage",placeholder:"Send a chat..."},domProps:{value:e.newMessage},on:{input:[function(t){t.target.composing||(e.newMessage=t.target.value)},function(t){return e.checkInput()}]}}),a("div",{staticClass:"input-group-btn"},[a("button",{staticClass:"btn btn-primary",attrs:{disabled:e.disableSend},on:{click:function(t){return t.preventDefault(),e.addComment()}}},[e._v(" Send ")])])])])])])])]),a("hr",{staticClass:"featurette-divider"}),a("footer",{staticClass:"container"},[e._m(0),a("p",[e._v(" © 2020 BU Spark! · "),a("a",[a("router-link",{attrs:{to:{name:"privacy"}}},[e._v("Privacy")])],1)])])])},r=[function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("p",{staticClass:"float-right"},[a("a",{attrs:{href:"#"}},[e._v("Back to top")])])}],s=(a("7db0"),a("b0c0"),a("96cf"),a("1da1")),c=a("c1df"),i=a.n(c),o=a("032d"),u={computed:{user:function(){return this.$store.state.user}},data:function(){return{route:this.$route.path,chats:[],chatBoxID:null,newMessage:null,disableSend:null,members:null,name:this.$route.params.name}},methods:{addComment:function(){var e=this;return Object(s["a"])(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,o["d"].httpsCallable("addProjectChat")({chatID:e.chatBoxID,message:{value:e.newMessage,sender:e.user.uname,timestamp:Date.now()}});case 2:e.newMessage=null;case 3:case"end":return t.stop()}}),t)})))()},delComment:function(e,t,a){var n=this;return Object(s["a"])(regeneratorRuntime.mark((function r(){return regeneratorRuntime.wrap((function(r){while(1)switch(r.prev=r.next){case 0:return r.next=2,o["d"].httpsCallable("deleteProjectChat")({chatID:n.chatBoxID,message:{value:e,sender:t,timestamp:a}});case 2:case"end":return r.stop()}}),r)})))()},checkInput:function(){var e=this;return Object(s["a"])(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:null==e.newMessage||""==e.newMessage?e.disableSend=!0:e.disableSend=!1;case 1:case"end":return t.stop()}}),t)})))()},makeTimeReadable:function(e){return i()(e).format("lll")}},created:function(){var e=this;return Object(s["a"])(regeneratorRuntime.mark((function t(){var a,n,r,s;return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,o["c"].collection("projectchats").where("chatBoxID","array-contains",e.route).get();case 2:return a=t.sent,t.next=5,o["c"].collection("projects").where("name","==",e.name).get();case 5:if(n=t.sent,e.members=n.docs[0].data().members,r=e.members.find((function(t){return t==e.user.uname})),void 0==r){t.next=21;break}if(!a.empty){t.next=15;break}return t.next=12,o["d"].httpsCallable("createProjectChatBox")({chatBoxID:e.route});case 12:location.reload(),t.next=16;break;case 15:e.chatBoxID=a.docs[0].id;case 16:s=o["c"].collection("projectchats").doc(e.chatBoxID),s.onSnapshot((function(t){e.chats=t.data().chats})),e.disableSend=!0,t.next=22;break;case 21:e.$router.push({name:"project",params:{name:e.$route.params.name}});case 22:case"end":return t.stop()}}),t)})))()}},l=u,d=(a("16c7"),a("2877")),m=Object(d["a"])(l,n,r,!1,null,"bbef6bce",null);t["default"]=m.exports}}]);
  //# sourceMappingURL=chunk-0d541475.b090cf8b.js.map