2020-02-27 08:44:03 +01:00
//META{"name":"EditUsers","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/EditUsers","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/EditUsers/EditUsers.plugin.js"}*//
2018-10-11 10:21:26 +02:00
2020-02-07 15:16:40 +01:00
var EditUsers = ( _ => {
return class EditUsers {
getName ( ) { return "EditUsers" ; }
2019-01-09 12:18:37 +01:00
2020-02-27 11:53:07 +01:00
getVersion ( ) { return "3.7.9" ; }
2019-01-09 12:18:37 +01:00
2020-02-07 15:16:40 +01:00
getAuthor ( ) { return "DevilBro" ; }
2019-01-09 12:18:37 +01:00
2020-02-07 15:16:40 +01:00
getDescription ( ) { return "Allows you to change the icon, name, tag and color of users." ; }
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
constructor ( ) {
this . changelog = {
2020-02-18 11:39:32 +01:00
"added" : [ [ "Custom Status" , "Ever been spoiled by a custom status of a user? You can now set your own local status for ppl or complete remove the status of a user" ] , [ "Custom Status Part 2" , "You can now select your own emoji for the local custom status" ] , [ "Message Color" , "You can now set unique message colors for users" ] ] ,
2020-02-10 08:59:57 +01:00
"fixed" : [ [ "Colored Text" , "Changing a User Color will now properly change the message color if Colored Text is enabled" ] , [ "Message Update" , "Fixed the plugin for the new Message Update" ] ] ,
2020-02-07 15:16:40 +01:00
"improved" : [ [ "New Library Structure & React" , "Restructured my Library and switched to React rendering instead of DOM manipulation" ] ]
} ;
2018-10-11 10:21:26 +02:00
2020-02-07 15:16:40 +01:00
this . patchedModules = {
before : {
HeaderBarContainer : "render" ,
ChannelEditorContainer : "render" ,
ChannelAutoComplete : "render" ,
AutocompleteUserResult : "render" ,
UserPopout : "render" ,
UserProfile : "render" ,
UserInfo : "default" ,
2020-02-08 10:24:25 +01:00
NowPlayingHeader : "Header" ,
2020-02-07 15:16:40 +01:00
VoiceUser : "render" ,
Account : "render" ,
Message : "default" ,
MessageContent : "type" ,
MemberListItem : "render" ,
AuditLog : "render" ,
GuildSettingsEmoji : "render" ,
MemberCard : "render" ,
SettingsInvites : "render" ,
GuildSettingsBans : "render" ,
InvitationCard : "render" ,
2020-02-17 13:16:17 +01:00
PrivateChannel : "render" ,
2020-02-07 15:16:40 +01:00
PrivateChannelRecipientsInvitePopout : "render" ,
QuickSwitchUserResult : "render" ,
SearchPopoutComponent : "render" ,
IncomingCall : "render" ,
PrivateChannelCallParticipants : "render" ,
VideoTile : "render"
} ,
after : {
AutocompleteUserResult : "render" ,
NameTag : "default" ,
UserPopout : "render" ,
2020-02-08 10:24:25 +01:00
NowPlayingHeader : "Header" ,
2020-02-07 15:16:40 +01:00
VoiceUser : "render" ,
Account : "render" ,
MessageHeader : "default" ,
MessageContent : "type" ,
MemberListItem : "render" ,
2020-02-07 19:46:33 +01:00
Mention : "default" ,
2020-02-07 15:16:40 +01:00
UserHook : "render" ,
InvitationCard : "render" ,
InviteModalUserRow : "default" ,
TypingUsers : "render" ,
DirectMessage : "render" ,
PrivateChannel : "render" ,
QuickSwitchUserResult : "render" ,
IncomingCall : "render"
}
} ;
2019-05-26 13:55:26 +02:00
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
initConstructor ( ) {
this . css = `
$ { BDFDB . dotCN . messageusername } : hover > span [ style *= "color" ] {
text - decoration : underline ;
}
$ { BDFDB . dotCN . dmchannel } : hover $ { BDFDB . dotCN . namecontainername } span [ style *= "color" ] {
filter : brightness ( 150 % ) ;
}
$ { BDFDB . dotCNS . userpopoutheadernamewrapper + BDFDB . dotCN . bottag } {
position : relative ;
bottom : 1 px ;
}
$ { BDFDB . dotCNS . dmchannel + BDFDB . dotCN . bottag } {
margin - left : 4 px ;
position : relative ;
bottom : 3 px ;
}
2020-02-07 15:19:51 +01:00
$ { BDFDB . dotCNS . userinfo + BDFDB . dotCN . userinfodiscriminator } {
display : none ;
2020-02-07 15:16:40 +01:00
}
2020-02-07 15:19:51 +01:00
$ { BDFDB . dotCNS . userinfohovered + BDFDB . dotCN . userinfodiscriminator } {
display : block ;
2020-02-07 15:16:40 +01:00
}
` ;
2019-10-17 11:36:34 +02:00
2020-02-07 15:16:40 +01:00
this . defaults = {
settings : {
changeInChatTextarea : { value : true , inner : true , description : "Chat Textarea" } ,
changeInChatWindow : { value : true , inner : true , description : "Messages" } ,
changeInMentions : { value : true , inner : true , description : "Mentions" } ,
changeInVoiceChat : { value : true , inner : true , description : "Voice Channels" } ,
changeInMemberList : { value : true , inner : true , description : "Member List" } ,
changeInRecentDms : { value : true , inner : true , description : "Direct Message Notifications" } ,
changeInDmsList : { value : true , inner : true , description : "Direct Message List" } ,
changeInDmHeader : { value : true , inner : true , description : "Direct Message Header" } ,
changeInDmCalls : { value : true , inner : true , description : "Calls/ScreenShares" } ,
changeInTyping : { value : true , inner : true , description : "Typing List" } ,
changeInFriendList : { value : true , inner : true , description : "Friend List" } ,
changeInInviteList : { value : true , inner : true , description : "Invite List" } ,
changeInActivity : { value : true , inner : true , description : "Activity Page" } ,
changeInUserPopout : { value : true , inner : true , description : "User Popouts" } ,
changeInUserProfile : { value : true , inner : true , description : "User Profile Modal" } ,
changeInAutoComplete : { value : true , inner : true , description : "Autocomplete Menu" } ,
changeInAuditLog : { value : true , inner : true , description : "Audit Log" } ,
changeInEmojiLog : { value : true , inner : true , description : "Emoji Upload Log" } ,
changeInMemberLog : { value : true , inner : true , description : "Member Log" } ,
changeInQuickSwitcher : { value : true , inner : true , description : "Quick Switcher" } ,
changeInSearchPopout : { value : true , inner : true , description : "Search Popout" } ,
changeInUserAccount : { value : true , inner : true , description : "Your Account Information" } ,
changeInAppTitle : { value : true , inner : true , description : "Discord App Title (DMs)" }
}
} ;
2018-10-11 10:21:26 +02:00
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
getSettingsPanel ( ) {
if ( ! window . BDFDB || typeof BDFDB != "object" || ! BDFDB . loaded || ! this . started ) return ;
let settings = BDFDB . DataUtils . get ( this , "settings" ) ;
let settingspanel , settingsitems = [ ] , inneritems = [ ] ;
for ( let key in settings ) ( ! this . defaults . settings [ key ] . inner ? settingsitems : inneritems ) . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsSaveItem , {
className : BDFDB . disCN . marginbottom8 ,
type : "Switch" ,
plugin : this ,
keys : [ "settings" , key ] ,
label : this . defaults . settings [ key ] . description ,
value : settings [ key ]
} ) ) ;
settingsitems . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsPanelInner , {
title : "Change Users in:" ,
first : settingsitems . length == 0 ,
children : inneritems
} ) ) ;
settingsitems . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsItem , {
type : "Button" ,
className : BDFDB . disCN . marginbottom8 ,
color : BDFDB . LibraryComponents . Button . Colors . RED ,
label : "Reset all Users" ,
onClick : _ => {
BDFDB . ModalUtils . confirm ( this , "Are you sure you want to reset all users?" , _ => {
BDFDB . DataUtils . remove ( this , "users" ) ;
this . forceUpdateAll ( ) ;
} ) ;
} ,
children : BDFDB . LanguageUtils . LanguageStrings . RESET
} ) ) ;
return settingspanel = BDFDB . PluginUtils . createSettingsPanel ( this , settingsitems ) ;
2018-10-11 10:21:26 +02:00
}
2020-02-07 15:16:40 +01:00
//legacy
load ( ) { }
start ( ) {
if ( ! window . BDFDB ) window . BDFDB = { myPlugins : { } } ;
if ( window . BDFDB && window . BDFDB . myPlugins && typeof window . BDFDB . myPlugins == "object" ) window . BDFDB . myPlugins [ this . getName ( ) ] = this ;
let libraryScript = document . querySelector ( "head script#BDFDBLibraryScript" ) ;
if ( ! libraryScript || ( performance . now ( ) - libraryScript . getAttribute ( "date" ) ) > 600000 ) {
if ( libraryScript ) libraryScript . remove ( ) ;
libraryScript = document . createElement ( "script" ) ;
libraryScript . setAttribute ( "id" , "BDFDBLibraryScript" ) ;
libraryScript . setAttribute ( "type" , "text/javascript" ) ;
libraryScript . setAttribute ( "src" , "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js" ) ;
libraryScript . setAttribute ( "date" , performance . now ( ) ) ;
libraryScript . addEventListener ( "load" , _ => { this . initialize ( ) ; } ) ;
document . head . appendChild ( libraryScript ) ;
}
else if ( window . BDFDB && typeof BDFDB === "object" && BDFDB . loaded ) this . initialize ( ) ;
this . startTimeout = setTimeout ( _ => {
try { return this . initialize ( ) ; }
catch ( err ) { console . error ( ` %c[ ${ this . getName ( ) } ]%c ` , "color: #3a71c1; font-weight: 700;" , "" , "Fatal Error: Could not initiate plugin! " + err ) ; }
} , 30000 ) ;
2018-10-11 10:21:26 +02:00
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
initialize ( ) {
if ( window . BDFDB && typeof BDFDB === "object" && BDFDB . loaded ) {
if ( this . started ) return ;
BDFDB . PluginUtils . init ( this ) ;
let observer = new MutationObserver ( _ => { this . changeAppTitle ( ) ; } ) ;
BDFDB . ObserverUtils . connect ( this , document . head . querySelector ( "title" ) , { name : "appTitleObserver" , instance : observer } , { childList : true } ) ;
let searchGroupData = BDFDB . ReactUtils . getValue ( BDFDB . ModuleUtils . findByName ( "SearchPopoutComponent" , false ) , "exports.GroupData" ) ;
if ( BDFDB . ObjectUtils . is ( searchGroupData ) ) {
BDFDB . ModuleUtils . patch ( this , searchGroupData . FILTER _FROM , "component" , { after : e => {
if ( typeof e . returnValue . props . renderResult == "function" ) {
let renderResult = e . returnValue . props . renderResult ;
e . returnValue . props . renderResult = ( ... args ) => {
let result = renderResult ( ... args ) ;
this . processSearchPopoutUserResult ( { instance : { props : e . methodArguments [ 0 ] } , returnvalue : result } ) ;
return result ;
2019-10-16 22:18:15 +02:00
}
2019-01-25 11:27:52 +01:00
}
2020-02-07 15:16:40 +01:00
} } ) ;
BDFDB . ModuleUtils . patch ( this , searchGroupData . FILTER _MENTIONS , "component" , { after : e => {
if ( typeof e . returnValue . props . renderResult == "function" ) {
let renderResult = e . returnValue . props . renderResult ;
e . returnValue . props . renderResult = ( ... args ) => {
let result = renderResult ( ... args ) ;
this . processSearchPopoutUserResult ( { instance : { props : e . methodArguments [ 0 ] } , returnvalue : result } ) ;
return result ;
}
2019-01-25 11:27:52 +01:00
}
2020-02-07 15:16:40 +01:00
} } ) ;
}
this . forceUpdateAll ( ) ;
2018-10-11 10:21:26 +02:00
}
2020-02-07 15:16:40 +01:00
else console . error ( ` %c[ ${ this . getName ( ) } ]%c ` , "color: #3a71c1; font-weight: 700;" , "" , "Fatal Error: Could not load BD functions!" ) ;
2018-10-11 10:21:26 +02:00
}
2019-07-18 12:53:00 +02:00
2020-02-07 15:16:40 +01:00
stop ( ) {
if ( window . BDFDB && typeof BDFDB === "object" && BDFDB . loaded ) {
this . stopping = true ;
this . forceUpdateAll ( ) ;
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
BDFDB . PluginUtils . clear ( this ) ;
}
2019-08-29 10:44:05 +02:00
}
2019-06-16 19:30:24 +02:00
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
// begin of own functions
onUserContextMenu ( e ) {
if ( e . instance . props . user ) {
let [ children , index ] = BDFDB . ReactUtils . findChildren ( e . returnvalue , { name : [ "FluxContainer(MessageDeveloperModeGroup)" , "DeveloperModeGroup" ] } ) ;
children . splice ( index > - 1 ? index : children . length , 0 , BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ContextMenuItems . Group , {
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ContextMenuItems . Sub , {
label : this . labels . context _localusersettings _text ,
render : [ BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ContextMenuItems . Group , {
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ContextMenuItems . Item , {
label : this . labels . submenu _usersettings _text ,
action : _ => {
BDFDB . ContextMenuUtils . close ( e . instance ) ;
2020-02-17 11:33:49 +01:00
this . openUserSettingsModal ( e . instance . props . user ) ;
2020-02-07 15:16:40 +01:00
}
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ContextMenuItems . Item , {
label : this . labels . submenu _resetsettings _text ,
disabled : ! BDFDB . DataUtils . load ( this , "users" , e . instance . props . user . id ) ,
action : _ => {
BDFDB . ContextMenuUtils . close ( e . instance ) ;
BDFDB . DataUtils . remove ( this , "users" , e . instance . props . user . id ) ;
this . forceUpdateAll ( ) ;
}
} )
]
} ) ]
} )
]
} ) ) ;
2018-12-22 22:34:45 +01:00
}
2018-10-11 10:21:26 +02:00
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
onSettingsClosed ( ) {
if ( this . SettingsUpdated ) {
delete this . SettingsUpdated ;
this . forceUpdateAll ( ) ;
}
2018-12-22 23:41:25 +01:00
}
2020-02-07 15:16:40 +01:00
processChannelEditorContainer ( e ) {
if ( ! e . instance . props . disabled && e . instance . props . channel && e . instance . props . channel . type == BDFDB . DiscordConstants . ChannelTypes . DM && e . instance . props . type == BDFDB . DiscordConstants . TextareaTypes . NORMAL && BDFDB . DataUtils . get ( this , "settings" , "changeInChatTextarea" ) ) {
let user = BDFDB . LibraryModules . UserStore . getUser ( e . instance . props . channel . recipients [ 0 ] ) ;
if ( user ) {
let data = BDFDB . DataUtils . load ( this , "users" , user . id ) ;
e . instance . props . placeholder = BDFDB . LanguageUtils . LanguageStringsFormat ( "TEXTAREA_PLACEHOLDER" , ` @ ${ data && data . name || user . username } ` ) ;
}
2019-02-07 22:54:50 +01:00
}
}
2020-02-07 15:16:40 +01:00
processChannelAutoComplete ( e ) {
if ( e . instance . state . autocompleteType == "MENTIONS" && BDFDB . ArrayUtils . is ( e . instance . state . autocompletes . users ) && e . instance . props . channel ) {
let lastword = ( e . instance . props . textValue || "" ) . slice ( 1 ) . toLowerCase ( ) ;
let users = BDFDB . DataUtils . load ( this , "users" ) ;
if ( ! users || ! lastword ) return ;
let userarray = [ ] ;
for ( let id in users ) if ( users [ id ] && users [ id ] . name ) {
let user = BDFDB . LibraryModules . UserStore . getUser ( id ) ;
if ( user && ( e . instance . props . channel . recipients . includes ( id ) || ( e . instance . props . channel . guild _id && BDFDB . LibraryModules . MemberStore . getMember ( e . instance . props . channel . guild _id , id ) ) ) ) userarray . push ( Object . assign ( {
lowercasename : users [ id ] . name . toLowerCase ( ) ,
user
} , users [ id ] ) ) ;
}
userarray = BDFDB . ArrayUtils . keySort ( userarray . filter ( n => e . instance . state . autocompletes . users . every ( comp => comp . user . id != n . user . id ) && n . lowercasename . indexOf ( lastword ) != - 1 ) , "lowercasename" ) ;
e . instance . state . autocompletes . users = [ ] . concat ( e . instance . state . autocompletes . users , userarray . map ( n => { return { user : n . user } ; } ) ) . slice ( 0 , BDFDB . DiscordConstants . MAX _AUTOCOMPLETE _RESULTS ) ;
2019-02-07 22:54:50 +01:00
}
}
2020-02-07 15:16:40 +01:00
processAutocompleteUserResult ( e ) {
if ( e . instance . props . user && BDFDB . DataUtils . get ( this , "settings" , "changeInAutoComplete" ) ) {
if ( ! e . returnvalue ) {
e . instance . props . user = this . getUserData ( e . instance . props . user . id ) ;
let data = BDFDB . DataUtils . load ( this , "users" , e . instance . props . user . id ) ;
if ( data && data . name ) e . instance . props . nick = data . name ;
}
else {
let [ children , index ] = BDFDB . ReactUtils . findChildren ( e . returnvalue , { props : [ [ "className" , BDFDB . disCN . marginleft8 ] ] } ) ;
if ( index > - 1 ) this . changeUserColor ( children [ index ] , e . instance . props . user . id ) ;
}
2019-02-07 22:54:50 +01:00
}
}
2020-02-07 15:16:40 +01:00
processHeaderBarContainer ( e ) {
let channel = BDFDB . LibraryModules . ChannelStore . getChannel ( e . instance . props . channelId ) ;
if ( channel && channel . type == BDFDB . DiscordConstants . ChannelTypes . DM && BDFDB . DataUtils . get ( this , "settings" , "changeInDmHeader" ) ) {
let [ children , index ] = BDFDB . ReactUtils . findChildren ( e . instance , { name : "Title" } ) ;
if ( index > - 1 ) {
let recipientId = channel . getRecipientId ( ) ;
children [ index ] . props . children = this . getUserData ( recipientId ) . username ;
this . changeUserColor ( children [ index ] , recipientId ) ;
}
2019-03-28 13:56:12 +01:00
}
}
2020-02-07 15:16:40 +01:00
processNameTag ( e ) {
if ( e . instance . props . user && e . instance . props . className ) {
2020-02-07 19:46:33 +01:00
let change = false , guildId = null , options = { changeBackground : false } , botClass = "" ;
2020-02-07 15:16:40 +01:00
switch ( e . instance . props . className ) {
case BDFDB . disCN . userpopoutheadertagnonickname :
change = BDFDB . DataUtils . get ( this , "settings" , "changeInUserPopout" ) ;
2020-02-07 19:46:33 +01:00
guildId = BDFDB . LibraryModules . LastGuildStore . getGuildId ( ) ;
2020-02-07 15:16:40 +01:00
options . changeBackground = true ;
botClass = BDFDB . disCN . bottagnametag ;
break ;
case BDFDB . disCN . userprofilenametag :
change = BDFDB . DataUtils . get ( this , "settings" , "changeInUserProfile" ) ;
2020-02-07 19:46:33 +01:00
guildId = BDFDB . LibraryModules . LastGuildStore . getGuildId ( ) ;
2020-02-07 15:16:40 +01:00
options . changeBackground = true ;
botClass = BDFDB . disCNS . userprofilebottag + BDFDB . disCN . bottagnametag ;
break ;
case BDFDB . disCN . guildsettingsinviteusername :
change = BDFDB . DataUtils . get ( this , "settings" , "changeInMemberLog" ) ;
break ;
case BDFDB . disCN . userinfodiscordtag :
change = BDFDB . DataUtils . get ( this , "settings" , "changeInFriendList" ) ;
botClass = BDFDB . disCN . bottagnametag ;
break ;
}
if ( change ) {
let [ children , index ] = BDFDB . ReactUtils . findChildren ( e . returnvalue , { props : [ [ "className" , BDFDB . disCN . username ] ] } ) ;
if ( index > - 1 ) this . changeUserColor ( children [ index ] , e . instance . props . user . id , options ) ;
2020-02-07 19:46:33 +01:00
if ( botClass ) this . injectBadge ( e . returnvalue . props . children , e . instance . props . user . id , guildId , 2 , botClass , e . instance . props . invertBotTagColor ) ;
2018-12-22 23:41:25 +01:00
}
2018-12-22 22:34:45 +01:00
}
2018-10-11 10:21:26 +02:00
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
processUserPopout ( e ) {
if ( e . instance . props . user && BDFDB . DataUtils . get ( this , "settings" , "changeInUserPopout" ) ) {
2020-02-08 18:50:11 +01:00
let data = BDFDB . DataUtils . load ( this , "users" , e . instance . props . user . id ) ;
2020-02-07 15:16:40 +01:00
if ( ! e . returnvalue ) {
e . instance . props . user = this . getUserData ( e . instance . props . user . id , true , true ) ;
2020-02-17 13:16:17 +01:00
if ( data ) {
if ( data . name ) {
e . instance . props . nickname = data . name ;
e . instance . props . guildMember = Object . assign ( { } , e . instance . props . guildMember , { nick : data . name } ) ;
}
2020-02-18 11:39:32 +01:00
if ( data . removeStatus || data . status || data . statusEmoji ) e . instance . props . customStatusActivity = this . createCustomStatus ( data ) ;
2020-02-07 15:16:40 +01:00
}
}
else {
2020-02-08 18:50:11 +01:00
if ( data && ( data . color1 || data . color2 || data . tag ) ) {
let [ children , index ] = BDFDB . ReactUtils . findChildren ( e . returnvalue , { props : [ [ "className" , BDFDB . disCN . userpopoutheadernickname ] ] } ) ;
if ( index > - 1 ) {
this . changeUserColor ( children [ index ] , e . instance . props . user . id , { changeBackground : true } ) ;
this . injectBadge ( children , e . instance . props . user . id , BDFDB . LibraryModules . LastGuildStore . getGuildId ( ) , 2 , BDFDB . disCN . bottagnametag , ! ! e . instance . props . activity ) ;
}
2020-02-07 15:16:40 +01:00
}
2019-10-02 09:53:39 +02:00
}
2018-10-11 10:21:26 +02:00
}
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
processUserProfile ( e ) {
2020-02-17 13:16:17 +01:00
if ( e . instance . props . user && BDFDB . DataUtils . get ( this , "settings" , "changeInUserProfile" ) ) {
e . instance . props . user = this . getUserData ( e . instance . props . user . id ) ;
let data = BDFDB . DataUtils . load ( this , "users" , e . instance . props . user . id ) ;
2020-02-18 11:39:32 +01:00
if ( data && ( data . removeStatus || data . status || data . statusEmoji ) ) e . instance . props . customStatusActivity = this . createCustomStatus ( data ) ;
2020-02-17 13:16:17 +01:00
}
2019-02-19 12:09:01 +01:00
}
2020-02-07 15:16:40 +01:00
processUserInfo ( e ) {
2020-02-17 13:16:17 +01:00
if ( e . instance . props . user && BDFDB . DataUtils . get ( this , "settings" , "changeInFriendList" ) ) {
e . instance . props . user = this . getUserData ( e . instance . props . user . id ) ;
if ( BDFDB . ReactUtils . isValidElement ( e . instance . props . subText ) ) {
let data = BDFDB . DataUtils . load ( this , "users" , e . instance . props . user . id ) ;
2020-02-18 11:39:32 +01:00
if ( data && ( data . removeStatus || data . status || data . statusEmoji ) ) {
2020-02-17 13:16:17 +01:00
e . instance . props . subText . props . activities = [ ] . concat ( e . instance . props . subText . props . activities ) . filter ( n => n && n . type != 4 ) ;
let activity = this . createCustomStatus ( data ) ;
if ( activity ) e . instance . props . subText . props . activities . unshift ( activity ) ;
}
}
}
2018-12-22 23:41:25 +01:00
}
2019-01-26 22:45:19 +01:00
2020-02-08 10:24:25 +01:00
processNowPlayingHeader ( e ) {
if ( BDFDB . ObjectUtils . is ( e . instance . props . priorityUser ) && e . instance . props . priorityUser . user && BDFDB . DataUtils . get ( this , "settings" , "changeInFriendList" ) ) {
if ( ! e . returnvalue ) {
let titleIsName = e . instance . props . priorityUser . user . username == e . instance . props . title ;
e . instance . props . priorityUser . user = this . getUserData ( e . instance . props . priorityUser . user . id ) ;
if ( titleIsName ) e . instance . props . title = e . instance . props . priorityUser . user . username ;
}
else {
let [ children , index ] = BDFDB . ReactUtils . findChildren ( e . returnvalue , { name : "Header" } ) ;
if ( index > - 1 ) this . changeUserColor ( children [ index ] , e . instance . props . priorityUser . user . id ) ;
}
}
}
2020-02-07 15:16:40 +01:00
processVoiceUser ( e ) {
if ( e . instance . props . user && BDFDB . DataUtils . get ( this , "settings" , "changeInVoiceChat" ) ) {
if ( ! e . returnvalue ) {
e . instance . props . user = this . getUserData ( e . instance . props . user . id ) ;
let data = BDFDB . DataUtils . load ( this , "users" , e . instance . props . user . id ) ;
if ( data && data . name ) e . instance . props . nick = data . name ;
}
else {
let [ children , index ] = BDFDB . ReactUtils . findChildren ( e . returnvalue , { props : [ [ "className" , BDFDB . disCN . voicename ] ] } ) ;
if ( index > - 1 ) this . changeUserColor ( children [ index ] , e . instance . props . user . id , { modify : e . instance . props } ) ;
}
}
}
2019-09-04 12:34:02 +02:00
2020-02-07 15:16:40 +01:00
processAccount ( e ) {
if ( e . instance . props . currentUser && BDFDB . DataUtils . get ( this , "settings" , "changeInUserAccount" ) ) {
2020-02-17 13:16:17 +01:00
let data = BDFDB . DataUtils . load ( this , "users" , e . instance . props . currentUser . id ) ;
if ( ! e . returnvalue ) {
e . instance . props . currentUser = this . getUserData ( e . instance . props . currentUser . id ) ;
2020-02-18 11:39:32 +01:00
if ( data && ( data . removeStatus || data . status || data . statusEmoji ) ) e . instance . props . customStatusActivity = this . createCustomStatus ( data ) ;
2020-02-17 13:16:17 +01:00
}
2020-02-07 15:16:40 +01:00
else {
2020-02-17 13:16:17 +01:00
if ( data && ( data . color1 || data . color2 ) ) {
let [ children , index ] = BDFDB . ReactUtils . findChildren ( e . returnvalue , { name : "Tooltip" } ) ;
if ( index > - 1 && typeof children [ index ] . props . children == "function" ) {
let renderChildren = children [ index ] . props . children ;
children [ index ] . props . children = ( ... args ) => {
let renderedChildren = renderChildren ( ... args ) ;
let [ children2 , index2 ] = BDFDB . ReactUtils . findChildren ( renderedChildren , { name : "PanelTitle" } ) ;
if ( index2 > - 1 ) this . changeUserColor ( children2 [ index2 ] , e . instance . props . currentUser . id ) ;
return renderedChildren ;
2020-02-07 15:16:40 +01:00
}
2019-08-29 23:23:06 +02:00
}
2018-12-25 16:52:37 +01:00
}
}
}
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
processMessage ( e ) {
let header = e . instance . props . childrenHeader ;
if ( header && header . props && header . props . message ) {
let data = BDFDB . DataUtils . load ( this , "users" , header . props . message . author . id ) ;
if ( data ) {
2020-02-09 12:54:27 +01:00
let message = new BDFDB . DiscordObjects . Message ( Object . assign ( { } , header . props . message , { author : this . getUserData ( header . props . message . author . id ) } ) ) ;
2020-02-07 15:16:40 +01:00
if ( data . name ) message . nick = data . name ;
if ( data . color1 ) message . colorString = BDFDB . ColorUtils . convert ( BDFDB . ObjectUtils . is ( data . color1 ) ? data . color1 [ 0 ] : data . color1 , "HEX" ) ;
2020-02-09 12:54:27 +01:00
header . props . message = message ;
2019-02-16 12:58:25 +01:00
}
2018-12-22 22:34:45 +01:00
}
2020-02-10 08:59:57 +01:00
let content = e . instance . props . childrenMessageContent ;
if ( content && content . type && content . type . type ) {
let data = BDFDB . DataUtils . load ( this , "users" , content . props . message . author . id ) ;
let messageColor = data && ( data . color5 || ( BDFDB . BDUtils . getSettings ( "bda-gs-7" ) && data . color1 ) ) ;
if ( messageColor ) {
let message = new BDFDB . DiscordObjects . Message ( Object . assign ( { } , content . props . message , { author : this . getUserData ( content . props . message . author . id ) } ) ) ;
if ( data . name ) message . nick = data . name ;
message . colorString = BDFDB . ColorUtils . convert ( BDFDB . ObjectUtils . is ( messageColor ) ? messageColor [ 0 ] : messageColor , "HEX" ) ;
content . props . message = message ;
}
}
2018-10-11 10:21:26 +02:00
}
2020-02-07 15:16:40 +01:00
processMessageHeader ( e ) {
if ( e . instance . props . message && BDFDB . DataUtils . get ( this , "settings" , "changeInChatWindow" ) ) {
2020-02-27 11:53:07 +01:00
let [ children , index ] = BDFDB . ReactUtils . findChildren ( e . returnvalue . props . children . slice ( 1 ) , { name : "Popout" } ) ;
if ( index > - 1 ) {
let data = BDFDB . DataUtils . load ( this , "users" , e . instance . props . message . author . id ) ;
if ( data && ( data . color1 || data . color2 ) ) {
if ( children [ index ] && children [ index ] . props && typeof children [ index ] . props . children == "function" ) {
let renderChildren = children [ index ] . props . children ;
children [ index ] . props . children = ( ... args ) => {
let renderedChildren = renderChildren ( ... args ) ;
this . changeUserColor ( renderedChildren , e . instance . props . message . author . id ) ;
return renderedChildren ;
}
2020-02-07 15:16:40 +01:00
}
}
2020-02-27 11:53:07 +01:00
this . injectBadge ( children , e . instance . props . message . author . id , ( BDFDB . LibraryModules . ChannelStore . getChannel ( e . instance . props . message . channel _id ) || { } ) . guild _id , 2 , e . instance . props . compact ? BDFDB . disCN . messagebottagcompact : BDFDB . disCN . messagebottagcozy ) ;
2020-02-07 15:16:40 +01:00
}
2018-10-11 10:21:26 +02:00
}
}
2020-02-07 15:16:40 +01:00
processMessageContent ( e ) {
2020-02-07 19:46:33 +01:00
if ( e . instance . props . message && BDFDB . DataUtils . get ( this , "settings" , "changeInChatWindow" ) ) {
if ( ! e . returnvalue ) {
if ( e . instance . props . message . type != BDFDB . DiscordConstants . MessageTypes . DEFAULT ) {
let message = new BDFDB . DiscordObjects . Message ( Object . assign ( { } , e . instance . props . message , { author : this . getUserData ( e . instance . props . message . author . id ) } ) ) ;
let data = BDFDB . DataUtils . load ( this , "users" , e . instance . props . message . author . id ) ;
if ( data ) {
if ( data . name ) message . nick = data . name ;
if ( data . color1 ) message . colorString = BDFDB . ColorUtils . convert ( BDFDB . ObjectUtils . is ( data . color1 ) ? data . color1 [ 0 ] : data . color1 , "HEX" ) ;
2020-02-07 15:16:40 +01:00
}
2020-02-07 19:46:33 +01:00
e . instance . props . message = message ;
e . instance . props . children . props . message = e . instance . props . message ;
2020-02-07 15:16:40 +01:00
}
}
2020-02-07 19:46:33 +01:00
else {
2020-02-07 15:16:40 +01:00
let data = BDFDB . DataUtils . load ( this , "users" , e . instance . props . message . author . id ) ;
let messageColor = data && ( data . color5 || ( BDFDB . BDUtils . getSettings ( "bda-gs-7" ) && data . color1 ) ) ;
if ( messageColor ) e . returnvalue . props . style = Object . assign ( { } , e . returnvalue . props . style , { color : BDFDB . ColorUtils . convert ( BDFDB . ObjectUtils . is ( messageColor ) ? messageColor [ 0 ] : messageColor , "RGBA" ) } ) ;
}
2018-12-30 09:50:26 +01:00
}
}
2020-02-07 19:46:33 +01:00
processMention ( e ) {
if ( e . instance . props . userId && BDFDB . DataUtils . get ( this , "settings" , "changeInMentions" ) ) {
let data = BDFDB . DataUtils . load ( this , "users" , e . instance . props . userId ) ;
if ( data ) {
if ( data . name ) e . returnvalue . props . children [ 0 ] = "@" + data . name ;
if ( data . color1 ) {
let color1 _0 = BDFDB . ColorUtils . convert ( BDFDB . ObjectUtils . is ( data . color1 ) ? data . color1 [ 0 ] : data . color1 , "RGBA" ) ;
let color0 _1 = BDFDB . ColorUtils . setAlpha ( color1 _0 , 0.1 , "RGBA" ) ;
let color0 _7 = BDFDB . ColorUtils . setAlpha ( color1 _0 , 0.7 , "RGBA" ) ;
e . returnvalue . props . style = Object . assign ( { } , e . returnvalue . props . style , {
background : color0 _1 ,
color : color1 _0
} ) ;
let onMouseEnter = e . returnvalue . props . onMouseEnter || ( _ => { } ) ;
e . returnvalue . props . onMouseEnter = event => {
onMouseEnter ( event ) ;
event . target . style . setProperty ( "background" , color0 _7 , "important" ) ;
event . target . style . setProperty ( "color" , "#FFFFFF" , "important" ) ;
} ;
let onMouseLeave = e . returnvalue . props . onMouseLeave || ( _ => { } ) ;
e . returnvalue . props . onMouseLeave = event => {
onMouseLeave ( event ) ;
event . target . style . setProperty ( "background" , color0 _1 , "important" ) ;
event . target . style . setProperty ( "color" , color1 _0 , "important" ) ;
} ;
}
}
}
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
processMemberListItem ( e ) {
if ( e . instance . props . user && BDFDB . DataUtils . get ( this , "settings" , "changeInMemberList" ) ) {
if ( ! e . returnvalue ) {
e . instance . props . user = this . getUserData ( e . instance . props . user . id ) ;
let data = BDFDB . DataUtils . load ( this , "users" , e . instance . props . user . id ) ;
2020-02-17 13:16:17 +01:00
if ( data ) {
if ( data . name ) e . instance . props . nick = data . name ;
2020-02-18 11:39:32 +01:00
if ( data . removeStatus || data . status || data . statusEmoji ) {
2020-02-17 13:16:17 +01:00
e . instance . props . activities = [ ] . concat ( e . instance . props . activities ) . filter ( n => n . type != 4 ) ;
let activity = this . createCustomStatus ( data ) ;
if ( activity ) e . instance . props . activities . unshift ( activity ) ;
}
}
2019-10-17 11:36:34 +02:00
}
else {
2020-02-07 15:16:40 +01:00
this . changeUserColor ( e . returnvalue . props . name , e . instance . props . user . id , { changeBackground : true } ) ;
2020-02-07 19:46:33 +01:00
this . injectBadge ( BDFDB . ReactUtils . getValue ( e . returnvalue , "props.decorators.props.children" ) , e . instance . props . user . id , BDFDB . LibraryModules . LastGuildStore . getGuildId ( ) , 2 , BDFDB . disCN . bottagmember ) ;
2019-10-17 11:36:34 +02:00
}
2019-03-27 19:18:10 +01:00
}
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
processAuditLog ( e ) {
if ( e . instance . props . log && BDFDB . DataUtils . get ( this , "settings" , "changeInAuditLog" ) ) {
if ( e . instance . props . log . user ) e . instance . props . log . user = this . getUserData ( e . instance . props . log . user . id ) ;
if ( e . instance . props . log . target && e . instance . props . log . targetType == "USER" ) e . instance . props . log . target = this . getUserData ( e . instance . props . log . target . id ) ;
}
}
2019-09-04 12:34:02 +02:00
2020-02-07 15:16:40 +01:00
processUserHook ( e ) {
if ( e . instance . props . user && BDFDB . DataUtils . get ( this , "settings" , "changeInAuditLog" ) ) {
this . changeUserColor ( e . returnvalue . props . children [ 0 ] , e . instance . props . user . id ) ;
2019-08-19 11:17:57 +02:00
}
2020-02-07 15:16:40 +01:00
}
processGuildSettingsEmoji ( e ) {
if ( BDFDB . ArrayUtils . is ( e . instance . props . emojis ) && BDFDB . DataUtils . get ( this , "settings" , "changeInEmojiLog" ) ) {
e . instance . props . emojis = [ ] . concat ( e . instance . props . emojis ) ;
for ( let i in e . instance . props . emojis ) e . instance . props . emojis [ i ] = Object . assign ( { } , e . instance . props . emojis [ i ] , { user : this . getUserData ( e . instance . props . emojis [ i ] . user . id ) } ) ;
2019-08-19 11:17:57 +02:00
}
2020-02-07 15:16:40 +01:00
}
2019-09-04 12:34:02 +02:00
2020-02-07 15:16:40 +01:00
processMemberCard ( e ) {
if ( e . instance . props . user && BDFDB . DataUtils . get ( this , "settings" , "changeInMemberLog" ) ) e . instance . props . user = this . getUserData ( e . instance . props . user . id ) ;
}
2019-09-04 12:34:02 +02:00
2020-02-07 15:16:40 +01:00
processSettingsInvites ( e ) {
if ( BDFDB . ObjectUtils . is ( e . instance . props . invites ) && BDFDB . DataUtils . get ( this , "settings" , "changeInMemberLog" ) ) {
e . instance . props . invites = Object . assign ( { } , e . instance . props . invites ) ;
for ( let id in e . instance . props . invites ) e . instance . props . invites [ id ] = new BDFDB . DiscordObjects . Invite ( Object . assign ( { } , e . instance . props . invites [ id ] , { inviter : this . getUserData ( e . instance . props . invites [ id ] . inviter . id ) } ) ) ;
2019-01-06 19:56:17 +01:00
}
2018-10-11 10:21:26 +02:00
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
processGuildSettingsBans ( e ) {
if ( BDFDB . ObjectUtils . is ( e . instance . props . bans ) && BDFDB . DataUtils . get ( this , "settings" , "changeInMemberLog" ) ) {
e . instance . props . bans = Object . assign ( { } , e . instance . props . bans ) ;
for ( let id in e . instance . props . bans ) e . instance . props . bans [ id ] = Object . assign ( { } , e . instance . props . bans [ id ] , { user : this . getUserData ( e . instance . props . bans [ id ] . user . id ) } ) ;
2019-08-19 11:17:57 +02:00
}
2018-12-22 23:41:25 +01:00
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
processInvitationCard ( e ) {
if ( e . instance . props . user && BDFDB . DataUtils . get ( this , "settings" , "changeInInviteList" ) ) {
if ( ! e . returnvalue ) e . instance . props . user = this . getUserData ( e . instance . props . user . id ) ;
2019-08-19 11:17:57 +02:00
else {
2020-02-07 15:16:40 +01:00
let [ children , index ] = BDFDB . ReactUtils . findChildren ( e . returnvalue , { props : [ [ "className" , BDFDB . disCN . invitemodalinviterowname ] ] } ) ;
if ( index > - 1 ) this . changeUserColor ( children [ index ] , e . instance . props . user . id ) ;
2019-08-19 11:17:57 +02:00
}
2018-12-25 11:53:15 +01:00
}
2020-02-07 15:16:40 +01:00
}
processPrivateChannelRecipientsInvitePopout ( e ) {
if ( BDFDB . ArrayUtils . is ( e . instance . props . results ) && BDFDB . DataUtils . get ( this , "settings" , "changeInInviteList" ) ) {
for ( let result of e . instance . props . results ) result . user = this . getUserData ( result . user . id ) ;
2019-01-06 19:56:17 +01:00
}
2018-12-25 11:53:15 +01:00
}
2019-09-04 12:34:02 +02:00
2020-02-07 15:16:40 +01:00
processInviteModalUserRow ( e ) {
if ( e . instance . props . user && BDFDB . DataUtils . get ( this , "settings" , "changeInInviteList" ) ) {
let [ children , index ] = BDFDB . ReactUtils . findChildren ( e . returnvalue , { props : [ [ "className" , BDFDB . disCN . searchpopoutddmaddnickname ] ] } ) ;
if ( index > - 1 ) this . changeUserColor ( children [ index ] , e . instance . props . user . id ) ;
}
2019-02-07 22:54:50 +01:00
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
processTypingUsers ( e ) {
if ( BDFDB . ObjectUtils . is ( e . instance . props . typingUsers ) && Object . keys ( e . instance . props . typingUsers ) . length && BDFDB . DataUtils . get ( this , "settings" , "changeInTyping" ) ) {
let users = Object . keys ( e . instance . props . typingUsers ) . filter ( id => id != BDFDB . UserUtils . me . id ) . filter ( id => ! BDFDB . LibraryModules . FriendUtils . isBlocked ( id ) ) . map ( id => BDFDB . LibraryModules . UserStore . getUser ( id ) ) . filter ( user => user ) ;
if ( users . length ) {
let [ children , index ] = BDFDB . ReactUtils . findChildren ( e . returnvalue , { props : [ [ "className" , BDFDB . disCN . typingtext ] ] } ) ;
if ( index > - 1 && BDFDB . ArrayUtils . is ( children [ index ] . props . children ) ) for ( let child of children [ index ] . props . children ) if ( child . type == "strong" ) {
let userId = ( users . shift ( ) || { } ) . id ;
if ( userId ) {
2020-02-07 19:46:33 +01:00
let data = BDFDB . DataUtils . load ( this , "users" , userId ) ;
if ( data && data . name ) child . props . children = data . name ;
2020-02-07 15:16:40 +01:00
this . changeUserColor ( child , userId ) ;
}
}
2019-01-06 19:56:17 +01:00
}
2019-01-02 09:58:59 +01:00
}
2018-12-22 23:41:25 +01:00
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
processDirectMessage ( e ) {
if ( e . instance . props . channel && e . instance . props . channel . type == BDFDB . DiscordConstants . ChannelTypes . DM && BDFDB . DataUtils . get ( this , "settings" , "changeInRecentDms" ) ) {
let recipientId = e . instance . props . channel . getRecipientId ( ) ;
let [ children , index ] = BDFDB . ReactUtils . findChildren ( e . returnvalue , { name : "ListItemTooltip" } ) ;
if ( index > - 1 ) children [ index ] . props . text = this . getUserData ( recipientId ) . username ;
[ children , index ] = BDFDB . ReactUtils . findChildren ( e . returnvalue , { name : "NavItem" } ) ;
if ( index > - 1 ) children [ index ] . props . icon = this . getUserAvatar ( recipientId ) ;
}
2019-01-17 23:48:29 +01:00
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
processPrivateChannel ( e ) {
if ( e . instance . props . user && BDFDB . DataUtils . get ( this , "settings" , "changeInDmsList" ) ) {
2020-02-17 13:16:17 +01:00
if ( ! e . returnvalue ) {
let data = BDFDB . DataUtils . load ( this , "users" , e . instance . props . user . id ) ;
2020-02-18 11:39:32 +01:00
if ( data && ( data . removeStatus || data . status || data . statusEmoji ) ) {
2020-02-17 13:16:17 +01:00
e . instance . props . activities = [ ] . concat ( e . instance . props . activities ) . filter ( n => n . type != 4 ) ;
let activity = this . createCustomStatus ( data ) ;
if ( activity ) e . instance . props . activities . unshift ( activity ) ;
}
}
else {
e . returnvalue . props . name = BDFDB . ReactUtils . createElement ( "span" , { children : this . getUserData ( e . instance . props . user . id ) . username } ) ;
this . changeUserColor ( e . returnvalue . props . name , e . instance . props . user . id , { changeBackground : true } ) ;
e . returnvalue . props . name = [ e . returnvalue . props . name ] ;
this . injectBadge ( e . returnvalue . props . name , e . instance . props . user . id , null , 1 ) ;
}
2019-08-19 11:17:57 +02:00
}
2018-12-19 13:44:41 +01:00
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
processQuickSwitchUserResult ( e ) {
if ( e . instance . props . user && BDFDB . DataUtils . get ( this , "settings" , "changeInQuickSwitcher" ) ) {
if ( ! e . returnvalue ) e . instance . props . user = this . getUserData ( e . instance . props . user . id ) ;
2019-08-19 11:17:57 +02:00
else {
2020-02-07 15:16:40 +01:00
let [ children , index ] = BDFDB . ReactUtils . findChildren ( e . returnvalue , { props : [ [ "className" , BDFDB . disCN . quickswitchresultmatch ] ] } ) ;
if ( index > - 1 ) {
let data = BDFDB . DataUtils . load ( this , "users" , e . instance . props . user . id ) ;
if ( data && data . name ) children [ index ] . props . children = data . name ;
this . changeUserColor ( children [ index ] , e . instance . props . user . id , { modify : BDFDB . ObjectUtils . extract ( e . instance . props , "focused" , "unread" , "mentions" ) } ) ;
}
2019-08-19 11:17:57 +02:00
}
2019-01-12 15:07:06 +01:00
}
}
2019-09-04 12:34:02 +02:00
2020-02-07 15:16:40 +01:00
processSearchPopoutComponent ( e ) {
if ( BDFDB . ArrayUtils . is ( BDFDB . ReactUtils . getValue ( e , "instance.props.resultsState.autocompletes" ) ) && BDFDB . DataUtils . get ( this , "settings" , "changeInSearchPopout" ) ) {
for ( let autocomplete of e . instance . props . resultsState . autocompletes ) if ( autocomplete && BDFDB . ArrayUtils . is ( autocomplete . results ) ) for ( let result of autocomplete . results ) if ( result . user ) result . user = this . getUserData ( result . user . id ) ;
2019-08-19 11:17:57 +02:00
}
2018-12-26 09:04:41 +01:00
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
processSearchPopoutUserResult ( e ) {
if ( e . instance . props . result && e . instance . props . result . user && BDFDB . DataUtils . get ( this , "settings" , "changeInSearchPopout" ) ) {
let [ children , index ] = BDFDB . ReactUtils . findChildren ( e . returnvalue , { props : [ [ "className" , BDFDB . disCN . searchpopoutdisplayednick ] ] } ) ;
if ( index > - 1 ) {
let data = BDFDB . DataUtils . load ( this , "users" , e . instance . props . result . user . id ) ;
if ( data && data . name ) children [ index ] . props . children = data . name ;
this . changeUserColor ( children [ index ] , e . instance . props . result . user . id ) ;
2019-08-19 11:17:57 +02:00
}
2019-04-23 08:09:58 +02:00
}
2020-02-07 15:16:40 +01:00
}
processIncomingCall ( e ) {
if ( e . instance . props . channelId && BDFDB . DataUtils . get ( this , "settings" , "changeInDmCalls" ) ) {
let user = BDFDB . LibraryModules . UserStore . getUser ( e . instance . props . channelId ) ;
if ( ! user ) {
let channel = BDFDB . LibraryModules . ChannelStore . getChannel ( e . instance . props . channelId ) ;
if ( channel && channel . type == BDFDB . DiscordConstants . ChannelTypes . DM ) user = BDFDB . LibraryModules . UserStore . getUser ( channel . recipients [ 0 ] ) ;
2019-08-19 11:17:57 +02:00
}
2020-02-07 15:16:40 +01:00
if ( user ) {
if ( ! e . returnvalue ) {
e . instance . props . channelName = this . getUserData ( user . id ) . username ;
e . instance . props . avatarUrl = this . getUserAvatar ( user . id ) ;
}
else {
let [ children , index ] = BDFDB . ReactUtils . findChildren ( e . returnvalue , { props : [ [ "className" , BDFDB . disCN . callmembers ] ] } ) ;
if ( index > - 1 ) this . changeUserColor ( children [ index ] , user . id ) ;
}
2019-08-19 11:17:57 +02:00
}
2019-04-23 08:09:58 +02:00
}
2019-01-01 20:41:27 +01:00
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
processPrivateChannelCallParticipants ( e ) {
if ( BDFDB . ArrayUtils . is ( e . instance . props . participants ) && BDFDB . DataUtils . get ( this , "settings" , "changeInDmCalls" ) ) {
for ( let participant of e . instance . props . participants ) if ( participant && participant . user ) participant . user = this . getUserData ( participant . user . id ) ;
}
2018-10-11 10:21:26 +02:00
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
processVideoTile ( e ) {
if ( e . instance . props . user && BDFDB . DataUtils . get ( this , "settings" , "changeInDmCalls" ) ) e . instance . props . user = this . getUserData ( e . instance . props . user . id ) ;
2019-08-29 10:44:05 +02:00
}
2019-09-04 12:34:02 +02:00
2020-02-07 15:16:40 +01:00
changeAppTitle ( ) {
let channel = BDFDB . LibraryModules . ChannelStore . getChannel ( BDFDB . LibraryModules . LastChannelStore . getChannelId ( ) ) ;
let title = document . head . querySelector ( "title" ) ;
if ( title && channel && channel . type == 1 ) {
let info = BDFDB . LibraryModules . UserStore . getUser ( channel . recipients [ 0 ] ) ;
if ( info ) {
let data = this . getUserData ( info . id , title ) ;
BDFDB . DOMUtils . setText ( title , "@" + ( data . name || info . username ) ) ;
}
}
2019-02-07 22:54:50 +01:00
}
2020-02-07 15:16:40 +01:00
changeUserColor ( parent , userId , options = { } ) {
if ( BDFDB . ReactUtils . isValidElement ( parent ) ) {
let data = BDFDB . DataUtils . load ( this , "users" , userId ) || { } ;
if ( data . color1 || ( data . color2 && options . changeBackground ) ) {
let fontColor = options . modify ? this . chooseColor ( data . color1 , options . modify ) : data . color1 ;
let backgroundColor = options . changeBackground && data . color2 ;
let fontGradient = BDFDB . ObjectUtils . is ( fontColor ) ;
if ( BDFDB . ObjectUtils . is ( parent . props . style ) ) {
delete parent . props . style . color ;
delete parent . props . style . backgroundColor ;
}
parent . props . children = BDFDB . ReactUtils . createElement ( "span" , {
style : {
background : BDFDB . ObjectUtils . is ( backgroundColor ) ? BDFDB . ColorUtils . createGradient ( backgroundColor ) : BDFDB . ColorUtils . convert ( backgroundColor , "RGBA" ) ,
color : fontGradient ? BDFDB . ColorUtils . convert ( fontColor [ 0 ] , "RGBA" ) : BDFDB . ColorUtils . convert ( fontColor , "RGBA" )
} ,
children : fontGradient ? BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TextGradientElement , {
gradient : BDFDB . ColorUtils . createGradient ( fontColor ) ,
children : parent . props . children
} ) : parent . props . children
} ) ;
}
}
2019-08-29 10:44:05 +02:00
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
chooseColor ( color , config = { } ) {
if ( color ) {
if ( BDFDB . ObjectUtils . is ( config ) ) {
if ( config . mentions || config . focused || config . hovered || config . selected || config . unread || config . speaking ) color = BDFDB . ColorUtils . change ( color , 0.5 ) ;
else if ( config . muted || config . locked ) color = BDFDB . ColorUtils . change ( color , - 0.5 ) ;
2019-01-25 11:27:52 +01:00
}
2020-02-07 15:16:40 +01:00
return color ;
}
return null ;
}
getUserData ( userId , change = true , keepName = false ) {
let user = BDFDB . LibraryModules . UserStore . getUser ( userId ) ;
if ( ! user ) return new BDFDB . DiscordObjects . User ( { } ) ;
let data = change && BDFDB . DataUtils . load ( this , "users" , user . id ) ;
if ( data ) {
let newUserObject = { } , nativeObject = new BDFDB . DiscordObjects . User ( user ) ;
for ( let key in nativeObject ) newUserObject [ key ] = nativeObject [ key ] ;
newUserObject . tag = nativeObject . tag ;
newUserObject . createdAt = nativeObject . createdAt ;
newUserObject . username = ! keepName && data . name || nativeObject . username ;
newUserObject . usernameNormalized = ! keepName && data . name && data . name . toLowerCase ( ) || nativeObject . usernameNormalized ;
if ( data . removeIcon ) {
newUserObject . avatar = null ;
newUserObject . avatarURL = null ;
newUserObject . getAvatarURL = _ => { return null ; } ;
2019-01-25 11:27:52 +01:00
}
2020-02-07 15:16:40 +01:00
else if ( data . url ) {
newUserObject . avatar = data . url ;
newUserObject . avatarURL = data . url ;
newUserObject . getAvatarURL = _ => { return data . url ; } ;
2019-01-25 11:27:52 +01:00
}
2020-02-07 15:16:40 +01:00
return newUserObject ;
2019-01-25 11:27:52 +01:00
}
2020-02-07 15:16:40 +01:00
return new BDFDB . DiscordObjects . User ( user ) ;
2019-01-25 11:27:52 +01:00
}
2020-02-07 15:16:40 +01:00
getUserAvatar ( userId , change = true ) {
let user = BDFDB . LibraryModules . UserStore . getUser ( userId ) ;
if ( ! user ) return "" ;
let data = change && BDFDB . DataUtils . load ( this , "users" , user . id ) ;
if ( data ) {
if ( data . removeIcon ) return "" ;
else if ( data . url ) return data . url ;
}
return BDFDB . LibraryModules . IconUtils . getUserAvatarURL ( user ) ;
2019-01-25 11:27:52 +01:00
}
2020-02-07 15:16:40 +01:00
2020-02-07 19:46:33 +01:00
injectBadge ( children , userId , guildId , insertIndex , botClass = "" , inverted = false ) {
2020-02-07 15:16:40 +01:00
if ( ! BDFDB . ArrayUtils . is ( children ) || ! userId ) return ;
let data = BDFDB . DataUtils . load ( this , "users" , userId ) ;
if ( data && data . tag ) {
2020-02-07 19:46:33 +01:00
let memberColor = data . ignoreTagColor && ( BDFDB . LibraryModules . MemberStore . getMember ( guildId , userId ) || { } ) . colorString ;
let fontColor = ! inverted ? data . color4 : ( memberColor || data . color3 ) ;
let backgroundColor = ! inverted ? ( memberColor || data . color3 ) : data . color4 ;
2020-02-07 15:16:40 +01:00
let fontGradient = BDFDB . ObjectUtils . is ( fontColor ) ;
children . splice ( insertIndex , 0 , BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . BotTag , {
className : botClass ,
invertColor : inverted ,
style : {
background : BDFDB . ObjectUtils . is ( backgroundColor ) ? BDFDB . ColorUtils . createGradient ( backgroundColor ) : BDFDB . ColorUtils . convert ( backgroundColor , "RGBA" ) ,
color : fontGradient ? BDFDB . ColorUtils . convert ( fontColor [ 0 ] , "RGBA" ) : BDFDB . ColorUtils . convert ( fontColor , "RGBA" )
} ,
tag : fontGradient ? BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TextGradientElement , {
gradient : BDFDB . ColorUtils . createGradient ( fontColor ) ,
children : data . tag
} ) : data . tag
} ) ) ;
}
}
2020-02-17 13:16:17 +01:00
createCustomStatus ( data ) {
return ! BDFDB . ObjectUtils . is ( data ) || data . removeStatus ? null : {
created _at : ( new Date ( ) ) . getTime ( ) . toString ( ) ,
2020-02-18 11:39:32 +01:00
emoji : data . statusEmoji ,
2020-02-17 13:16:17 +01:00
id : "custom" ,
name : "Custom Status" ,
state : data . status ,
type : 4
}
}
2020-02-07 15:16:40 +01:00
forceUpdateAll ( ) {
this . changeAppTitle ( ) ;
BDFDB . ModuleUtils . forceAllUpdates ( this ) ;
BDFDB . MessageUtils . rerenderAll ( ) ;
2019-01-25 11:27:52 +01:00
}
2019-01-26 22:45:19 +01:00
2020-02-17 13:16:17 +01:00
openUserSettingsModal ( user ) {
let data = BDFDB . DataUtils . load ( this , "users" , user . id ) || { } ;
let member = BDFDB . LibraryModules . MemberStore . getMember ( BDFDB . LibraryModules . LastGuildStore . getGuildId ( ) , user . id ) || { } ;
let activity = BDFDB . LibraryModules . StatusMetaUtils . getApplicationActivity ( user . id ) ;
2020-02-07 15:16:40 +01:00
BDFDB . ModalUtils . open ( this , {
size : "MEDIUM" ,
header : this . labels . modal _header _text ,
2020-02-17 13:16:17 +01:00
subheader : member . nick || user . username ,
2020-02-07 15:16:40 +01:00
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ModalComponents . ModalTabContent , {
tab : this . labels . modal _tabheader1 _text ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormItem , {
title : this . labels . modal _username _text ,
2020-02-17 13:16:17 +01:00
className : BDFDB . disCN . marginbottom20 + " input-username" ,
2020-02-07 15:16:40 +01:00
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TextInput , {
value : data . name ,
2020-02-17 13:16:17 +01:00
placeholder : member . nick || user . username ,
2020-02-07 15:16:40 +01:00
autoFocus : true
} )
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormItem , {
title : this . labels . modal _usertag _text ,
2020-02-17 13:16:17 +01:00
className : BDFDB . disCN . marginbottom20 + " input-usertag" ,
2020-02-07 15:16:40 +01:00
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TextInput , {
value : data . tag
} )
} ) ,
2020-02-17 13:16:17 +01:00
BDFDB . ReactUtils . createElement ( "div" , {
className : BDFDB . disCN . marginbottom20 ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Flex , {
className : BDFDB . disCN . marginbottom8 ,
align : BDFDB . LibraryComponents . Flex . Align . CENTER ,
direction : BDFDB . LibraryComponents . Flex . Direction . HORIZONTAL ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormTitle , {
className : BDFDB . disCN . marginreset ,
tag : BDFDB . LibraryComponents . FormComponents . FormTitle . Tags . H5 ,
children : this . labels . modal _useravatar _text
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsItem , {
className : "input-removeicon" ,
type : "Switch" ,
grow : 0 ,
label : BDFDB . LanguageUtils . LanguageStrings . REMOVE ,
tag : BDFDB . LibraryComponents . FormComponents . FormTitle . Tags . H5 ,
value : data . removeIcon ,
onChange : ( value , instance ) => {
let avatarInputIins = BDFDB . ReactUtils . findOwner ( instance . _reactInternalFiber . return . return , { key : "USERAVATAR" } ) ;
if ( avatarInputIins ) {
delete avatarInputIins . props . success ;
delete avatarInputIins . props . errorMessage ;
avatarInputIins . props . disabled = value ;
BDFDB . ReactUtils . forceUpdate ( avatarInputIins ) ;
}
}
} )
]
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TextInput , {
className : "input-useravatar" ,
key : "USERAVATAR" ,
success : ! data . removeIcon && data . url ,
maxLength : 100000000000000000000 ,
value : data . url ,
placeholder : BDFDB . UserUtils . getAvatar ( user . id ) ,
disabled : data . removeIcon ,
onChange : ( value , instance ) => {
this . checkUrl ( value , instance ) ;
}
} )
]
2020-02-17 11:59:30 +01:00
} ) ,
2020-02-17 13:16:17 +01:00
BDFDB . ReactUtils . createElement ( "div" , {
className : BDFDB . disCN . marginbottom20 ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Flex , {
className : BDFDB . disCN . marginbottom8 ,
align : BDFDB . LibraryComponents . Flex . Align . CENTER ,
direction : BDFDB . LibraryComponents . Flex . Direction . HORIZONTAL ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormTitle , {
className : BDFDB . disCN . marginreset ,
tag : BDFDB . LibraryComponents . FormComponents . FormTitle . Tags . H5 ,
children : BDFDB . LanguageUtils . LanguageStrings . CUSTOM _STATUS
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsItem , {
className : "input-removestatus" ,
type : "Switch" ,
grow : 0 ,
label : BDFDB . LanguageUtils . LanguageStrings . REMOVE ,
tag : BDFDB . LibraryComponents . FormComponents . FormTitle . Tags . H5 ,
value : data . removeStatus ,
onChange : ( value , instance ) => {
2020-02-18 11:39:32 +01:00
let statusInputIns = BDFDB . ReactUtils . findOwner ( instance . _reactInternalFiber . return . return , { key : "USERSTATUS" } ) ;
let statusEmojiInputIns = BDFDB . ReactUtils . findOwner ( instance . _reactInternalFiber . return . return , { key : "USERSTATUSEMOJI" } ) ;
if ( statusInputIns && statusEmojiInputIns ) {
delete statusInputIns . props . success ;
delete statusInputIns . props . errorMessage ;
statusInputIns . props . disabled = value ;
delete statusEmojiInputIns . props . emoji ;
BDFDB . ReactUtils . forceUpdate ( statusInputIns , statusEmojiInputIns ) ;
2020-02-17 13:16:17 +01:00
}
}
} )
]
} ) ,
2020-02-18 11:39:32 +01:00
BDFDB . ReactUtils . createElement ( "div" , {
className : BDFDB . disCN . emojiinputcontainer ,
children : [
BDFDB . ReactUtils . createElement ( "div" , {
className : BDFDB . disCN . emojiinputbuttoncontainer ,
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . EmojiPickerButton , {
className : "input-useremojistatus" ,
key : "USERSTATUSEMOJI" ,
emoji : data . statusEmoji
} )
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TextInput , {
className : "input-userstatus" ,
inputClassName : BDFDB . disCN . emojiinput ,
key : "USERSTATUS" ,
maxLength : 100000000000000000000 ,
value : data . status ,
placeholder : activity && activity . type == 4 && activity . state || "" ,
disabled : data . removeStatus
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Button , {
size : BDFDB . LibraryComponents . Button . Sizes . NONE ,
look : BDFDB . LibraryComponents . Button . Looks . BLANK ,
className : BDFDB . disCN . emojiinputclearbutton ,
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SvgIcon , {
className : BDFDB . disCN . emojiinputclearicon ,
name : BDFDB . LibraryComponents . SvgIcon . Names . CLOSE _CIRCLE
} ) ,
onClick : ( e , instance ) => {
let statusInputIns = BDFDB . ReactUtils . findOwner ( instance . _reactInternalFiber . return . return , { key : "USERSTATUS" } ) ;
let statusEmojiInputIns = BDFDB . ReactUtils . findOwner ( instance . _reactInternalFiber . return . return , { key : "USERSTATUSEMOJI" } ) ;
if ( statusInputIns && statusEmojiInputIns ) {
statusInputIns . props . value = "" ;
delete statusEmojiInputIns . props . emoji ;
BDFDB . ReactUtils . forceUpdate ( statusInputIns , statusEmojiInputIns ) ;
}
}
} )
]
2020-02-17 13:16:17 +01:00
} )
]
2020-02-07 15:16:40 +01:00
} )
]
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ModalComponents . ModalTabContent , {
tab : this . labels . modal _tabheader2 _text ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormItem , {
title : this . labels . modal _colorpicker1 _text ,
className : BDFDB . disCN . marginbottom20 ,
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ColorSwatches , {
color : data . color1 ,
number : 1
} )
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormItem , {
title : this . labels . modal _colorpicker2 _text ,
className : BDFDB . disCN . marginbottom20 ,
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ColorSwatches , {
color : data . color2 ,
number : 2
} )
} )
]
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ModalComponents . ModalTabContent , {
tab : this . labels . modal _tabheader3 _text ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormItem , {
title : this . labels . modal _colorpicker3 _text ,
className : BDFDB . disCN . marginbottom20 ,
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ColorSwatches , {
color : data . color3 ,
number : 3 ,
disabled : data . ignoreTagColor
} )
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormItem , {
title : this . labels . modal _colorpicker4 _text ,
className : BDFDB . disCN . marginbottom20 ,
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ColorSwatches , {
color : data . color4 ,
number : 4 ,
disabled : data . ignoreTagColor
} )
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsItem , {
type : "Switch" ,
className : BDFDB . disCN . marginbottom20 + " input-ignoretagcolor" ,
label : this . labels . modal _ignoretagcolor _text ,
2020-02-17 11:33:49 +01:00
tag : BDFDB . LibraryComponents . FormComponents . FormTitle . Tags . H5 ,
2020-02-07 15:16:40 +01:00
value : data . ignoreTagColor ,
onChange : ( value , instance ) => {
let colorpicker3ins = BDFDB . ReactUtils . findOwner ( instance . _reactInternalFiber . return , { props : [ [ "number" , 3 ] ] } ) ;
let colorpicker4ins = BDFDB . ReactUtils . findOwner ( instance . _reactInternalFiber . return , { props : [ [ "number" , 4 ] ] } ) ;
if ( colorpicker3ins ) colorpicker3ins . setState ( { disabled : value } ) ;
if ( colorpicker4ins ) colorpicker4ins . setState ( { disabled : value } ) ;
}
} )
]
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ModalComponents . ModalTabContent , {
tab : this . labels . modal _tabheader4 _text ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormItem , {
title : this . labels . modal _colorpicker5 _text ,
className : BDFDB . disCN . marginbottom20 ,
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ColorSwatches , {
color : data . color5 ,
pickerConfig : { gradient : false } ,
number : 5
} )
} )
]
} )
] ,
buttons : [ {
contents : BDFDB . LanguageUtils . LanguageStrings . SAVE ,
color : "BRAND" ,
close : true ,
click : modal => {
let olddata = Object . assign ( { } , data ) ;
2020-02-17 13:16:17 +01:00
let userNameInput = modal . querySelector ( ".input-username " + BDFDB . dotCN . input ) ;
let userTagInput = modal . querySelector ( ".input-usertag " + BDFDB . dotCN . input ) ;
let userAvatarInput = modal . querySelector ( ".input-useravatar " + BDFDB . dotCN . input ) ;
let removeIconInput = modal . querySelector ( ".input-removeicon " + BDFDB . dotCN . switchinner ) ;
let userStatusInput = modal . querySelector ( ".input-userstatus " + BDFDB . dotCN . input ) ;
2020-02-18 11:39:32 +01:00
let userStatusEmojiPicker = modal . querySelector ( ".input-useremojistatus " + BDFDB . dotCN . emojiold ) ;
2020-02-17 13:16:17 +01:00
let removeStatusInput = modal . querySelector ( ".input-removestatus " + BDFDB . dotCN . switchinner ) ;
let ignoreTagColorInput = modal . querySelector ( ".input-ignoretagcolor " + BDFDB . dotCN . switchinner ) ;
2020-02-07 15:16:40 +01:00
2020-02-17 13:16:17 +01:00
data . name = userNameInput . value . trim ( ) || null ;
data . tag = userTagInput . value . trim ( ) || null ;
data . url = ( ! data . removeIcon && BDFDB . DOMUtils . containsClass ( userAvatarInput , BDFDB . disCN . inputsuccess ) ? userAvatarInput . value . trim ( ) : null ) || null ;
data . removeIcon = removeIconInput . checked ;
data . status = ! data . removeStatus && userStatusInput . value . trim ( ) || null ;
2020-02-18 11:39:32 +01:00
data . statusEmoji = ! data . removeStatus && BDFDB . ReactUtils . findValue ( userStatusEmojiPicker , "emoji" , { up : true } ) || null ;
2020-02-17 13:16:17 +01:00
data . removeStatus = removeStatusInput . checked ;
data . ignoreTagColor = ignoreTagColorInput . checked ;
2020-02-07 15:16:40 +01:00
data . color1 = BDFDB . ColorUtils . getSwatchColor ( modal , 1 ) ;
data . color2 = BDFDB . ColorUtils . getSwatchColor ( modal , 2 ) ;
data . color3 = BDFDB . ColorUtils . getSwatchColor ( modal , 3 ) ;
data . color4 = BDFDB . ColorUtils . getSwatchColor ( modal , 4 ) ;
data . color5 = BDFDB . ColorUtils . getSwatchColor ( modal , 5 ) ;
let changed = false ;
2020-02-17 13:16:17 +01:00
if ( Object . keys ( data ) . every ( key => data [ key ] == null || data [ key ] == false ) && ( changed = true ) ) BDFDB . DataUtils . remove ( this , "users" , user . id ) ;
else if ( ! BDFDB . equals ( olddata , data ) && ( changed = true ) ) BDFDB . DataUtils . save ( data , this , "users" , user . id ) ;
2020-02-07 15:16:40 +01:00
if ( changed ) this . forceUpdateAll ( ) ;
}
} ]
} ) ;
}
checkUrl ( url , instance ) {
BDFDB . TimeUtils . clear ( instance . checkTimeout ) ;
if ( url == null || ! url . trim ( ) ) {
delete instance . props . success ;
delete instance . props . errorMessage ;
instance . forceUpdate ( ) ;
}
else instance . checkTimeout = BDFDB . TimeUtils . timeout ( _ => {
BDFDB . LibraryRequires . request ( url . trim ( ) , ( error , response , result ) => {
if ( response && response . headers [ "content-type" ] && response . headers [ "content-type" ] . indexOf ( "image" ) != - 1 ) {
instance . props . success = true ;
delete instance . props . errorMessage ;
}
else {
delete instance . props . success ;
instance . props . errorMessage = this . labels . modal _invalidurl _text ;
}
delete instance . checkTimeout ;
instance . forceUpdate ( ) ;
} ) ;
} , 1000 ) ;
2019-01-25 11:27:52 +01:00
}
2019-01-26 22:45:19 +01:00
2020-02-07 15:16:40 +01:00
setLabelsByLanguage ( ) {
switch ( BDFDB . LanguageUtils . getLanguage ( ) . id ) {
case "hr" : //croatian
return {
context _localusersettings _text : "Lokalne korisničke postavke" ,
submenu _usersettings _text : "Promijeni postavke" ,
submenu _resetsettings _text : "Poništi korisnika" ,
modal _header _text : "Lokalne korisničke postavke" ,
modal _username _text : "Lokalno korisničko ime" ,
modal _usertag _text : "Oznaka" ,
modal _useravatar _text : "Ikona" ,
modal _tabheader1 _text : "Korisnik" ,
modal _tabheader2 _text : "Boja naziva" ,
modal _tabheader3 _text : "Boja oznaka" ,
modal _tabheader4 _text : "Boja poruke" ,
modal _colorpicker1 _text : "Boja naziva" ,
modal _colorpicker2 _text : "Boja pozadine" ,
modal _colorpicker3 _text : "Boja oznaka" ,
modal _colorpicker4 _text : "Boja fonta" ,
modal _colorpicker5 _text : "Boja fonta" ,
modal _ignoretagcolor _text : "Upotrijebite boju uloga" ,
modal _invalidurl _text : "Nevažeći URL"
} ;
case "da" : //danish
return {
context _localusersettings _text : "Lokal brugerindstillinger" ,
submenu _usersettings _text : "Skift indstillinger" ,
submenu _resetsettings _text : "Nulstil bruger" ,
modal _header _text : "Lokal brugerindstillinger" ,
modal _username _text : "Lokalt brugernavn" ,
modal _usertag _text : "Initialer" ,
modal _useravatar _text : "Ikon" ,
modal _tabheader1 _text : "Bruger" ,
modal _tabheader2 _text : "Navnefarve" ,
modal _tabheader3 _text : "Etiketfarve" ,
modal _tabheader4 _text : "Meddelelsesfarve" ,
modal _colorpicker1 _text : "Navnefarve" ,
modal _colorpicker2 _text : "Baggrundsfarve" ,
modal _colorpicker3 _text : "Etiketfarve" ,
modal _colorpicker4 _text : "Skriftfarve" ,
modal _colorpicker5 _text : "Skriftfarve" ,
modal _ignoretagcolor _text : "Brug rollefarve" ,
modal _invalidurl _text : "Ugyldig URL"
} ;
case "de" : //german
return {
context _localusersettings _text : "Lokale Benutzereinstellungen" ,
submenu _usersettings _text : "Einstellungen ändern" ,
submenu _resetsettings _text : "Benutzer zurücksetzen" ,
modal _header _text : "Lokale Benutzereinstellungen" ,
modal _username _text : "Lokaler Benutzername" ,
modal _usertag _text : "Etikett" ,
modal _useravatar _text : "Icon" ,
modal _tabheader1 _text : "Benutzer" ,
modal _tabheader2 _text : "Namensfarbe" ,
modal _tabheader3 _text : "Etikettfarbe" ,
modal _tabheader4 _text : "Nachrichtenfarbe" ,
modal _colorpicker1 _text : "Namensfarbe" ,
modal _colorpicker2 _text : "Hintergrundfarbe" ,
modal _colorpicker3 _text : "Etikettfarbe" ,
modal _colorpicker4 _text : "Schriftfarbe" ,
modal _colorpicker5 _text : "Schriftfarbe" ,
modal _ignoretagcolor _text : "Benutze Rollenfarbe" ,
modal _invalidurl _text : "Ungültige URL"
} ;
case "es" : //spanish
return {
context _localusersettings _text : "Ajustes local de usuario" ,
submenu _usersettings _text : "Cambiar ajustes" ,
submenu _resetsettings _text : "Restablecer usuario" ,
modal _header _text : "Ajustes local de usuario" ,
modal _username _text : "Nombre local de usuario" ,
modal _usertag _text : "Etiqueta" ,
modal _useravatar _text : "Icono" ,
modal _tabheader1 _text : "Usuario" ,
modal _tabheader2 _text : "Color del nombre" ,
modal _tabheader3 _text : "Color de la etiqueta" ,
modal _tabheader4 _text : "Color del mensaje" ,
modal _colorpicker1 _text : "Color del nombre" ,
modal _colorpicker2 _text : "Color de fondo" ,
modal _colorpicker3 _text : "Color de la etiqueta" ,
modal _colorpicker4 _text : "Color de fuente" ,
modal _colorpicker5 _text : "Color de fuente" ,
modal _ignoretagcolor _text : "Usar color de rol" ,
modal _invalidurl _text : "URL inválida"
} ;
case "fr" : //french
return {
context _localusersettings _text : "Paramètres locale d'utilisateur" ,
submenu _usersettings _text : "Modifier les paramètres" ,
submenu _resetsettings _text : "Réinitialiser l'utilisateur" ,
modal _header _text : "Paramètres locale d'utilisateur" ,
modal _username _text : "Nom local d'utilisateur" ,
modal _usertag _text : "Étiquette" ,
modal _useravatar _text : "Icône" ,
modal _tabheader1 _text : "Serveur" ,
modal _tabheader2 _text : "Couleur du nom" ,
modal _tabheader3 _text : "Couleur de l'étiquette" ,
modal _tabheader4 _text : "Couleur du message" ,
modal _colorpicker1 _text : "Couleur du nom" ,
modal _colorpicker2 _text : "Couleur de fond" ,
modal _colorpicker3 _text : "Couleur de l'étiquette" ,
modal _colorpicker4 _text : "Couleur de la police" ,
modal _colorpicker5 _text : "Couleur de la police" ,
modal _ignoretagcolor _text : "Utiliser la couleur de rôle" ,
modal _invalidurl _text : "URL invalide"
} ;
case "it" : //italian
return {
context _localusersettings _text : "Impostazioni locale utente" ,
submenu _usersettings _text : "Cambia impostazioni" ,
submenu _resetsettings _text : "Ripristina utente" ,
modal _header _text : "Impostazioni locale utente" ,
modal _username _text : "Nome locale utente" ,
modal _usertag _text : "Etichetta" ,
modal _useravatar _text : "Icona" ,
modal _tabheader1 _text : "Utente" ,
modal _tabheader2 _text : "Colore del nome" ,
modal _tabheader3 _text : "Colore della etichetta" ,
modal _tabheader4 _text : "Colore del messaggio" ,
modal _colorpicker1 _text : "Colore del nome" ,
modal _colorpicker2 _text : "Colore di sfondo" ,
modal _colorpicker3 _text : "Colore della etichetta" ,
modal _colorpicker4 _text : "Colore del carattere" ,
modal _colorpicker5 _text : "Colore del carattere" ,
modal _ignoretagcolor _text : "Usa il colore del ruolo" ,
modal _invalidurl _text : "URL non valido"
} ;
case "nl" : //dutch
return {
context _localusersettings _text : "Lokale gebruikerinstellingen" ,
submenu _usersettings _text : "Verandere instellingen" ,
submenu _resetsettings _text : "Reset gebruiker" ,
modal _header _text : "Lokale gebruikerinstellingen" ,
modal _username _text : "Lokale gebruikernaam" ,
modal _usertag _text : "Etiket" ,
modal _useravatar _text : "Icoon" ,
modal _tabheader1 _text : "Gebruiker" ,
modal _tabheader2 _text : "Naamkleur" ,
modal _tabheader3 _text : "Etiketkleur" ,
modal _tabheader4 _text : "Berichtkleur" ,
modal _colorpicker1 _text : "Naamkleur" ,
modal _colorpicker2 _text : "Achtergrondkleur" ,
modal _colorpicker3 _text : "Etiketkleur" ,
modal _colorpicker4 _text : "Doopvontkleur" ,
modal _colorpicker5 _text : "Doopvontkleur" ,
modal _ignoretagcolor _text : "Gebruik rolkleur" ,
modal _invalidurl _text : "Ongeldige URL"
} ;
case "no" : //norwegian
return {
context _localusersettings _text : "Lokal brukerinnstillinger" ,
submenu _usersettings _text : "Endre innstillinger" ,
submenu _resetsettings _text : "Tilbakestill bruker" ,
modal _header _text : "Lokal brukerinnstillinger" ,
modal _username _text : "Lokalt gebruikernavn" ,
modal _usertag _text : "Stikkord" ,
modal _useravatar _text : "Ikon" ,
modal _tabheader1 _text : "Bruker" ,
modal _tabheader2 _text : "Navnfarge" ,
modal _tabheader3 _text : "Stikkordfarge" ,
modal _tabheader4 _text : "Meldingsfarge" ,
modal _colorpicker1 _text : "Navnfarge" ,
modal _colorpicker2 _text : "Bakgrunnfarge" ,
modal _colorpicker3 _text : "Stikkordfarge" ,
modal _colorpicker4 _text : "Skriftfarge" ,
modal _colorpicker5 _text : "Skriftfarge" ,
modal _ignoretagcolor _text : "Bruk rollefarge" ,
modal _invalidurl _text : "Ugyldig URL"
} ;
case "pl" : //polish
return {
context _localusersettings _text : "Lokalne ustawienia użytkownika" ,
submenu _usersettings _text : "Zmień ustawienia" ,
submenu _resetsettings _text : "Resetuj ustawienia" ,
modal _header _text : "Lokalne ustawienia użytkownika" ,
modal _username _text : "Lokalna nazwa użytkownika" ,
modal _usertag _text : "Etykieta" ,
modal _useravatar _text : "Ikona" ,
modal _tabheader1 _text : "Użytkownik" ,
modal _tabheader2 _text : "Kolor nazwy" ,
modal _tabheader3 _text : "Kolor etykiety" ,
modal _tabheader4 _text : "Kolor wiadomości" ,
modal _colorpicker1 _text : "Kolor nazwy" ,
modal _colorpicker2 _text : "Kolor tła" ,
modal _colorpicker3 _text : "Kolor etykiety" ,
modal _colorpicker4 _text : "Kolor czcionki" ,
modal _colorpicker5 _text : "Kolor czcionki" ,
modal _ignoretagcolor _text : "Użyj kolor roli" ,
modal _invalidurl _text : "Nieprawidłowe URL"
} ;
case "pt-BR" : //portuguese (brazil)
return {
context _localusersettings _text : "Configurações local do utilizador" ,
submenu _usersettings _text : "Mudar configurações" ,
submenu _resetsettings _text : "Redefinir utilizador" ,
modal _header _text : "Configurações local do utilizador" ,
modal _username _text : "Nome local do utilizador" ,
modal _usertag _text : "Etiqueta" ,
modal _useravatar _text : "Icone" ,
modal _tabheader1 _text : "Utilizador" ,
modal _tabheader2 _text : "Cor do nome" ,
modal _tabheader3 _text : "Cor da etiqueta" ,
modal _tabheader4 _text : "Cor da mensagem" ,
modal _colorpicker1 _text : "Cor do nome" ,
modal _colorpicker2 _text : "Cor do fundo" ,
modal _colorpicker3 _text : "Cor da etiqueta" ,
modal _colorpicker4 _text : "Cor da fonte" ,
modal _colorpicker5 _text : "Cor da fonte" ,
modal _ignoretagcolor _text : "Use a cor do papel" ,
modal _invalidurl _text : "URL inválida"
} ;
case "fi" : //finnish
return {
context _localusersettings _text : "Paikallinen käyttäjä asetukset" ,
submenu _usersettings _text : "Vaihda asetuksia" ,
submenu _resetsettings _text : "Nollaa käyttäjä" ,
modal _header _text : "Paikallinen käyttäjä asetukset" ,
modal _username _text : "Paikallinen käyttäjätunnus" ,
modal _usertag _text : "Merkki" ,
modal _useravatar _text : "Ikonin" ,
modal _tabheader1 _text : "Käyttäjä" ,
modal _tabheader2 _text : "Nimiväri" ,
modal _tabheader3 _text : "Merkkiväri" ,
modal _tabheader4 _text : "Viestinväri" ,
modal _colorpicker1 _text : "Nimiväri" ,
modal _colorpicker2 _text : "Taustaväri" ,
modal _colorpicker3 _text : "Merkkiväri" ,
modal _colorpicker4 _text : "Fontinväri" ,
modal _colorpicker5 _text : "Fontinväri" ,
modal _ignoretagcolor _text : "Käytä rooliväriä" ,
modal _invalidurl _text : "Virheellinen URL"
} ;
case "sv" : //swedish
return {
context _localusersettings _text : "Lokal användareinställningar" ,
submenu _usersettings _text : "Ändra inställningar" ,
submenu _resetsettings _text : "Återställ användare" ,
modal _header _text : "Lokal användareinställningar" ,
modal _username _text : "Lokalt användarenamn" ,
modal _usertag _text : "Märka" ,
modal _useravatar _text : "Ikon" ,
modal _tabheader1 _text : "Användare" ,
modal _tabheader2 _text : "Namnfärg" ,
modal _tabheader3 _text : "Märkafärg" ,
modal _tabheader4 _text : "Meddelandefärg" ,
modal _colorpicker1 _text : "Namnfärg" ,
modal _colorpicker2 _text : "Bakgrundfärg" ,
modal _colorpicker3 _text : "Märkafärg" ,
modal _colorpicker4 _text : "Fontfärg" ,
modal _colorpicker5 _text : "Fontfärg" ,
modal _ignoretagcolor _text : "Använd rollfärg" ,
modal _invalidurl _text : "Ogiltig URL"
} ;
case "tr" : //turkish
return {
context _localusersettings _text : "Yerel Kullanı cı Ayarları " ,
submenu _usersettings _text : "Ayarları Değiştir" ,
submenu _resetsettings _text : "Kullanı cı Sı fı rla" ,
modal _header _text : "Yerel Kullanı cı Ayarları " ,
modal _username _text : "Yerel Kullanı cı Isim" ,
modal _usertag _text : "Etiket" ,
modal _useravatar _text : "Simge" ,
modal _tabheader1 _text : "Kullanı cı " ,
modal _tabheader2 _text : "Simge rengi" ,
modal _tabheader3 _text : "Isim rengi" ,
modal _tabheader4 _text : "Mesaj rengi" ,
modal _colorpicker1 _text : "Simge rengi" ,
modal _colorpicker2 _text : "Arka fon rengi" ,
modal _colorpicker3 _text : "Etiket rengi" ,
modal _colorpicker4 _text : "Yazı rengi" ,
modal _colorpicker5 _text : "Yazı rengi" ,
modal _ignoretagcolor _text : "Rol rengini kullan" ,
modal _invalidurl _text : "Geçersiz URL"
} ;
case "cs" : //czech
return {
context _localusersettings _text : "Místní nastavení uživatel" ,
submenu _usersettings _text : "Změnit nastavení" ,
submenu _resetsettings _text : "Obnovit uživatel" ,
modal _header _text : "Místní nastavení uživatel" ,
modal _username _text : "Místní název uživatel" ,
modal _usertag _text : "Štítek" ,
modal _useravatar _text : "Ikony" ,
modal _tabheader1 _text : "Uživatel" ,
modal _tabheader2 _text : "Barva název" ,
modal _tabheader3 _text : "Barva štítek" ,
modal _tabheader4 _text : "Barva zprávy" ,
modal _colorpicker1 _text : "Barva název" ,
modal _colorpicker2 _text : "Barva pozadí" ,
modal _colorpicker3 _text : "Barva štítek" ,
modal _colorpicker4 _text : "Barva fontu" ,
modal _colorpicker5 _text : "Barva fontu" ,
modal _ignoretagcolor _text : "Použijte barva role" ,
modal _invalidurl _text : "Neplatná URL"
} ;
case "bg" : //bulgarian
return {
context _localusersettings _text : "Настройки за локални потребител" ,
submenu _usersettings _text : "Промяна на настройките" ,
submenu _resetsettings _text : "Възстановяване на потребител" ,
modal _header _text : "Настройки за локални потребител" ,
modal _username _text : "Локално име на потребител" ,
modal _usertag _text : "Cво б о де н край" ,
modal _useravatar _text : "Икона" ,
modal _tabheader1 _text : "Потребител" ,
modal _tabheader2 _text : "Цвят на име" ,
modal _tabheader3 _text : "Цвят на свободен край" ,
modal _tabheader4 _text : "Цвят на съобщението" ,
modal _colorpicker1 _text : "Цвят на име" ,
modal _colorpicker2 _text : "Цвят на заден план" ,
modal _colorpicker3 _text : "Цвят на свободен край" ,
modal _colorpicker4 _text : "Цвят на шрифта" ,
modal _colorpicker5 _text : "Цвят на шрифта" ,
modal _ignoretagcolor _text : "Използвайте цвят на ролите" ,
modal _invalidurl _text : "Невалиден URL"
} ;
case "ru" : //russian
return {
context _localusersettings _text : "Настройки локального пользователь" ,
submenu _usersettings _text : "Изменить настройки" ,
submenu _resetsettings _text : "Сбросить пользователь" ,
modal _header _text : "Настройки локального пользователь" ,
modal _username _text : "Имя локального пользователь" ,
modal _usertag _text : "Tе г " ,
modal _useravatar _text : "Значок" ,
modal _tabheader1 _text : "Пользователь" ,
modal _tabheader2 _text : "Цвет имя" ,
modal _tabheader3 _text : "Цвет тег" ,
modal _tabheader4 _text : "Цвет сообщения" ,
modal _colorpicker1 _text : "Цвет имя" ,
modal _colorpicker2 _text : "Цвет задний план" ,
modal _colorpicker3 _text : "Цвет тег" ,
modal _colorpicker4 _text : "Цвет шрифта" ,
modal _colorpicker5 _text : "Цвет шрифта" ,
modal _ignoretagcolor _text : "Использовать цвет ролей" ,
modal _invalidurl _text : "Неверная URL"
} ;
case "uk" : //ukrainian
return {
context _localusersettings _text : "Налаштування локального користувач" ,
submenu _usersettings _text : "Змінити налаштування" ,
submenu _resetsettings _text : "Скидання користувач" ,
modal _header _text : "Налаштування локального користувач" ,
modal _username _text : "Локальне ім'я користувач" ,
modal _usertag _text : "Tе г " ,
modal _useravatar _text : "Іконка" ,
modal _tabheader1 _text : "Користувач" ,
modal _tabheader2 _text : "Колір ім'я" ,
modal _tabheader3 _text : "Колір тег" ,
modal _tabheader4 _text : "Колір повідомлення" ,
modal _colorpicker1 _text : "Колір ім'я" ,
modal _colorpicker2 _text : "Колір фон" ,
modal _colorpicker3 _text : "Колір тег" ,
modal _colorpicker4 _text : "Колір шрифту" ,
modal _colorpicker5 _text : "Колір шрифту" ,
modal _ignoretagcolor _text : "Використовуйте рольовий колір" ,
modal _invalidurl _text : "Недійсна URL"
} ;
case "ja" : //japanese
return {
context _localusersettings _text : "ローカルユーザーー設定" ,
submenu _usersettings _text : "設定を変更する" ,
submenu _resetsettings _text : "ユーザーーをリセットする" ,
modal _header _text : "ローカルユーザーー設定" ,
modal _username _text : "ローカルユーザーー名" ,
modal _usertag _text : "タグ" ,
modal _useravatar _text : "アイコン" ,
modal _tabheader1 _text : "ユーザー" ,
modal _tabheader2 _text : "名の色" ,
modal _tabheader3 _text : "タグの色" ,
modal _tabheader4 _text : "メッセージの色" ,
modal _colorpicker1 _text : "名の色" ,
modal _colorpicker2 _text : "バックグラウンドの色" ,
modal _colorpicker3 _text : "タグの色" ,
modal _colorpicker4 _text : "フォントの色" ,
modal _colorpicker5 _text : "フォントの色" ,
modal _ignoretagcolor _text : "ロールカラーを使用する" ,
modal _invalidurl _text : "無効な URL"
} ;
case "zh-TW" : //chinese (traditional)
return {
context _localusersettings _text : "本地用戶設置" ,
submenu _usersettings _text : "更改設置" ,
submenu _resetsettings _text : "重置用戶" ,
modal _header _text : "本地用戶設置" ,
modal _username _text : "用戶名稱" ,
modal _usertag _text : "標籤" ,
modal _useravatar _text : "圖標" ,
modal _tabheader1 _text : "用戶" ,
modal _tabheader2 _text : "名稱顏色" ,
modal _tabheader3 _text : "標籤顏色" ,
modal _tabheader4 _text : "訊息顏色" ,
modal _colorpicker1 _text : "名稱顏色" ,
modal _colorpicker2 _text : "背景顏色" ,
modal _colorpicker3 _text : "標籤顏色" ,
modal _colorpicker4 _text : "字體顏色" ,
modal _colorpicker5 _text : "字體顏色" ,
modal _ignoretagcolor _text : "使用角色" ,
modal _invalidurl _text : "無效的 URL"
} ;
case "ko" : //korean
return {
context _localusersettings _text : "로컬 사용자 설정" ,
submenu _usersettings _text : "설정 변경" ,
submenu _resetsettings _text : "사용자 재설정" ,
modal _header _text : "로컬 사용자 설정" ,
modal _username _text : "로컬 사용자 이름" ,
modal _usertag _text : "꼬리표" ,
modal _useravatar _text : "상" ,
modal _tabheader1 _text : "사용자" ,
modal _tabheader2 _text : "이름 색깔" ,
modal _tabheader3 _text : "꼬리표 색깔" ,
modal _tabheader4 _text : "메시지 색상" ,
modal _colorpicker1 _text : "이름 색깔" ,
modal _colorpicker2 _text : "배경 색깔" ,
modal _colorpicker3 _text : "꼬리표 색깔" ,
modal _colorpicker4 _text : "글꼴 색깔" ,
modal _colorpicker5 _text : "글꼴 색깔" ,
modal _ignoretagcolor _text : "역할 색상 사용" ,
modal _invalidurl _text : "잘못된 URL"
} ;
default : //default: english
return {
context _localusersettings _text : "Local Usersettings" ,
submenu _usersettings _text : "Change Settings" ,
submenu _resetsettings _text : "Reset User" ,
modal _header _text : "Local Usersettings" ,
modal _username _text : "Local Username" ,
modal _usertag _text : "Tag" ,
modal _useravatar _text : "Icon" ,
modal _tabheader1 _text : "User" ,
modal _tabheader2 _text : "Namecolor" ,
modal _tabheader3 _text : "Tagcolor" ,
modal _tabheader4 _text : "Messagecolor" ,
modal _colorpicker1 _text : "Namecolor" ,
modal _colorpicker2 _text : "Backgroundcolor" ,
modal _colorpicker3 _text : "Tagcolor" ,
modal _colorpicker4 _text : "Fontcolor" ,
modal _colorpicker5 _text : "Fontcolor" ,
modal _ignoretagcolor _text : "Use Rolecolor" ,
modal _invalidurl _text : "Invalid URL"
} ;
}
2018-10-11 10:21:26 +02:00
}
}
2020-02-07 16:36:26 +01:00
} ) ( ) ;