mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-11 00:54:50 +00:00
1 line
195 KiB
JavaScript
1 line
195 KiB
JavaScript
|
(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[9026],{72233:(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>h});var a=s(79984),o=s(17108),i=s(95002),r=s(13094),n=s(58753),l=s(94559),c=s(19413),d=s(49268),u=s(33457),p=s(52505);function f(t){return function(t){if(Array.isArray(t))return m(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 m(t,e);var s=Object.prototype.toString.call(t).slice(8,-1);"Object"===s&&t.constructor&&(s=t.constructor.name);if("Map"===s||"Set"===s)return Array.from(t);if("Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s))return m(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 m(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,a=new Array(e);s<e;s++)a[s]=t[s];return a}const h={props:{groupId:{type:String},path:{type:String},permalinkMode:{type:Boolean,default:!1},permalinkId:{type:String}},components:{"status-card":a.default,"group-status":i.default,"group-compose":o.default,"group-info-card":r.default,"leave-group":n.default,"search-modal":l.default,"invite-modal":c.default,"group-banner":d.default,"group-header-details":p.default,"group-nav-tabs":u.default},data:function(){return{initalLoad:!1,profile:void 0,group:{},isMember:!1,isAdmin:!1,tab:"feed",requestingMembership:!1,composeText:null,feed:[],ids:[],maxId:null,status:void 0,likes:[],likesPage:1,likesId:void 0,renderIdx:1,atabs:{moderation_count:0,request_count:0}}},created:function(){this.fetchSelf()},methods:{fetchSelf:function(){var t=this;axios.get("/api/v1/accounts/verify_credentials?_pe=1").then((function(e){t.profile=e.data})).catch((function(t){window.location.href="/login?_next="+encodeURIComponent(window.location.href)})).finally((function(){t.fetchGroup()}))},initObservers:function(){},fetchGroup:function(){var t=this;axios.get("/api/v0/groups/"+this.groupId).then((function(e){t.group=e.data,t.isMember=e.data.self.is_member,t.isAdmin=["founder","admin"].includes(e.data.self.role),t.isAdmin&&t.fetchAdminTabs(),t.path?t.isMember&&["about","topics","members","events","media","polls"].includes(t.path)||t.isAdmin&&["insights","moderation"].includes(t.path)?setTimeout((function(){t.tab=t.path,t.initalLoad=!0}),500):(history.pushState(null,null,t.group.url),t.initalLoad=!0):t.initalLoad=!0})).catch((function(t){window.location.href="/groups/unavailable"})).finally((function(){t.fetchFeed()}))},fetchAdminTabs:function(){var t=this;axios.get("/api/v0/groups/"+this.groupId+"/atabs").then((function(e){t.atabs=e.data}))},fetchFeed:function(){var t=this;axios.get("/api/v0/groups/"+this.groupId+"/feed").then((function(e){var s=t;e.data&&e.data.length&&(t.feed=e.data,t.maxId=t.feed[t.feed.length-1].id,e.data.forEach((function(t){-1==s.ids.indexOf(t.id)&&s.ids.push(t.id)}))),t.initObservers()}))},fetchPermalink:function(){var t=this;axios.get("/api/v0/groups/status",{params:{gid:this.groupId,sid:this.permalinkId}}).then((function(e){t.status=e.data,t.status.in_reply_to_id&&(t.status.showCommentDrawer=!0)})).catch((function(e){t.permalinkMode=!1,t.fetchFeed()}))},handleRefresh:function(){this.initialLoad=!1,this.init(),this.renderIdx++},timestampFormat:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],s=new Date(t);return e?s.toDateString()+" · "+s.toLocaleTimeString():s.toDateString()},switchTab:function(t){window.scrollTo(0,0),"feed"==t&&this.permalinkMode&&(this.permalinkMode=!1,this.fetchFeed());var e="feed"==t?this.group.url:this.group.url+"/"+t;history.pushState(t,null,e),this.tab=t},joinGroup:function(){var t=this;this.requestingMembership=!0,axios.post("/api/v0/groups/"+this.groupId+"/join").then((function(e){t.requestingMembership=!1,t.group=e.data,t.fetchGroup(),t.fetchFeed()})).catch((function(e){var s=e.response;422==s.status&&(t.tab="feed",history.pushState("",null,t.group.url),t.requestingMembership=!1,s
|