1 line
3.1 KiB
JavaScript
1 line
3.1 KiB
JavaScript
(function(d,B,a,h,e,R,g,b,w){"use strict";function S(t,n,o,i){try{return o()}catch(r){return i.error(`[${t}] Failed to apply the "${n}" patch, that surface will be skipped: ${r}`),function(){}}}function E(t,n,o){const i=Object.entries(o).map(function([r,c]){return S(t,r,c,n)});return function(){return i.forEach(function(r){return r()})}}function P(t,n,o=100){let i=!1,r;const c=t();return c?(n(c),{cancel(){}}):(r=setInterval(function(){if(i)return;const u=t();u&&(i=!0,clearInterval(r),n(u))},o),{cancel(){i=!0,r&&clearInterval(r)}})}let l=function(){};function I(){let t=function(){};const n=P(function(){return h.findByTypeName("YouBarNotificationsButton")},function(o){t=D(o)});return function(){n.cancel(),t()}}function D(t){const n=h.findByProps("openUserSettings"),o=h.findByProps("transitionToGuild"),i=g.getAssetIDByName("ChatIcon"),r=g.getAssetIDByName("SettingsIcon");return R.instead("type",t,function(c,u){try{const[,k]=e.React.useReducer(function(x){return~x},0);l=function(){return k()};const s=u(...c);if(!s?.props?.children)return s;const v=s.props.children.type,f=s.props.children.props;return e.React.createElement(e.React.Fragment,null,a.storage.showDMButton&&e.React.createElement(v,{variant:f?.variant||"tertiary",size:f?.size||"sm",icon:i,onPress:function(){return o?.transitionToGuild?.("@me")}}),a.storage.showSettingsButton&&e.React.createElement(v,{variant:f?.variant||"tertiary",size:f?.size||"sm",icon:r,onPress:function(){return n?.openUserSettings?.()}}),s)}catch{return u(...c)}})}const{ScrollView:F,View:M}=e.ReactNative;function V({children:t}){return e.React.createElement(F,{style:{flex:1}},t,e.React.createElement(M,{style:{height:24}}))}const{View:Y,Text:z}=e.ReactNative;function N({children:t,style:n}){return e.React.createElement(Y,{style:[{marginHorizontal:16,marginVertical:8,padding:10,borderRadius:8,borderWidth:1,borderColor:"rgba(128,128,128,0.25)"},n]},e.React.createElement(z,{style:{fontSize:12.5,lineHeight:18,opacity:.75}},t))}const{FormSection:$,FormSwitchRow:p}=w.Forms;function C(){return b.useProxy(a.storage),e.React.useEffect(function(){return function(){return l()}},[]),e.React.createElement(V,null,e.React.createElement(N,null,"Fork of Purple-EyeZ's YouBar+, ported to Revenge's Vendetta-compat API with a fix for a startup race that could silently skip the button patch for an entire session."),e.React.createElement($,{title:"Buttons"},e.React.createElement(p,{label:"Direct Messages button",subLabel:"Show the DM button in the YouBar",value:!!a.storage.showDMButton,onValueChange:function(t){a.storage.showDMButton=t,l()}}),e.React.createElement(p,{label:"Settings button",subLabel:"Show the Settings button in the YouBar",value:!!a.storage.showSettingsButton,onValueChange:function(t){a.storage.showSettingsButton=t,l()}})))}let y=function(){};var T={onLoad:function(){a.storage.showDMButton??=!1,a.storage.showSettingsButton??=!0,y=E("YouBar+",B.logger,{"YouBar buttons":I})},onUnload:function(){return y()},settings:C};return d.default=T,Object.defineProperty(d,"__esModule",{value:!0}),d})({},vendetta,vendetta.plugin,vendetta.metro,vendetta.metro.common,vendetta.patcher,vendetta.ui.assets,vendetta.storage,vendetta.ui.components);
|