PageSourceSearch

https://andromedaterminal.ru/assets/index-BI-Fv5iK.js

js andromedaterminal.ru collected 2026-10-06 07:00:24 UTC 2,845 bytes, 1 lines download raw bytes

1import{D as h,r as y,A as _,j as i,b as x,B as C,i as E,c as f}from"./index-BzOhS_Ua.js";import{S as I,n as R,o as L,q as N,s as q,t as w}from"./app-body-B3H32O80.js";import{u as V}from"./index-B5TJCvXs.js";const k=()=>{const t=h(_),e=t.visibility.all,s=t.visibility.nobody;return y.useMemo(()=>[{key:"all",label:e},{key:"nobody",label:s}],[e,s])},B="_loader_1q9ee_1",F="_retry_1q9ee_8",T="_alert_1q9ee_31",b={loader:B,retry:F,"retry-button":"_retry-button_1q9ee_18",alert:T},D=({loading:t,error:e,visibility:s,labelledBy:r,saving:o,onRetry:n,onChange:c})=>{const a=h(_),u=k();return t?i.jsx("div",{className:b.loader,role:"status","aria-label":a.loading,children:i.jsx(x,{size:24})}):e?i.jsxs("div",{className:b.retry,children:[i.jsx("span",{className:b.alert,role:"alert",children:a.loadError}),i.jsx("button",{type:"button",className:b["retry-button"],onClick:n,children:a.retry})]}):i.jsx(I,{options:u,optionKey:s,onChange:c,labelledBy:r,busy:o})},O=["all","nobody"],G=t=>O.includes(t),g=t=>{const e=t==null?void 0:t.profile_visibility;if(!G(e))throw new Error(`chat privacy: неизвестное значение profile_visibility: ${String(e)}`);return{profile_visibility:e}};class $ extends C{constructor(){super("chats","/api/v1/participants/me"),this.getPrivacy=this.getPrivacy.bind(this),this.updatePrivacy=this.updatePrivacy.bind(this)}getPrivacy(){return this.handleGet("/privacy").then(g)}updatePrivacy(e){return this.handlePatch({profile_visibility:e},"/privacy").then(g)}}const P=new $,S=t=>{var e,s;return E(t)&&((e=t.response)==null?void 0:e.status)===403&&R((s=t.response.data)==null?void 0:s.error)},H=t=>{const[e,s]=y.useState(null),[r,o]=y.useState(!1),[n,c]=y.useState(!1),[a,u]=y.useState(!1),{loadingStatus:v,refetch:m}=L({requestFn:P.getPrivacy,enabled:t,onSuccess:l=>s(l.profile_visibility),onError:l=>{S(l)&&o(!0)}}),A=l=>{if(n||e===null||e===l)return;const j=e;c(!0),u(!1),s(l),P.updatePrivacy(l).then(d=>s(d.profile_visibility)).catch(d=>{if(console.error(d),s(j),S(d)){o(!0);return}u(!0)}).finally(()=>c(!1))};return{visibility:e,loading:v===f.LOADING,error:v===f.ERROR,notAvailable:r,saving:n,saveFailed:a,reload:m,changeVisibility:A}},z=()=>{const t=N(q),{notAvailable:e,...s}=H(t),r=!t||e;return V(r),{...s,locked:r}},K="_page_3wjus_1",M="_title_3wjus_12",U="_alert_3wjus_19",p={page:K,title:M,alert:U},W=()=>{const t=h(_),e=y.useId(),{locked:s,visibility:r,loading:o,error:n,saving:c,saveFailed:a,reload:u,changeVisibility:v}=z();return s?null:i.jsxs("div",{className:p.page,children:[i.jsx("h2",{className:p.title,children:t.title}),i.jsx(w,{label:t.visibilityLabel,labelId:e,hint:r?t.hint[r]:null,status:a?i.jsx("p",{className:p.alert,role:"alert",children:t.saveError}):null,children:i.jsx(D,{loading:o,error:n,visibility:r,labelledBy:e,saving:c,onRetry:u,onChange:v})})]})};export{W as PrivacySettings};

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.