mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-23 13:33:18 +00:00
1 line
68 KiB
JavaScript
1 line
68 KiB
JavaScript
|
"use strict";(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[7399],{57141:(t,e,a)=>{a.r(e),a.d(e,{default:()=>u});var i=a(5787),r=a(28772),s=a(90198),o=a(25100),n=a(34719),l=a(18011),c=a(74692);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:r.default,intersect:o.default,"dm-placeholder":s.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 r=i.messages.map((function(t){return t.id}));t.max_id=Math.max.apply(Math,d(r)),t.min_id=Math.min.apply(Math,d(r)),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 r=e.threads[e.threadIndex].messages.map((function(t){return t.id}));t.max_id=Math.max.apply(Math,d(r)),t.min_id=Math.min.apply(Math,d(r))})).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=post
|