1 line
3.4 KiB
JavaScript
1 line
3.4 KiB
JavaScript
(function(f,b,c,d,e,v,g,E,S){"use strict";function w(t,n,r,o){try{return r()}catch(a){return o.error(`[${t}] Failed to apply the "${n}" patch, that surface will be skipped: ${a}`),function(){}}}function N(t,n,r){const o=Object.entries(r).map(function([a,s]){return w(t,a,s,n)});return function(){return o.forEach(function(a){return a()})}}function P(t,n,r=100){let o=!1,a;const s=t();return s?(n(s),{cancel(){}}):(a=setInterval(function(){if(o)return;const i=t();i&&(o=!0,clearInterval(a),n(i))},r),{cancel(){o=!0,a&&clearInterval(a)}})}const p=["none","dms","settings"],I={none:"None",dms:"Direct Messages",settings:"Settings"};let h=function(){};function T(){let t=function(){};const n=P(function(){return d.findByTypeName("YouBarNotificationsButton")},function(r){t=Y(r)});return function(){n.cancel(),t()}}function Y(t){const n=d.findByProps("openUserSettings"),r=d.findByProps("transitionToGuild"),o={dms:g.getAssetIDByName("ChatIcon"),settings:g.getAssetIDByName("SettingsIcon")},a=function(s){s==="dms"?r?.transitionToGuild?.("@me"):s==="settings"&&n?.openUserSettings?.()};return v.instead("type",t,function(s,i){try{const[,D]=e.React.useReducer(function(l){return~l},0);h=function(){return D()};const u=i(...s);if(!u?.props?.children)return u;const L=u.props.children.type,B=u.props.children.props,m=[c.storage.slot1,c.storage.slot2];return e.React.createElement(e.React.Fragment,null,m.map(function(l,H){return l==="none"?null:e.React.createElement(L,{key:`you-bar-plus-${H}`,variant:B?.variant||"tertiary",size:B?.size||"sm",icon:o[l],onPress:function(){return a(l)}})}),u)}catch{return i(...s)}})}const{ScrollView:F,View:O}=e.ReactNative;function U({children:t}){return e.React.createElement(F,{style:{flex:1}},t,e.React.createElement(O,{style:{height:24}}))}const{View:_,Text:A}=e.ReactNative;function V({children:t,style:n}){return e.React.createElement(_,{style:[{marginHorizontal:16,marginVertical:8,padding:10,borderRadius:8,borderWidth:1,borderColor:"rgba(128,128,128,0.25)"},n]},e.React.createElement(A,{style:{fontSize:12.5,lineHeight:18,opacity:.75}},t))}const{FormSection:$,FormRow:k}=S.Forms;function x(t){const n=p.indexOf(t);return p[(n+1)%p.length]}function y({label:t,slotKey:n}){const r=c.storage[n];return e.React.createElement(k,{label:t,subLabel:I[r],onPress:function(){c.storage[n]=x(r),h()}})}function z(){return E.useProxy(c.storage),e.React.useEffect(function(){return function(){return h()}},[]),e.React.createElement(U,null,e.React.createElement(V,null,"YouBar+ adds up to 2 buttons to the YouBar - the row with your avatar and status near the top of the app. Tap a slot below to cycle it through None, Direct Messages, and Settings; the first slot renders on the left. 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(y,{label:"First button",slotKey:"slot1"}),e.React.createElement(y,{label:"Second button",slotKey:"slot2"})))}let R=function(){};var C={onLoad:function(){c.storage.slot1??="dms",c.storage.slot2??="settings",R=N("YouBar+",b.logger,{"YouBar buttons":T})},onUnload:function(){return R()},settings:z};return f.default=C,Object.defineProperty(f,"__esModule",{value:!0}),f})({},vendetta,vendetta.plugin,vendetta.metro,vendetta.metro.common,vendetta.patcher,vendetta.ui.assets,vendetta.storage,vendetta.ui.components);
|