vd-plugins/NoAutoReplyMention/index.js

2 lines
3.1 KiB
JavaScript
Raw Normal View History

(function(s,b,g,m,e,v,u,w,f,i){"use strict";function x(n,a){if(!(n instanceof a))throw new TypeError("Cannot call a class as a function")}function p(n,a,r){return a in n?Object.defineProperty(n,a,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[a]=r,n}const R=g.findByStoreName("UserStore"),{FormInput:F,FormDivider:h,FormText:I,FormIcon:o,FormRow:E,FormSection:_,FormSwitchRow:B}=w.Forms,y=e.stylesheet.createThemedStyleSheet({avatar:{height:36,width:36,borderRadius:18},button:{marginRight:12}});function S(n){let{callback:a}=n;return e.React.createElement(i.TouchableOpacity,{onPress:a},e.React.createElement(I,{style:y.button},"ADD"))}function T(n){let{onFinish:a}=n;const[r,l]=f.useState(""),d=function(){!isNaN(parseInt(r))&&R.getUser(r)&&!t.exempted.includes(r)&&(t.exempted=[...t.exempted,r],l("")),a()};return e.React.createElement(E,{leading:e.React.createElement(o,{source:u.getAssetIDByName("ic_add_friend")}),label:e.React.createElement(F,{autoFocus:!0,title:"User ID",placeholder:"123456789012345678",value:r,keyboardType:"numeric",onChangeText:function(c){return l(c.replace(/[^0-9]/g,"").trim())},returnKeyType:"done"}),trailing:e.React.createElement(i.TouchableOpacity,{onPress:d},e.React.createElement(o,{source:u.getAssetIDByName("ic_add_24px")}))})}function k(){v.useProxy(t);const[n,a]=f.useState(!1),r=e.NavigationNative.useNavigation();return f.useEffect(function(){r.setOptions({headerRight:function(){return e.React.createElement(S,{callback:function(){return a(!0)}})}})},[]),e.React.createElement(i.ScrollView,null,e.React.createElement(B,{label:"Enable blacklist mode",subLabel:"If enabled, only users in the exempted list will be affected by the plugin.",leading:e.React.createElement(o,{source:u.getAssetIDByName("ic_block")}),value:t.isBlacklistMode,onValueChange:function(l){return t.isBlacklistMode=l}}),e.React.createElement(_,{title:"Exempted Users"},t.exempted?.length>0&&e.React.createElement(i.FlatList,{data:t.exempted,keyExtractor:function(l){return l},renderItem:function(l){let{item:d}=l;const c=R.getUser(d);if(!c)throw new Error("User not found/is not cached");return e.React.createElement(E,{label:c.username,leading:e.React.createElement(i.Image,{style:y.avatar,source:{uri:c.getAvatarURL()}}),trailing:e.React.createElement(i.TouchableOpacity,{onPress:function(){t.exempted=t.exempted.filter(function(D){return D!==d})}},e.React.createElement(o,{source:u.getAssetIDByName("Small"),disableColor:!0}))})},ItemSeparatorComponent:h}),n&&e.React.createElement(e.React.Fragment,null,e.React.createElement(h,null),e.React.createElement(T,{onFinish:function(){return a(!1)}}))))}const t=m.storage,P=g.findByProps("createPendingReply");t.isBlacklistMode??=!1,t.exempted??=[];var U=new function n(){x(this,n),p(this,"settings",k),p(this,"onUnload",b.patcher.before("createPendingReply",P,function(a){let[r]=a;const l=t.exempted.includes(r.message?.author?.id);r.shouldMention&&=t.isBlacklistMode?!l:l}))};return s.default=U,s.settings=t,Object.defineProperty(s,"__esModule",{value:!0}),s})({},vendetta,vendetta.metro,vendetta.plugin,vendetta.metro.common,vendetta.storage,vendetta.ui.assets,vendetta.ui.components,window.React,vendetta.metro.common.ReactNative);