pixelfed/public/js/dms~message.chunk.a69815bfbd4d4598.js

1 line
71 KiB
JavaScript
Raw Normal View History

2023-01-31 06:02:21 +00:00
"use strict";(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[2732],{63744:(t,e,a)=>{a.r(e),a.d(e,{default:()=>u});var i=a(42755),s=a(88231),r=a(33795),o=a(78423),n=a(22583),l=a(64491),c=a(19755);function d(t){return function(t){if(Array.isArray(t))return p(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return p(t,e);var a=Object.prototype.toString.call(t).slice(8,-1);"Object"===a&&t.constructor&&(a=t.constructor.name);if("Map"===a||"Set"===a)return Array.from(t);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return p(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var a=0,i=new Array(e);a<e;a++)i[a]=t[a];return i}const u={props:["accountId"],components:{drawer:i.default,sidebar:s.default,intersect:o.default,"dm-placeholder":r.default,"profile-card":n.default,message:l.default},data:function(){return{isLoaded:!1,profile:void 0,conversationProfile:void 0,isIntersecting:!1,config:window.App.config,hideAvatars:!0,hideTimestamps:!1,largerText:!1,autoRefresh:!1,mutedNotifications:!1,blocked:!1,loaded:!1,page:"read",pages:["browse","add","read"],threads:[],thread:!1,threadIndex:!1,replyText:"",composeUsername:"",uploading:!1,uploadProgress:null,min_id:null,max_id:null,loadingMessages:!1,showLoadMore:!0,showReplyLong:!1,showReplyTooLong:!1,showPrivacyWarning:!0}},mounted:function(){var t=this;this.profile=window._sharedData.user,this.isLoaded=!0;var e=this;axios.get("/api/v1/accounts/"+this.accountId).then((function(e){t.conversationProfile=e.data})),axios.get("/api/direct/thread",{params:{pid:e.accountId}}).then((function(a){e.loaded=!0;var i=a.data;t.thread=i,t.threads=[i],t.threadIndex=0;var s=i.messages.map((function(t){return t.id}));t.max_id=Math.max.apply(Math,d(s)),t.min_id=Math.min.apply(Math,d(s)),t.mutedNotifications=i.muted,t.markAsRead()}));var a=localStorage.getItem("px_dm_options");a&&(a=JSON.parse(a),this.hideAvatars=a.hideAvatars,this.hideTimestamps=a.hideTimestamps,this.largerText=a.largerText)},computed:{showDMPrivacyWarning:{get:function(){return this.$store.state.showDMPrivacyWarning},set:function(t){window.localStorage.removeItem("pf_m2s.dmwarncounter"),this.$store.commit("setShowDMPrivacyWarning",t)}}},watch:{mutedNotifications:function(t){t?axios.post("/api/direct/mute",{id:this.accountId}).then((function(t){})):axios.post("/api/direct/unmute",{id:this.accountId}).then((function(t){})),this.mutedNotifications=t},hideAvatars:function(t){this.hideAvatars=t,this.updateOptions()},hideTimestamps:function(t){this.hideTimestamps=t,this.updateOptions()},largerText:function(t){this.largerText=t,this.updateOptions()},replyText:function(t){return t.length<500&&(this.showReplyLong=!1,this.showReplyTooLong=!1),t.length>500?(this.showReplyLong=!1,void(this.showReplyTooLong=!0)):t.length>450?(this.showReplyTooLong=!1,void(this.showReplyLong=!0)):void 0}},methods:{sendMessage:function(){var t=this,e=this,a=this.replyText;axios.post("/api/direct/create",{to_id:this.threads[this.threadIndex].id,message:a,type:e.isEmoji(a)&&a.length<10?"emoji":"text"}).then((function(a){var i=a.data;e.threads[e.threadIndex].messages.unshift(i);var s=e.threads[e.threadIndex].messages.map((function(t){return t.id}));t.max_id=Math.max.apply(Math,d(s)),t.min_id=Math.min.apply(Math,d(s))})).catch((function(t){403==t.response.status&&(e.blocked=!0,swal("Profile Unavailable","You cannot message this profile at this time.","error"))})),this.replyText=""},truncate:function(t){return _.truncate(t)},deleteMessage:function(t){var e=this;window.confirm("Are you sure you want to delete this message?")&&axios.delete("/api/direct/message",{params:{id:this.thread.messages[t].reportId}}).then((function(a){e.thread.messages.splice(t,1)}))},reportMessage:function(){this.closeCtxMenu();var t="/i/report?type=pos