2020-10-20 23:25:34 +02:00
/ * *
* @ name PinDMs
2021-03-05 13:26:41 +01:00
* @ author DevilBro
2020-10-20 23:25:34 +02:00
* @ authorId 278543574059057154
2021-05-06 19:36:45 +02:00
* @ version 1.8 . 3
2021-03-05 13:26:41 +01:00
* @ description Allows you to pin DMs , making them appear at the top of your DMs / ServerList
2020-10-20 23:25:34 +02:00
* @ invite Jx3TjNS
* @ donate https : //www.paypal.me/MircoWittrien
* @ patreon https : //www.patreon.com/MircoWittrien
2021-03-09 15:10:55 +01:00
* @ website https : //mwittrien.github.io/
* @ source https : //github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/PinDMs/
2021-03-10 09:17:37 +01:00
* @ updateUrl https : //mwittrien.github.io/BetterDiscordAddons/Plugins/PinDMs/PinDMs.plugin.js
2020-10-20 23:25:34 +02:00
* /
2018-10-11 10:21:26 +02:00
2020-09-19 20:49:33 +02:00
module . exports = ( _ => {
2020-10-09 21:09:35 +02:00
const config = {
2020-09-19 20:49:33 +02:00
"info" : {
"name" : "PinDMs" ,
"author" : "DevilBro" ,
2021-05-06 19:36:45 +02:00
"version" : "1.8.3" ,
2021-03-04 12:26:17 +01:00
"description" : "Allows you to pin DMs, making them appear at the top of your DMs/ServerList"
2020-11-16 16:38:04 +01:00
} ,
"changeLog" : {
2021-04-22 12:17:32 +02:00
"fixed" : {
2021-05-06 19:36:45 +02:00
"Unread Badge" : "Fixed Issue where the unread badge for pinned categories would not get updated after the first new message"
2020-11-16 16:38:04 +01:00
}
2020-08-21 16:17:47 +02:00
}
2020-09-19 20:49:33 +02:00
} ;
2020-11-13 19:47:44 +01:00
2021-06-15 13:42:02 +02:00
return ( window . Lightcord || window . LightCord ) ? class {
getName ( ) { return config . info . name ; }
getAuthor ( ) { return config . info . author ; }
getVersion ( ) { return config . info . version ; }
getDescription ( ) { return "Do not use LightCord!" ; }
load ( ) { BdApi . alert ( "Attention!" , "By using LightCord you are risking your Discord Account, due to using a 3rd Party Client. Switch to an official Discord Client (https://discord.com/) with the proper BD Injection (https://betterdiscord.app/)" ) ; }
start ( ) { }
stop ( ) { }
} : ! window . BDFDB _Global || ( ! window . BDFDB _Global . loaded && ! window . BDFDB _Global . started ) ? class {
2021-01-06 12:38:36 +01:00
getName ( ) { return config . info . name ; }
getAuthor ( ) { return config . info . author ; }
getVersion ( ) { return config . info . version ; }
2021-02-01 17:13:13 +01:00
getDescription ( ) { return ` The Library Plugin needed for ${ config . info . name } is missing. Open the Plugin Settings to download it. \n \n ${ config . info . description } ` ; }
downloadLibrary ( ) {
require ( "request" ) . get ( "https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js" , ( e , r , b ) => {
2021-03-05 13:14:18 +01:00
if ( ! e && b && r . statusCode == 200 ) require ( "fs" ) . writeFile ( require ( "path" ) . join ( BdApi . Plugins . folder , "0BDFDB.plugin.js" ) , b , _ => BdApi . showToast ( "Finished downloading BDFDB Library" , { type : "success" } ) ) ;
2021-03-06 14:59:48 +01:00
else BdApi . alert ( "Error" , "Could not download BDFDB Library Plugin. Try again later or download it manually from GitHub: https://mwittrien.github.io/downloader/?library" ) ;
2021-02-01 17:13:13 +01:00
} ) ;
}
2020-09-19 20:49:33 +02:00
2021-01-06 12:38:36 +01:00
load ( ) {
2020-11-19 16:51:14 +01:00
if ( ! window . BDFDB _Global || ! Array . isArray ( window . BDFDB _Global . pluginQueue ) ) window . BDFDB _Global = Object . assign ( { } , window . BDFDB _Global , { pluginQueue : [ ] } ) ;
2020-09-19 20:49:33 +02:00
if ( ! window . BDFDB _Global . downloadModal ) {
window . BDFDB _Global . downloadModal = true ;
2021-01-14 16:14:44 +01:00
BdApi . showConfirmationModal ( "Library Missing" , ` The Library Plugin needed for ${ config . info . name } is missing. Please click "Download Now" to install it. ` , {
2020-09-19 20:49:33 +02:00
confirmText : "Download Now" ,
cancelText : "Cancel" ,
onCancel : _ => { delete window . BDFDB _Global . downloadModal ; } ,
2020-09-20 08:15:13 +02:00
onConfirm : _ => {
delete window . BDFDB _Global . downloadModal ;
2021-02-01 17:13:13 +01:00
this . downloadLibrary ( ) ;
2020-09-20 08:15:13 +02:00
}
2020-09-19 20:49:33 +02:00
} ) ;
2020-02-11 17:05:06 +01:00
}
2020-09-19 20:49:33 +02:00
if ( ! window . BDFDB _Global . pluginQueue . includes ( config . info . name ) ) window . BDFDB _Global . pluginQueue . push ( config . info . name ) ;
2020-10-09 21:09:35 +02:00
}
2021-01-06 12:38:36 +01:00
start ( ) { this . load ( ) ; }
stop ( ) { }
getSettingsPanel ( ) {
2020-11-28 23:12:09 +01:00
let template = document . createElement ( "template" ) ;
2021-01-14 16:14:44 +01:00
template . innerHTML = ` <div style="color: var(--header-primary); font-size: 16px; font-weight: 300; white-space: pre; line-height: 22px;">The Library Plugin needed for ${ config . info . name } is missing. \n Please click <a style="font-weight: 500;">Download Now</a> to install it.</div> ` ;
2021-02-01 17:13:13 +01:00
template . content . firstElementChild . querySelector ( "a" ) . addEventListener ( "click" , this . downloadLibrary ) ;
2020-11-28 23:12:09 +01:00
return template . content . firstElementChild ;
}
2020-10-09 21:09:35 +02:00
} : ( ( [ Plugin , BDFDB ] ) => {
2020-09-19 20:49:33 +02:00
var hoveredCategory , draggedCategory , releasedCategory ;
var hoveredChannel , draggedChannel , releasedChannel ;
2020-10-09 21:09:35 +02:00
return class PinDMs extends Plugin {
2021-01-06 12:38:36 +01:00
onLoad ( ) {
2020-09-19 20:49:33 +02:00
this . defaults = {
2021-04-22 12:17:32 +02:00
general : {
pinIcon : { value : true , description : "Show a little 'Pin' Icon for pinned DMs in the Server List" } ,
unreadAmount : { value : true , description : "Shows the Amount of unread Messages in a Category in the Channel List" } ,
channelAmount : { value : true , description : "Shows the Amount of pinned DMs in a Category in the Channel List" }
} ,
recentOrder : {
channelList : { value : false , description : "Channel List" } ,
guildList : { value : false , description : "Server List" } ,
2020-12-15 13:27:07 +01:00
} ,
preCategories : {
2021-04-22 12:17:32 +02:00
friends : { value : { enabled : false , collapsed : false } , description : "FRIENDS" } ,
blocked : { value : { enabled : false , collapsed : false } , description : "BLOCKED" } ,
groups : { value : { enabled : false , collapsed : false } , description : "GROUPS" }
2020-09-19 20:49:33 +02:00
}
} ;
2020-02-11 17:05:06 +01:00
2020-09-19 20:49:33 +02:00
this . patchedModules = {
before : {
PrivateChannelsList : "render" ,
UnreadDMs : "render"
} ,
after : {
PrivateChannelsList : "render" ,
UnreadDMs : "render" ,
PrivateChannel : [ "render" , "componentDidMount" ] ,
DirectMessage : [ "render" , "componentDidMount" , "componentWillUnmount" ]
}
} ;
this . css = `
$ { BDFDB . dotCNS . dmchannel + BDFDB . dotCN . namecontainerchildren } {
display : flex ;
}
$ { BDFDB . dotCN . dmchannel } : hover $ { BDFDB . dotCN . _pindmsunpinbutton } {
display : block ;
}
$ { BDFDB . dotCN . _pindmspinnedchannelsheadercontainer } {
display : flex ;
cursor : pointer ;
}
$ { BDFDB . dotCNS . _pindmspinnedchannelsheadercontainer + BDFDB . dotCN . dmchannelheadertext } {
margin - right : 6 px ;
}
$ { BDFDB . dotCN . _pindmspinnedchannelsheadercontainer + BDFDB . dotCN . _pindmspinnedchannelsheadercolored } : hover $ { BDFDB . dotCN . dmchannelheadertext } {
filter : brightness ( 150 % ) ;
}
$ { BDFDB . dotCNS . _pindmspinnedchannelsheadercontainer + BDFDB . dotCN . _pindmspinnedchannelsheaderamount } {
position : relative ;
top : - 1 px ;
margin - right : 6 px ;
2021-05-14 09:47:20 +02:00
background - color : var ( -- background - accent ) ;
2020-09-19 20:49:33 +02:00
}
$ { BDFDB . dotCN . _pindmspinnedchannelsheaderarrow } {
flex : 0 ;
width : 16 px ;
height : 16 px ;
margin - left : 0 ;
margin - right : 2 px ;
}
$ { BDFDB . dotCNS . _pindmspinnedchannelsheadercollapsed + BDFDB . dotCN . _pindmspinnedchannelsheaderarrow + BDFDB . dotCN . channelheadericonwrapper } {
transform : rotate ( - 90 deg ) ;
}
$ { BDFDB . dotCN . _pindmsunpinbutton } {
display : none ;
width : 16 px ;
height : 16 px ;
opacity : . 7 ;
margin : 2 px ;
}
$ { BDFDB . dotCN . _pindmsunpinbutton } : hover {
opacity : 1 ;
}
$ { BDFDB . dotCN . _pindmsunpinicon } {
display : block ;
width : 16 px ;
height : 16 px ;
}
$ { BDFDB . dotCNS . _pindmsdmchannelplaceholder + BDFDB . dotCN . namecontainerlayout } {
box - sizing : border - box ;
border : 1 px dashed currentColor ;
}
$ { BDFDB . dotCN . _pindmspinnedchannelsheadercontainer + BDFDB . dotCN . _pindmsdmchannelplaceholder } {
margin - left : 8 px ;
height : 12 px ;
box - sizing : border - box ;
border : 1 px dashed currentColor ;
}
$ { BDFDB . dotCN . _pindmsdragpreview } {
pointer - events : none ! important ;
position : absolute ! important ;
opacity : 0.5 ! important ;
z - index : 10000 ! important ;
}
` ;
}
2021-01-06 12:38:36 +01:00
onStart ( ) {
2021-04-24 14:27:23 +02:00
// REMOVE 24.04.2021
2021-04-22 12:17:32 +02:00
if ( ! BDFDB . DataUtils . load ( this , "pinned" , BDFDB . UserUtils . me . id ) ) {
let pinned = { } ;
let channelListPinned = BDFDB . DataUtils . load ( this , "dmCategories" ) ;
let guildListPinned = BDFDB . DataUtils . load ( this , "pinnedRecents" ) ;
if ( ! BDFDB . ObjectUtils . isEmpty ( channelListPinned ) ) pinned . channelList = channelListPinned ;
if ( ! BDFDB . ObjectUtils . isEmpty ( guildListPinned ) ) pinned . guildList = guildListPinned ;
if ( pinned . channelList || pinned . guildList ) BDFDB . DataUtils . save ( pinned , this , "pinned" , BDFDB . UserUtils . me . id ) ;
}
2020-02-11 17:05:06 +01:00
this . forceUpdateAll ( ) ;
2020-01-05 14:01:45 +01:00
}
2020-09-19 20:49:33 +02:00
2021-01-06 12:38:36 +01:00
onStop ( ) {
2020-07-02 09:54:10 +02:00
this . forceUpdateAll ( ) ;
2020-02-11 17:05:06 +01:00
2020-11-19 16:51:14 +01:00
let unreadDMsInstance = BDFDB . ReactUtils . findOwner ( document . querySelector ( BDFDB . dotCN . app ) , { name : "UnreadDMs" , unlimited : true } ) ;
2020-02-11 17:05:06 +01:00
if ( unreadDMsInstance ) {
delete unreadDMsInstance . props . pinnedPrivateChannelIds ;
unreadDMsInstance . props . unreadPrivateChannelIds = BDFDB . LibraryModules . DirectMessageUnreadStore . getUnreadPrivateChannelIds ( ) ;
BDFDB . ReactUtils . forceUpdate ( unreadDMsInstance ) ;
}
}
2019-09-04 12:34:02 +02:00
2020-09-19 20:49:33 +02:00
getSettingsPanel ( collapseStates = { } ) {
2021-04-22 12:17:32 +02:00
let settingsPanel ;
return settingsPanel = BDFDB . PluginUtils . createSettingsPanel ( this , {
collapseStates : collapseStates ,
children : _ => {
let settingsItems = [ ] ;
settingsItems . push ( Object . keys ( this . defaults . general ) . map ( key => BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsSaveItem , {
type : "Switch" ,
plugin : this ,
keys : [ "general" , key ] ,
label : this . defaults . general [ key ] . description ,
value : this . settings . general [ key ]
} ) ) ) ;
settingsItems . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormDivider , {
className : BDFDB . disCN . marginbottom8
} ) ) ;
settingsItems . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsPanelList , {
title : "Sort pinned DMs in the 'Recent Message' instead of the 'Pinned at' Order in:" ,
children : Object . keys ( this . defaults . recentOrder ) . map ( key => BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsSaveItem , {
type : "Switch" ,
plugin : this ,
keys : [ "recentOrder" , key ] ,
label : this . defaults . recentOrder [ key ] . description ,
value : this . settings . recentOrder [ key ]
} ) )
} ) ) ;
settingsItems . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormDivider , {
className : BDFDB . disCN . marginbottom8
} ) ) ;
settingsItems . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsPanelList , {
title : "Add predefined Category for:" ,
children : Object . keys ( this . defaults . preCategories ) . map ( key => BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsItem , {
type : "Switch" ,
label : BDFDB . LanguageUtils . LanguageStrings [ this . defaults . preCategories [ key ] . description ] ,
value : this . settings . preCategories [ key ] . enabled ,
onChange : value => {
this . settings . preCategories [ key ] . enabled = value ;
BDFDB . DataUtils . save ( this . settings . preCategories , this , "preCategories" ) ;
}
} ) )
} ) ) ;
settingsItems . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormDivider , {
className : BDFDB . disCN . marginbottom8
} ) ) ;
settingsItems . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsItem , {
type : "Button" ,
color : BDFDB . LibraryComponents . Button . Colors . RED ,
label : "Unpin all pinned DMs" ,
onClick : _ => {
BDFDB . ModalUtils . confirm ( this , "Are you sure you want to unpin all pinned DMs?" , _ => BDFDB . DataUtils . remove ( this , "pinned" , BDFDB . UserUtils . me . id ) ) ;
} ,
children : BDFDB . LanguageUtils . LanguageStrings . UNPIN
} ) ) ;
return settingsItems . flat ( 10 ) ;
}
} ) ;
2020-09-19 20:49:33 +02:00
}
2019-01-26 22:45:19 +01:00
2021-01-06 12:38:36 +01:00
onSettingsClosed ( ) {
2020-09-19 20:49:33 +02:00
if ( this . SettingsUpdated ) {
delete this . SettingsUpdated ;
this . forceUpdateAll ( ) ;
}
}
2019-01-26 22:45:19 +01:00
2021-01-06 12:38:36 +01:00
forceUpdateAll ( ) {
2020-09-19 20:49:33 +02:00
BDFDB . PatchUtils . forceAllUpdates ( this ) ;
2021-04-22 12:17:32 +02:00
BDFDB . DiscordUtils . rerenderAll ( ) ;
2020-02-11 17:05:06 +01:00
}
2019-11-21 14:56:53 +01:00
2020-09-19 20:49:33 +02:00
onUserContextMenu ( e ) {
if ( e . instance . props . user ) {
let [ children , index ] = BDFDB . ContextMenuUtils . findItem ( e . returnvalue , { id : "close-dm" } ) ;
if ( index > - 1 ) {
let id = BDFDB . LibraryModules . ChannelStore . getDMFromUserId ( e . instance . props . user . id ) ;
if ( id ) this . injectItem ( e . instance , id , children , index ) ;
}
2020-02-11 17:05:06 +01:00
}
2019-01-11 15:32:04 +01:00
}
2019-01-26 22:45:19 +01:00
2020-09-19 20:49:33 +02:00
onGroupDMContextMenu ( e ) {
if ( e . instance . props . channel ) {
let [ children , index ] = BDFDB . ContextMenuUtils . findItem ( e . returnvalue , { id : "change-icon" } ) ;
if ( index > - 1 ) this . injectItem ( e . instance , e . instance . props . channel . id , children , index + 1 ) ;
}
2020-02-11 17:05:06 +01:00
}
2019-01-26 22:45:19 +01:00
2020-09-19 20:49:33 +02:00
injectItem ( instance , id , children , index ) {
2020-12-15 13:27:07 +01:00
if ( ! id ) return ;
2021-05-06 19:36:45 +02:00
let pinnedInGuild = this . isPinnedInGuilds ( id ) ;
2020-09-19 20:49:33 +02:00
2021-04-22 12:17:32 +02:00
let categories = this . sortAndUpdateCategories ( "channelList" , true ) ;
2021-05-06 19:36:45 +02:00
let currentCategory = this . getChannelListCategory ( id ) ;
2020-09-19 20:49:33 +02:00
children . splice ( index , 0 , BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2020-12-21 19:56:36 +01:00
label : this . labels . context _pindm ,
2020-09-19 20:49:33 +02:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "submenu-pin" ) ,
children : [
BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2020-12-21 19:56:36 +01:00
label : this . labels . context _pinchannel ,
2020-09-19 20:49:33 +02:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "submenu-channelist" ) ,
2020-12-15 13:27:07 +01:00
children : this . getPredefinedCategory ( id ) ? BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2020-12-21 19:56:36 +01:00
label : this . labels . context _inpredefined ,
2020-12-15 13:27:07 +01:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "in-predefined" ) ,
disabled : true
} ) : [
2020-09-19 20:49:33 +02:00
BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuGroup , {
children : currentCategory ? BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2020-12-21 19:56:36 +01:00
label : this . labels . context _unpinchannel ,
2020-09-19 20:49:33 +02:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "unpin-channellist" ) ,
color : BDFDB . LibraryComponents . MenuItems . Colors . DANGER ,
action : _ => {
2021-04-22 12:17:32 +02:00
this . removeFromCategory ( id , currentCategory , "channelList" ) ;
2020-09-19 20:49:33 +02:00
}
} ) : BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2020-12-21 19:56:36 +01:00
label : this . labels . context _addtonewcategory ,
2020-09-19 20:49:33 +02:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "new-channellist" ) ,
color : BDFDB . LibraryComponents . MenuItems . Colors . BRAND ,
action : _ => {
this . openCategorySettingsModal ( {
2021-04-22 12:17:32 +02:00
id : this . generateID ( "channelList" ) . toString ( ) ,
2020-12-21 19:56:36 +01:00
name : ` ${ this . labels . header _pinneddms } # ${ categories . length + 1 } ` ,
2020-09-19 20:49:33 +02:00
dms : [ id ] ,
pos : categories . length ,
collapsed : false ,
color : null
2021-04-22 12:17:32 +02:00
} , "channelList" , true ) ;
2020-09-19 20:49:33 +02:00
}
} )
} ) ,
categories . length ? BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuGroup , {
2020-12-15 13:27:07 +01:00
children : categories . map ( category => currentCategory && currentCategory . id == category . id || category . predefined ? null : BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2020-12-21 19:56:36 +01:00
label : category . name || this . labels . header _pinneddms ,
2020-09-19 20:49:33 +02:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "pin-channellist" , category . id ) ,
action : _ => {
2021-04-22 12:17:32 +02:00
if ( currentCategory ) this . removeFromCategory ( id , currentCategory , "channelList" ) ;
this . addToCategory ( id , category , "channelList" ) ;
2020-09-19 20:49:33 +02:00
}
} ) ) . filter ( n => n )
} ) : null
] . filter ( n => n )
} ) ,
BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2020-12-21 19:56:36 +01:00
label : this . labels [ pinnedInGuild ? "context_unpinguild" : "context_pinguild" ] ,
2020-09-19 20:49:33 +02:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , pinnedInGuild ? "unpin-serverlist" : "pin-serverlist" ) ,
2021-04-23 10:51:38 +02:00
color : pinnedInGuild ? BDFDB . LibraryComponents . MenuItems . Colors . DANGER : BDFDB . LibraryComponents . MenuItems . Colors . DEFAULT ,
2020-09-19 20:49:33 +02:00
action : _ => {
2021-04-22 12:17:32 +02:00
if ( ! pinnedInGuild ) this . addPin ( id , "guildList" ) ;
else this . removePin ( id , "guildList" ) ;
2020-09-19 20:49:33 +02:00
}
} )
2020-12-15 13:27:07 +01:00
] . filter ( n => n )
2020-09-19 20:49:33 +02:00
} ) ) ;
}
2020-02-11 17:05:06 +01:00
2020-09-19 20:49:33 +02:00
processPrivateChannelsList ( e ) {
2021-04-22 12:17:32 +02:00
let categories = this . sortAndUpdateCategories ( "channelList" , true ) ;
2020-09-19 20:49:33 +02:00
if ( categories . length ) {
e . instance . props . channels = Object . assign ( { } , e . instance . props . channels ) ;
e . instance . props . privateChannelIds = [ ] . concat ( e . instance . props . privateChannelIds || [ ] ) ;
e . instance . props . pinnedChannelIds = Object . assign ( { } , e . instance . props . pinnedChannelIds ) ;
if ( ! e . returnvalue ) {
if ( draggedChannel && releasedChannel ) {
let categoryId = releasedChannel . split ( "header_" ) [ 1 ] ;
let category = categories . find ( n => categoryId != undefined ? n . id == categoryId : n . dms . includes ( releasedChannel ) ) ;
if ( category ) {
BDFDB . ArrayUtils . remove ( category . dms , draggedChannel , true ) ;
category . dms . splice ( categoryId != undefined ? 0 : category . dms . indexOf ( releasedChannel ) + 1 , 0 , draggedChannel ) ;
2021-04-22 12:17:32 +02:00
this . savePinnedChannels ( Object . assign ( { } , this . getPinnedChannels ( "channelList" ) , { [ category . id ] : category } ) , "channelList" ) ;
2020-09-19 20:49:33 +02:00
}
draggedChannel = null ;
releasedChannel = null ;
2020-04-01 19:28:13 +02:00
}
2020-09-19 20:49:33 +02:00
if ( draggedCategory && releasedCategory ) {
let maybedDraggedCategory = categories . find ( n => n . id == draggedCategory ) ;
let maybedReleasedCategory = categories . find ( n => n . id == releasedCategory ) ;
if ( maybedDraggedCategory && maybedReleasedCategory ) {
BDFDB . ArrayUtils . remove ( categories , maybedDraggedCategory , true ) ;
categories . splice ( categories . indexOf ( maybedReleasedCategory ) + 1 , 0 , maybedDraggedCategory ) ;
let newCategories = { } , newPos = 0 ;
2020-12-15 13:27:07 +01:00
for ( let category of [ ] . concat ( categories ) . reverse ( ) ) if ( ! category . predefined ) newCategories [ category . id ] = Object . assign ( category , { pos : newPos ++ } ) ;
2021-04-22 12:17:32 +02:00
this . savePinnedChannels ( newCategories , "channelList" ) ;
2020-09-19 20:49:33 +02:00
}
draggedCategory = null ;
releasedCategory = null ;
2020-04-24 19:33:47 +02:00
}
2020-09-19 20:49:33 +02:00
e . instance . props . pinnedChannelIds = { } ;
for ( let category of [ ] . concat ( categories ) . reverse ( ) ) {
e . instance . props . pinnedChannelIds [ category . id ] = [ ] ;
2021-04-22 12:17:32 +02:00
for ( let id of this . sortDMsByTime ( this . filterDMs ( category . dms , ! category . predefined ) , "channelList" ) . reverse ( ) ) {
2020-09-19 20:49:33 +02:00
BDFDB . ArrayUtils . remove ( e . instance . props . privateChannelIds , id , true ) ;
if ( ! category . collapsed || e . instance . props . selectedChannelId == id ) {
e . instance . props . privateChannelIds . unshift ( id ) ;
e . instance . props . pinnedChannelIds [ category . id ] . push ( id ) ;
}
2020-04-24 19:33:47 +02:00
}
}
}
2020-09-19 20:49:33 +02:00
else {
2020-11-16 16:38:04 +01:00
if ( typeof e . returnvalue . props . children == "function" ) {
let childrenRender = e . returnvalue . props . children ;
e . returnvalue . props . children = ( ... args ) => {
let children = childrenRender ( ... args ) ;
this . injectCategories ( e . instance , children , categories ) ;
return children ;
} ;
}
else this . injectCategories ( e . instance , e . returnvalue , categories ) ;
2020-09-19 20:49:33 +02:00
}
let pinnedIds = BDFDB . ObjectUtils . toArray ( e . instance . props . pinnedChannelIds ) . reverse ( ) ;
BDFDB . PatchUtils . unpatch ( this , e . instance , "renderDM" ) ;
BDFDB . PatchUtils . patch ( this , e . instance , "renderDM" , { before : e2 => {
if ( e2 . methodArguments [ 0 ] != 0 ) e2 . methodArguments [ 1 ] += pinnedIds . slice ( 0 , e2 . methodArguments [ 0 ] - 1 ) . flat ( ) . length ;
} , after : e2 => {
if ( e2 . methodArguments [ 0 ] != 0 ) {
let id = e . instance . props . privateChannelIds [ e2 . methodArguments [ 1 ] ] ;
e2 . returnValue = e . instance . props . channels [ id ] ? BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . PrivateChannelItems [ e . instance . props . channels [ id ] . isMultiUserDM ( ) ? "GroupDM" : "DirectMessage" ] , Object . assign ( {
key : id ,
channel : e . instance . props . channels [ id ] ,
selected : e . instance . props . selectedChannelId == id
} , ( e . instance . props . navigator || e . instance . props . listNavigator ) . getItemProps ( {
index : e2 . methodArguments [ 2 ]
} ) ) ) : null ;
let category = categories [ e2 . methodArguments [ 0 ] - 1 ] ;
if ( category ) {
2021-04-28 09:31:30 +02:00
if ( ! id || ( category . collapsed && e . instance . props . selectedChannelId != id ) || ! this . filterDMs ( category . dms , ! category . predefined ) . includes ( id ) || draggedCategory == category . id || draggedChannel == id ) e2 . returnValue = null ;
2020-09-19 20:49:33 +02:00
else if ( hoveredCategory == category . id && [ ] . concat ( category . dms ) . reverse ( ) [ 0 ] == id ) e2 . returnValue = [
e2 . returnValue ,
BDFDB . ReactUtils . createElement ( "h2" , {
className : BDFDB . disCNS . dmchannelheadercontainer + BDFDB . disCNS . _pindmspinnedchannelsheadercontainer + BDFDB . disCNS . _pindmsdmchannelplaceholder + BDFDB . disCN . namecontainernamecontainer
} )
] . filter ( n => n ) ;
else if ( hoveredChannel == id ) e2 . returnValue = [
e2 . returnValue ,
BDFDB . ReactUtils . createElement ( "div" , {
2020-07-02 09:54:10 +02:00
className : BDFDB . disCNS . dmchannel + BDFDB . disCNS . _pindmsdmchannelpinned + BDFDB . disCNS . _pindmsdmchannelplaceholder + BDFDB . disCN . namecontainernamecontainer ,
children : BDFDB . ReactUtils . createElement ( "div" , {
className : BDFDB . disCN . namecontainerlayout
2020-04-24 21:57:57 +02:00
} )
2020-04-25 09:23:03 +02:00
} )
2020-07-02 09:54:10 +02:00
] . filter ( n => n ) ;
}
2020-04-01 19:28:13 +02:00
}
2020-09-19 20:49:33 +02:00
} } , { force : true , noCache : true } ) ;
2020-07-02 09:54:10 +02:00
}
2020-09-19 20:49:33 +02:00
}
2020-11-16 16:38:04 +01:00
injectCategories ( instance , returnvalue , categories ) {
returnvalue . props . sections = [ ] ;
returnvalue . props . sections . push ( instance . state . preRenderedChildren ) ;
let shownPinnedIds = BDFDB . ObjectUtils . toArray ( instance . props . pinnedChannelIds ) . reverse ( ) ;
for ( let ids of shownPinnedIds ) returnvalue . props . sections . push ( ids . length || 1 ) ;
returnvalue . props . sections . push ( instance . props . privateChannelIds . length - shownPinnedIds . flat ( ) . length ) ;
let sectionHeight = returnvalue . props . sectionHeight ;
let sectionHeightFunc = typeof sectionHeight != "function" ? _ => sectionHeight : sectionHeight ;
returnvalue . props . sectionHeight = ( ... args ) => {
if ( args [ 0 ] != 0 && args [ 0 ] != returnvalue . props . sections . length - 1 ) {
let category = categories [ args [ 0 ] - 1 ] ;
if ( category ) return 40 ;
}
return sectionHeightFunc ( ... args ) ;
} ;
let rowHeight = returnvalue . props . rowHeight ;
let rowHeightFunc = typeof rowHeight != "function" ? _ => rowHeight : rowHeight ;
returnvalue . props . rowHeight = ( ... args ) => {
if ( args [ 0 ] != 0 && args [ 0 ] != returnvalue . props . sections . length - 1 ) {
let category = categories [ args [ 0 ] - 1 ] ;
if ( category && ( category . collapsed || category . id == draggedCategory ) ) return 0 ;
}
return rowHeightFunc ( ... args ) ;
} ;
let renderRow = returnvalue . props . renderRow ;
returnvalue . props . renderRow = ( ... args ) => {
let row = renderRow ( ... args ) ;
return row && row . key == "no-private-channels" ? null : row ;
} ;
let renderSection = returnvalue . props . renderSection ;
returnvalue . props . renderSection = ( ... args ) => {
if ( args [ 0 ] . section != 0 && args [ 0 ] . section != returnvalue . props . sections . length - 1 ) {
let category = categories [ args [ 0 ] . section - 1 ] ;
if ( category && draggedCategory != category . id ) {
let color = BDFDB . ColorUtils . convert ( category . color , "RGBA" ) ;
2020-12-15 13:27:07 +01:00
let foundDMs = this . filterDMs ( category . dms , ! category . predefined ) ;
2021-04-22 12:17:32 +02:00
let unreadAmount = this . settings . general . unreadAmount && BDFDB . ArrayUtils . sum ( foundDMs . map ( id => BDFDB . LibraryModules . UnreadChannelUtils . getMentionCount ( id ) ) ) ;
2020-12-15 13:27:07 +01:00
return category . predefined && foundDMs . length < 1 ? null : [
2020-11-16 16:38:04 +01:00
BDFDB . ReactUtils . createElement ( "h2" , {
className : BDFDB . DOMUtils . formatClassName ( BDFDB . disCN . dmchannelheadercontainer , BDFDB . disCN . _pindmspinnedchannelsheadercontainer , category . collapsed && BDFDB . disCN . _pindmspinnedchannelsheadercollapsed , color && BDFDB . disCN . _pindmspinnedchannelsheadercolored , BDFDB . disCN . namecontainernamecontainer ) ,
categoryId : category . id ,
2020-12-15 13:27:07 +01:00
onMouseDown : category . predefined ? null : event => {
2020-11-16 16:38:04 +01:00
event = event . nativeEvent || event ;
let node = BDFDB . DOMUtils . getParent ( BDFDB . dotCN . _pindmspinnedchannelsheadercontainer , event . target ) . cloneNode ( true ) ;
2020-12-15 13:27:07 +01:00
let mouseMove = event2 => {
2020-11-16 16:38:04 +01:00
if ( Math . sqrt ( ( event . pageX - event2 . pageX ) * * 2 ) > 20 || Math . sqrt ( ( event . pageY - event2 . pageY ) * * 2 ) > 20 ) {
BDFDB . ListenerUtils . stopEvent ( event ) ;
draggedCategory = category . id ;
2021-04-22 12:17:32 +02:00
this . updateContainer ( "channelList" ) ;
2020-11-16 16:38:04 +01:00
let dragPreview = this . createDragPreview ( node , event2 ) ;
2020-12-15 13:27:07 +01:00
document . removeEventListener ( "mousemove" , mouseMove ) ;
document . removeEventListener ( "mouseup" , mouseUp ) ;
2020-11-16 16:38:04 +01:00
let dragging = event3 => {
this . updateDragPreview ( dragPreview , event3 ) ;
let placeholder = BDFDB . DOMUtils . getParent ( BDFDB . dotCN . _pindmsdmchannelplaceholder , event3 . target ) ;
let categoryNode = BDFDB . DOMUtils . getParent ( BDFDB . dotCN . _pindmspinnedchannelsheadercontainer , placeholder ? placeholder . previousSibling : event3 . target ) ;
let maybeHoveredCategory = categoryNode && categoryNode . getAttribute ( "categoryId" ) ;
let update = maybeHoveredCategory != hoveredCategory ;
2021-04-22 12:17:32 +02:00
if ( maybeHoveredCategory && ! this . defaults . preCategories [ maybeHoveredCategory ] ) hoveredCategory = maybeHoveredCategory ;
2020-11-16 16:38:04 +01:00
else hoveredCategory = null ;
2021-04-22 12:17:32 +02:00
if ( update ) this . updateContainer ( "channelList" ) ;
2020-11-16 16:38:04 +01:00
} ;
let releasing = event3 => {
BDFDB . DOMUtils . remove ( dragPreview ) ;
if ( hoveredCategory ) releasedCategory = hoveredCategory ;
else draggedCategory = null ;
hoveredCategory = null ;
2021-04-22 12:17:32 +02:00
this . updateContainer ( "channelList" ) ;
2020-11-16 16:38:04 +01:00
document . removeEventListener ( "mousemove" , dragging ) ;
document . removeEventListener ( "mouseup" , releasing ) ;
} ;
document . addEventListener ( "mousemove" , dragging ) ;
document . addEventListener ( "mouseup" , releasing ) ;
}
} ;
2020-12-15 13:27:07 +01:00
let mouseUp = _ => {
document . removeEventListener ( "mousemove" , mouseMove ) ;
document . removeEventListener ( "mouseup" , mouseUp ) ;
2020-11-16 16:38:04 +01:00
} ;
2020-12-15 13:27:07 +01:00
document . addEventListener ( "mousemove" , mouseMove ) ;
document . addEventListener ( "mouseup" , mouseUp ) ;
2020-11-16 16:38:04 +01:00
} ,
onClick : _ => {
if ( foundDMs . length || ! category . collapsed ) {
category . collapsed = ! category . collapsed ;
2020-12-15 13:27:07 +01:00
if ( category . predefined ) {
2021-04-22 12:17:32 +02:00
this . settings . preCategories [ category . id ] . collapsed = category . collapsed ;
BDFDB . DataUtils . save ( this . settings . preCategories , this , "preCategories" ) ;
2020-12-15 13:27:07 +01:00
}
2021-04-22 12:17:32 +02:00
else this . savePinnedChannels ( Object . assign ( { } , this . getPinnedChannels ( "channelList" ) , { [ category . id ] : category } ) , "channelList" ) ;
this . updateContainer ( "channelList" ) ;
2020-11-16 16:38:04 +01:00
}
} ,
onContextMenu : event => {
BDFDB . ContextMenuUtils . open ( this , event , BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuGroup , {
2020-12-15 13:27:07 +01:00
children : category . predefined ? BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
2020-12-21 19:56:36 +01:00
label : this . labels . context _disablepredefined ,
2020-12-15 13:27:07 +01:00
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "disable-predefined" ) ,
action : _ => {
2021-04-22 12:17:32 +02:00
if ( ! this . settings . preCategories [ category . id ] ) return ;
this . settings . preCategories [ category . id ] . enabled = false ;
BDFDB . DataUtils . save ( this . settings . preCategories , this , "preCategories" ) ;
this . updateContainer ( "channelList" ) ;
2020-12-15 13:27:07 +01:00
}
} ) : [
2020-11-16 16:38:04 +01:00
BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
label : BDFDB . LanguageUtils . LanguageStrings . CATEGORY _SETTINGS ,
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "category-settings" ) ,
2020-12-15 13:27:07 +01:00
action : _ => {
2021-04-22 12:17:32 +02:00
this . openCategorySettingsModal ( category , "channelList" ) ;
2020-11-16 16:38:04 +01:00
}
} ) ,
BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
label : BDFDB . LanguageUtils . LanguageStrings . DELETE _CATEGORY ,
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "remove-category" ) ,
color : BDFDB . LibraryComponents . MenuItems . Colors . DANGER ,
2020-12-15 13:27:07 +01:00
action : _ => {
2021-04-22 12:17:32 +02:00
let newData = this . getPinnedChannels ( "channelList" ) ;
delete newData [ category . id ] ;
this . savePinnedChannels ( newData , "channelList" ) ;
this . updateContainer ( "channelList" ) ;
2020-11-16 16:38:04 +01:00
}
} )
]
} ) ) ;
} ,
children : [
BDFDB . ObjectUtils . is ( color ) ? BDFDB . ReactUtils . createElement ( "span" , {
className : BDFDB . disCN . dmchannelheadertext ,
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TextGradientElement , {
gradient : BDFDB . ColorUtils . createGradient ( color ) ,
children : category . name
} )
} ) : BDFDB . ReactUtils . createElement ( "span" , {
className : BDFDB . disCN . dmchannelheadertext ,
style : { color : color } ,
children : category . name ,
} ) ,
unreadAmount ? BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Badges . NumberBadge , {
className : BDFDB . disCN . _pindmspinnedchannelsheaderamount ,
2021-05-14 09:47:20 +02:00
count : unreadAmount
2020-11-16 16:38:04 +01:00
} ) : null ,
2021-04-22 12:17:32 +02:00
this . settings . general . channelAmount ? BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Badges . NumberBadge , {
2020-11-16 16:38:04 +01:00
className : BDFDB . disCN . _pindmspinnedchannelsheaderamount ,
count : foundDMs . length ,
2021-05-14 09:47:20 +02:00
disableColor : true
2020-11-16 16:38:04 +01:00
} ) : null ,
BDFDB . ReactUtils . createElement ( "div" , {
className : BDFDB . disCNS . _pindmspinnedchannelsheaderarrow + BDFDB . disCNS . channelheadericonwrapper + BDFDB . disCN . channelheadericonclickable ,
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SvgIcon , {
className : BDFDB . disCNS . _pindmspinnedchannelsheaderarrow + BDFDB . disCN . channelheadericon ,
nativeClass : true ,
iconSVG : ` <svg width="24" height="24" viewBox="4 4 16 16"><path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M16.59 8.59004L12 13.17L7.41 8.59004L6 10L12 16L18 10L16.59 8.59004Z"></path></svg> `
} )
} )
] . filter ( n => n )
} ) ,
hoveredChannel == "header_" + category . id && BDFDB . ReactUtils . createElement ( "div" , {
className : BDFDB . disCNS . dmchannel + BDFDB . disCNS . _pindmsdmchannelpinned + BDFDB . disCNS . _pindmsdmchannelplaceholder + BDFDB . disCN . namecontainernamecontainer ,
children : BDFDB . ReactUtils . createElement ( "div" , {
className : BDFDB . disCN . namecontainerlayout
} )
} )
] . filter ( n => n ) ;
}
else return null ;
}
else return renderSection ( ... args ) ;
} ;
}
2020-09-19 20:49:33 +02:00
processUnreadDMs ( e ) {
e . instance . props . pinnedPrivateChannelIds = [ ] ;
2021-04-22 12:17:32 +02:00
let sortedRecents = this . sortAndUpdate ( "guildList" ) ;
2020-09-19 20:49:33 +02:00
if ( sortedRecents . length ) {
e . instance . props . unreadPrivateChannelIds = [ ] ;
for ( let pos in sortedRecents ) {
let id = sortedRecents [ pos ] ;
if ( e . instance . props . channels [ id ] ) {
if ( ! e . instance . props . pinnedPrivateChannelIds . includes ( id ) ) e . instance . props . pinnedPrivateChannelIds . push ( id ) ;
if ( ! e . instance . props . unreadPrivateChannelIds . includes ( id ) ) e . instance . props . unreadPrivateChannelIds . push ( id ) ;
}
}
e . instance . props . unreadPrivateChannelIds = e . instance . props . unreadPrivateChannelIds . concat ( BDFDB . LibraryModules . DirectMessageUnreadStore . getUnreadPrivateChannelIds ( ) ) ;
if ( e . returnvalue ) {
if ( draggedChannel && releasedChannel ) {
let pinnedPrivateChannelIds = [ ] . concat ( e . instance . props . pinnedPrivateChannelIds ) , newData = { } ;
BDFDB . ArrayUtils . remove ( pinnedPrivateChannelIds , draggedChannel , true ) ;
pinnedPrivateChannelIds . splice ( pinnedPrivateChannelIds . indexOf ( releasedChannel ) + 1 , 0 , draggedChannel ) ;
for ( let pos in pinnedPrivateChannelIds ) newData [ pinnedPrivateChannelIds [ pos ] ] = parseInt ( pos ) ;
2021-04-22 12:17:32 +02:00
this . savePinnedChannels ( newData , "guildList" ) ;
2020-09-19 20:49:33 +02:00
draggedChannel = null ;
releasedChannel = null ;
BDFDB . ReactUtils . forceUpdate ( e . instance ) ;
}
if ( draggedChannel ) {
let [ children , index ] = BDFDB . ReactUtils . findParent ( e . returnvalue , { filter : child => BDFDB . ObjectUtils . get ( child , "props.channel.id" ) == draggedChannel } ) ;
children . splice ( index , 1 ) ;
}
if ( this . hoveredChannel ) {
let [ children , index ] = BDFDB . ReactUtils . findParent ( e . returnvalue , { filter : child => BDFDB . ObjectUtils . get ( child , "props.channel.id" ) == this . hoveredChannel } ) ;
children . splice ( index + 1 , 0 , BDFDB . ReactUtils . createElement ( "div" , {
className : BDFDB . disCNS . guildouter + BDFDB . disCN . _pindmsrecentplaceholder ,
children : BDFDB . ReactUtils . createElement ( "div" , {
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . GuildComponents . Items . DragPlaceholder , { } )
2020-04-25 09:23:03 +02:00
} )
2020-09-19 20:49:33 +02:00
} ) ) ;
2020-04-24 19:33:47 +02:00
}
2020-04-25 09:23:03 +02:00
}
2020-09-19 20:49:33 +02:00
}
else e . instance . props . unreadPrivateChannelIds = BDFDB . LibraryModules . DirectMessageUnreadStore . getUnreadPrivateChannelIds ( ) ;
2019-01-24 22:27:15 +01:00
}
2019-01-26 22:45:19 +01:00
2020-09-19 20:49:33 +02:00
processPrivateChannel ( e ) {
2020-12-15 13:27:07 +01:00
if ( e . instance . props . channel && ! this . getPredefinedCategory ( e . instance . props . channel . id ) ) {
2021-05-06 19:36:45 +02:00
let category = this . getChannelListCategory ( e . instance . props . channel . id ) ;
2020-09-19 20:49:33 +02:00
if ( category ) {
if ( e . node ) {
BDFDB . DOMUtils . addClass ( e . node , BDFDB . disCN . _pindmsdmchannelpinned ) ;
e . node . removeEventListener ( "mousedown" , e . node . PinDMsMouseDownListener ) ;
2021-04-22 12:17:32 +02:00
if ( ! this . settings . recentOrder . channelList ) {
2020-09-19 20:49:33 +02:00
e . node . setAttribute ( "draggable" , false ) ;
e . node . PinDMsMouseDownListener = event => {
2020-12-15 13:27:07 +01:00
if ( ! this . started ) e . node . removeEventListener ( "mousedown" , e . node . PinDMsMouseDownListener ) ;
2020-09-19 20:49:33 +02:00
else {
event = event . nativeEvent || event ;
2020-12-15 13:27:07 +01:00
let mouseMove = event2 => {
2020-09-19 20:49:33 +02:00
if ( Math . sqrt ( ( event . pageX - event2 . pageX ) * * 2 ) > 20 || Math . sqrt ( ( event . pageY - event2 . pageY ) * * 2 ) > 20 ) {
BDFDB . ListenerUtils . stopEvent ( event ) ;
draggedChannel = e . instance . props . channel . id ;
2021-04-22 12:17:32 +02:00
this . updateContainer ( "channelList" ) ;
2020-09-19 20:49:33 +02:00
let dragPreview = this . createDragPreview ( e . node , event2 ) ;
2020-12-15 13:27:07 +01:00
document . removeEventListener ( "mousemove" , mouseMove ) ;
document . removeEventListener ( "mouseup" , mouseUp ) ;
2020-09-19 20:49:33 +02:00
let dragging = event3 => {
this . updateDragPreview ( dragPreview , event3 ) ;
let maybeHoveredChannel = null ;
let categoryNode = BDFDB . DOMUtils . getParent ( BDFDB . dotCN . _pindmspinnedchannelsheadercontainer , event3 . target ) ;
if ( categoryNode ) {
let hoveredCategoryId = categoryNode . getAttribute ( "categoryid" ) ;
if ( hoveredCategoryId && hoveredCategoryId == category . id ) maybeHoveredChannel = "header_" + category . id ;
}
else {
let placeholder = BDFDB . DOMUtils . getParent ( BDFDB . dotCN . _pindmsdmchannelplaceholder , event3 . target ) ;
maybeHoveredChannel = ( BDFDB . ReactUtils . findValue ( BDFDB . DOMUtils . getParent ( BDFDB . dotCN . _pindmsdmchannelpinned , placeholder ? placeholder . previousSibling : event3 . target ) , "channel" , { up : true } ) || { } ) . id ;
2021-05-06 19:36:45 +02:00
let maybeHoveredCategory = maybeHoveredChannel && this . getChannelListCategory ( maybeHoveredChannel ) ;
2020-09-19 20:49:33 +02:00
if ( ! maybeHoveredCategory || maybeHoveredCategory . id != category . id ) maybeHoveredChannel = null ;
} ;
let update = maybeHoveredChannel != hoveredChannel ;
if ( maybeHoveredChannel ) hoveredChannel = maybeHoveredChannel ;
else hoveredChannel = null ;
2021-04-22 12:17:32 +02:00
if ( update ) this . updateContainer ( "channelList" ) ;
2020-09-19 20:49:33 +02:00
} ;
let releasing = event3 => {
BDFDB . DOMUtils . remove ( dragPreview ) ;
if ( hoveredChannel ) releasedChannel = hoveredChannel ;
else draggedChannel = null ;
hoveredChannel = null ;
2021-04-22 12:17:32 +02:00
this . updateContainer ( "channelList" ) ;
2020-09-19 20:49:33 +02:00
document . removeEventListener ( "mousemove" , dragging ) ;
document . removeEventListener ( "mouseup" , releasing ) ;
} ;
document . addEventListener ( "mousemove" , dragging ) ;
document . addEventListener ( "mouseup" , releasing ) ;
}
} ;
2020-12-15 13:27:07 +01:00
let mouseUp = _ => {
document . removeEventListener ( "mousemove" , mouseMove ) ;
document . removeEventListener ( "mouseup" , mouseUp ) ;
2020-09-19 20:49:33 +02:00
} ;
2020-12-15 13:27:07 +01:00
document . addEventListener ( "mousemove" , mouseMove ) ;
document . addEventListener ( "mouseup" , mouseUp ) ;
2020-09-19 20:49:33 +02:00
}
} ;
e . node . addEventListener ( "mousedown" , e . node . PinDMsMouseDownListener ) ;
}
}
if ( e . returnvalue ) e . returnvalue . props . children = [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TooltipContainer , {
text : BDFDB . LanguageUtils . LanguageStrings . UNPIN ,
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Clickable , {
className : BDFDB . disCN . _pindmsunpinbutton ,
onClick : event => {
BDFDB . ListenerUtils . stopEvent ( event ) ;
2021-04-22 12:17:32 +02:00
this . removeFromCategory ( e . instance . props . channel . id , category , "channelList" ) ;
2020-09-19 20:49:33 +02:00
} ,
children : BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SvgIcon , {
className : BDFDB . disCN . _pindmsunpinicon ,
name : BDFDB . LibraryComponents . SvgIcon . Names . PIN
} )
} )
} ) ,
e . returnvalue . props . children
] . flat ( 10 ) . filter ( n => n ) ;
2020-02-11 17:05:06 +01:00
}
2019-11-21 14:56:53 +01:00
}
2020-02-11 17:05:06 +01:00
}
2020-09-19 20:49:33 +02:00
processDirectMessage ( e ) {
if ( e . instance . props . channel ) {
2021-05-06 19:36:45 +02:00
if ( e . node ) {
if ( e . methodname == "componentDidMount" ) {
BDFDB . DOMUtils . removeClass ( e . node , BDFDB . disCN . _pindmsrecentpinned ) ;
e . node . removeEventListener ( "contextmenu" , e . node . PinDMsContextMenuListener ) ;
e . node . addEventListener ( "contextmenu" , e . node . PinDMsContextMenuListener ) ;
if ( this . isPinnedInGuilds ( e . instance . props . channel . id ) ) {
BDFDB . DOMUtils . addClass ( e . node , BDFDB . disCN . _pindmsrecentpinned ) ;
e . node . removeEventListener ( "mousedown" , e . node . PinDMsMouseDownListener ) ;
if ( ! this . settings . recentOrder . guildList ) {
for ( let child of e . node . querySelectorAll ( "a" ) ) child . setAttribute ( "draggable" , false ) ;
e . node . PinDMsMouseDownListener = event => {
let mousemove = event2 => {
if ( Math . sqrt ( ( event . pageX - event2 . pageX ) * * 2 ) > 20 || Math . sqrt ( ( event . pageY - event2 . pageY ) * * 2 ) > 20 ) {
BDFDB . ListenerUtils . stopEvent ( event ) ;
draggedChannel = e . instance . props . channel . id ;
BDFDB . PatchUtils . forceAllUpdates ( this , "UnreadDMs" ) ;
let dragPreview = this . createDragPreview ( e . node , event2 ) ;
document . removeEventListener ( "mousemove" , mousemove ) ;
document . removeEventListener ( "mouseup" , mouseup ) ;
let dragging = event3 => {
this . updateDragPreview ( dragPreview , event3 ) ;
let placeholder = BDFDB . DOMUtils . getParent ( BDFDB . dotCN . _pindmsrecentplaceholder , event3 . target ) ;
let maybeHoveredChannel = ( BDFDB . ReactUtils . findValue ( BDFDB . DOMUtils . getParent ( BDFDB . dotCN . _pindmsrecentpinned , placeholder ? placeholder . previousSibling : event3 . target ) , "channel" , { up : true } ) || { } ) . id ;
let update = maybeHoveredChannel != hoveredChannel ;
if ( maybeHoveredChannel ) hoveredChannel = maybeHoveredChannel ;
else hoveredChannel = null ;
if ( update ) BDFDB . PatchUtils . forceAllUpdates ( this , "UnreadDMs" ) ;
} ;
let releasing = event3 => {
BDFDB . DOMUtils . remove ( dragPreview ) ;
if ( hoveredChannel ) releasedChannel = hoveredChannel ;
else draggedChannel = null ;
hoveredChannel = null ;
BDFDB . PatchUtils . forceAllUpdates ( this , "UnreadDMs" ) ;
document . removeEventListener ( "mousemove" , dragging ) ;
document . removeEventListener ( "mouseup" , releasing ) ;
} ;
document . addEventListener ( "mousemove" , dragging ) ;
document . addEventListener ( "mouseup" , releasing ) ;
}
} ;
let mouseup = _ => {
2020-02-11 17:05:06 +01:00
document . removeEventListener ( "mousemove" , mousemove ) ;
document . removeEventListener ( "mouseup" , mouseup ) ;
2021-05-06 19:36:45 +02:00
} ;
document . addEventListener ( "mousemove" , mousemove ) ;
document . addEventListener ( "mouseup" , mouseup ) ;
2020-02-11 17:05:06 +01:00
} ;
2021-05-06 19:36:45 +02:00
e . node . addEventListener ( "mousedown" , e . node . PinDMsMouseDownListener ) ;
}
2020-09-19 20:49:33 +02:00
}
2020-02-11 17:05:06 +01:00
}
2021-05-06 19:36:45 +02:00
if ( e . methodname == "componentWillUnmount" ) {
if ( this . getChannelListCategory ( e . instance . props . channel . id ) ) BDFDB . PatchUtils . forceAllUpdates ( this , "PrivateChannelsList" ) ;
}
2020-01-05 17:46:10 +01:00
}
2021-05-06 19:36:45 +02:00
if ( e . returnvalue ) {
if ( this . settings . general . pinIcon && this . isPinnedInGuilds ( e . instance . props . channel . id ) ) {
let [ children , index ] = BDFDB . ReactUtils . findParent ( e . returnvalue , { name : "BlobMask" } ) ;
if ( index > - 1 ) children [ index ] . props . upperLeftBadge = BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Badges . IconBadge , {
className : BDFDB . disCN . guildiconbadge ,
disableColor : true ,
style : { transform : "scale(-1, 1)" } ,
icon : BDFDB . LibraryComponents . SvgIcon . Names . NOVA _PIN
} ) ;
}
if ( this . getChannelListCategory ( e . instance . props . channel . id ) ) BDFDB . PatchUtils . forceAllUpdates ( this , "PrivateChannelsList" ) ;
2020-09-19 20:49:33 +02:00
}
2019-11-21 14:56:53 +01:00
}
}
2021-04-22 12:17:32 +02:00
getPinnedChannels ( type ) {
return ( ( BDFDB . DataUtils . load ( this , "pinned" , BDFDB . UserUtils . me . id ) || { } ) [ type ] || { } ) ;
}
savePinnedChannels ( channels , type ) {
let pinned = BDFDB . DataUtils . load ( this , "pinned" , BDFDB . UserUtils . me . id ) || { } ;
if ( BDFDB . ObjectUtils . is ( channels ) && ! BDFDB . ObjectUtils . isEmpty ( channels ) ) pinned [ type ] = channels ;
else delete pinned [ type ] ;
if ( ! BDFDB . ObjectUtils . isEmpty ( pinned ) ) BDFDB . DataUtils . save ( pinned , this , "pinned" , BDFDB . UserUtils . me . id ) ;
else BDFDB . DataUtils . remove ( this , "pinned" , BDFDB . UserUtils . me . id ) ;
}
2019-02-05 14:23:34 +01:00
2020-09-19 20:49:33 +02:00
generateID ( type ) {
if ( ! type ) return null ;
2021-04-22 12:17:32 +02:00
let categories = this . getPinnedChannels ( type ) ;
2020-09-19 20:49:33 +02:00
let id = Math . round ( Math . random ( ) * 10000000000000000 ) ;
return categories [ id ] ? this . generateID ( ) : id ;
}
2020-12-15 13:27:07 +01:00
filterDMs ( dms , removePredefined ) {
return dms . filter ( id => BDFDB . LibraryModules . ChannelStore . getChannel ( id ) && ! ( removePredefined && this . getPredefinedCategory ( id ) ) ) ;
2020-09-19 20:49:33 +02:00
}
2020-01-05 14:01:45 +01:00
2020-09-19 20:49:33 +02:00
addToCategory ( id , category , type ) {
if ( ! id || ! category || ! type ) return ;
let wasEmpty = ! this . filterDMs ( category . dms ) . length ;
if ( ! category . dms . includes ( id ) ) category . dms . unshift ( id ) ;
2021-04-22 12:17:32 +02:00
this . savePinnedChannels ( Object . assign ( { } , this . getPinnedChannels ( type ) , { [ category . id ] : category } ) , type ) ;
2020-09-19 20:49:33 +02:00
if ( wasEmpty && category . dms . length ) category . collapsed = false ;
this . updateContainer ( type ) ;
}
2020-01-05 14:01:45 +01:00
2020-09-19 20:49:33 +02:00
removeFromCategory ( id , category , type ) {
if ( ! id || ! category || ! type ) return ;
BDFDB . ArrayUtils . remove ( category . dms , id , true ) ;
if ( ! this . filterDMs ( category . dms ) . length ) category . collapsed = true ;
2021-04-22 12:17:32 +02:00
this . savePinnedChannels ( Object . assign ( { } , this . getPinnedChannels ( type ) , { [ category . id ] : category } ) , type ) ;
2020-09-19 20:49:33 +02:00
this . updateContainer ( type ) ;
}
2020-01-05 14:01:45 +01:00
2021-05-06 19:36:45 +02:00
getChannelListCategory ( id ) {
if ( ! id ) return null ;
let categories = this . getPinnedChannels ( "channelList" ) ;
2020-09-19 20:49:33 +02:00
for ( let catId in categories ) if ( categories [ catId ] . dms . includes ( id ) ) return categories [ catId ] ;
return null ;
}
2020-12-15 13:27:07 +01:00
getPredefinedCategory ( id ) {
if ( ! id ) return "" ;
let channel = BDFDB . LibraryModules . ChannelStore . getChannel ( id ) ;
if ( ! channel ) return "" ;
2021-04-22 12:17:32 +02:00
else if ( this . settings . preCategories . friends . enabled && channel . isDM ( ) && BDFDB . LibraryModules . RelationshipStore . isFriend ( channel . recipients [ 0 ] ) ) return "friends" ;
else if ( this . settings . preCategories . blocked . enabled && channel . isDM ( ) && BDFDB . LibraryModules . RelationshipStore . isBlocked ( channel . recipients [ 0 ] ) ) return "blocked" ;
else if ( this . settings . preCategories . groups . enabled && channel . isGroupDM ( ) ) return "groups" ;
2020-12-15 13:27:07 +01:00
return "" ;
}
2020-01-05 14:01:45 +01:00
2020-09-19 20:49:33 +02:00
sortAndUpdateCategories ( type , reverse ) {
2021-04-22 12:17:32 +02:00
let data = BDFDB . ObjectUtils . sort ( this . getPinnedChannels ( type ) , "pos" ) , newData = { } ;
2020-09-19 20:49:33 +02:00
let sorted = [ ] , pos = 0 , sort = id => {
if ( sorted [ pos ] === undefined ) {
newData [ id ] = Object . assign ( { } , data [ id ] , { pos } ) ;
sorted [ pos ] = newData [ id ] ;
}
else {
pos ++ ;
sort ( id ) ;
}
} ;
for ( let id in data ) sort ( id ) ;
2021-04-22 12:17:32 +02:00
if ( ! BDFDB . equals ( data , newData ) ) this . savePinnedChannels ( newData , type ) ;
if ( type == "channelList" && Object . keys ( this . settings . preCategories ) . some ( type => this . settings . preCategories [ type ] . enabled ) ) {
2020-12-15 13:27:07 +01:00
let predefinedDMs = { } ;
for ( let channelId of BDFDB . LibraryModules . DirectMessageStore . getPrivateChannelIds ( ) ) {
let category = this . getPredefinedCategory ( channelId ) ;
if ( category ) {
if ( ! predefinedDMs [ category ] ) predefinedDMs [ category ] = [ ] ;
predefinedDMs [ category ] . push ( channelId ) ;
}
}
for ( let type in predefinedDMs ) if ( predefinedDMs [ type ] . length ) sorted . unshift ( {
predefined : true ,
2021-04-22 12:17:32 +02:00
collapsed : this . settings . preCategories [ type ] . collapsed ,
2020-12-15 13:27:07 +01:00
color : null ,
dms : predefinedDMs [ type ] ,
id : type ,
name : BDFDB . LanguageUtils . LanguageStrings [ this . defaults . preCategories [ type ] . description ]
} ) ;
}
2020-09-19 20:49:33 +02:00
return ( reverse ? sorted . reverse ( ) : sorted ) . filter ( n => n ) ;
}
sortDMsByTime ( dms , type ) {
2021-04-22 12:17:32 +02:00
if ( dms . length > 1 && this . settings . recentOrder [ type ] ) {
2020-09-19 20:49:33 +02:00
let timestamps = BDFDB . LibraryModules . DirectMessageStore . getPrivateChannelIds ( ) . reduce ( ( newObj , channelId ) => ( newObj [ channelId ] = BDFDB . LibraryModules . UnreadChannelUtils . lastMessageId ( channelId ) , newObj ) , { } ) ;
return [ ] . concat ( dms ) . sort ( function ( x , y ) { return timestamps [ x ] > timestamps [ y ] ? - 1 : timestamps [ x ] < timestamps [ y ] ? 1 : 0 ; } ) ;
2020-02-11 17:05:06 +01:00
}
2020-09-19 20:49:33 +02:00
else return dms ;
2020-01-05 14:01:45 +01:00
}
2020-09-19 20:49:33 +02:00
openCategorySettingsModal ( data , type , isNew ) {
2021-01-29 18:39:02 +01:00
if ( ! BDFDB . ObjectUtils . is ( data ) || ! type ) return ;
let newData = Object . assign ( { } , data ) ;
BDFDB . ModalUtils . open ( this , {
2020-09-19 20:49:33 +02:00
size : "MEDIUM" ,
header : BDFDB . LanguageUtils . LanguageStrings . CATEGORY _SETTINGS ,
2021-01-23 18:50:24 +01:00
subHeader : data . name ,
2020-09-19 20:49:33 +02:00
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormItem , {
title : BDFDB . LanguageUtils . LanguageStrings . CATEGORY _NAME ,
className : BDFDB . disCN . marginbottom20 + " input-categoryname" ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TextInput , {
value : data . name ,
placeholder : data . name ,
2021-01-29 18:39:02 +01:00
autoFocus : true ,
2021-01-29 20:04:13 +01:00
onChange : value => { newData . name = value ; }
2020-09-19 20:49:33 +02:00
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormDivider , {
className : BDFDB . disCN . dividerdefault
} )
]
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormItem , {
2020-12-21 19:56:36 +01:00
title : this . labels . modal _colorpicker1 ,
2020-09-19 20:49:33 +02:00
className : BDFDB . disCN . marginbottom20 ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ColorSwatches , {
color : data . color ,
2021-01-29 20:04:13 +01:00
onColorChange : value => { newData . color = value ; }
2020-09-19 20:49:33 +02:00
} )
]
} )
] ,
buttons : [ {
contents : isNew ? BDFDB . LanguageUtils . LanguageStrings . CREATE : BDFDB . LanguageUtils . LanguageStrings . SAVE ,
color : "BRAND" ,
close : true ,
2021-01-29 18:39:02 +01:00
onClick : _ => {
if ( newData . color != null && ! BDFDB . ObjectUtils . is ( newData . color ) ) {
if ( newData . color [ 0 ] < 30 && newData . color [ 1 ] < 30 && newData . color [ 2 ] < 30 ) newData . color = BDFDB . ColorUtils . change ( newData . color , 30 ) ;
else if ( newData . color [ 0 ] > 225 && newData . color [ 1 ] > 225 && newData . color [ 2 ] > 225 ) newData . color = BDFDB . ColorUtils . change ( newData . color , - 30 ) ;
2020-09-19 20:49:33 +02:00
}
2021-04-22 12:17:32 +02:00
this . savePinnedChannels ( Object . assign ( { } , this . getPinnedChannels ( type ) , { [ data . id ] : newData } ) , type ) ;
2020-09-19 20:49:33 +02:00
this . updateContainer ( type ) ;
2020-02-11 17:05:06 +01:00
}
2020-09-19 20:49:33 +02:00
} ]
} ) ;
2020-02-11 17:05:06 +01:00
}
2019-01-26 22:45:19 +01:00
2021-04-23 10:51:38 +02:00
addPin ( id , type ) {
if ( ! id ) return ;
2021-04-22 12:17:32 +02:00
let channels = this . getPinnedChannels ( type ) ;
2021-04-23 10:51:38 +02:00
for ( let i in channels ) channels [ i ] = channels [ i ] + 1 ;
channels [ id ] = 0 ;
2021-04-22 12:17:32 +02:00
this . savePinnedChannels ( channels , type ) ;
2020-09-19 20:49:33 +02:00
this . updateContainer ( type ) ;
2020-02-11 17:05:06 +01:00
}
2019-01-26 22:45:19 +01:00
2020-09-19 20:49:33 +02:00
removePin ( id , type ) {
if ( ! id ) return ;
2021-04-23 10:51:38 +02:00
let channels = this . getPinnedChannels ( type ) ;
delete channels [ id ] ;
this . savePinnedChannels ( channels , type ) ;
2020-09-19 20:49:33 +02:00
this . updateContainer ( type ) ;
}
2020-07-02 09:54:10 +02:00
2021-05-06 19:36:45 +02:00
isPinnedInGuilds ( id ) {
return this . getPinnedChannels ( "guildList" ) [ id ] != undefined ;
2020-09-19 20:49:33 +02:00
}
updateContainer ( type ) {
switch ( type ) {
2021-04-22 12:17:32 +02:00
case "channelList" :
2020-09-19 20:49:33 +02:00
BDFDB . PatchUtils . forceAllUpdates ( this , "PrivateChannelsList" ) ;
2021-04-22 12:17:32 +02:00
if ( ! Object . keys ( this . settings . preCategories ) . every ( type => this . settings . preCategories [ type ] . enabled ) && BDFDB . ObjectUtils . isEmpty ( this . getPinnedChannels ( type ) ) ) this . forceUpdateAll ( ) ;
2020-09-19 20:49:33 +02:00
break ;
2021-04-22 12:17:32 +02:00
case "guildList" :
2020-09-19 20:49:33 +02:00
BDFDB . PatchUtils . forceAllUpdates ( this , "UnreadDMs" ) ;
break ;
}
}
2019-09-04 12:34:02 +02:00
2020-09-19 20:49:33 +02:00
sortAndUpdate ( type ) {
2021-04-22 12:17:32 +02:00
let data = this . getPinnedChannels ( type ) , newData = { } ;
2020-09-19 20:49:33 +02:00
delete data [ "" ] ;
delete data [ "null" ] ;
let sortedDMs = [ ] , existingDMs = [ ] , sortDM = ( id , pos ) => {
if ( sortedDMs [ pos ] === undefined ) sortedDMs [ pos ] = id ;
else sortDM ( id , pos + 1 ) ;
} ;
for ( let id in data ) sortDM ( id , data [ id ] ) ;
sortedDMs = sortedDMs . filter ( n => n ) ;
for ( let pos in sortedDMs ) {
newData [ sortedDMs [ pos ] ] = parseInt ( pos ) ;
if ( BDFDB . LibraryModules . ChannelStore . getChannel ( sortedDMs [ pos ] ) ) existingDMs . push ( sortedDMs [ pos ] ) ;
}
2021-04-22 12:17:32 +02:00
if ( ! BDFDB . equals ( data , newData ) ) this . savePinnedChannels ( newData , this ) ;
2020-09-19 20:49:33 +02:00
return this . sortDMsByTime ( existingDMs , type ) ;
}
2020-04-24 19:33:47 +02:00
2020-09-19 20:49:33 +02:00
createDragPreview ( div , event ) {
if ( ! Node . prototype . isPrototypeOf ( div ) ) return ;
let dragPreview = div . cloneNode ( true ) ;
BDFDB . DOMUtils . addClass ( dragPreview , BDFDB . disCN . _pindmsdragpreview ) ;
BDFDB . DOMUtils . remove ( dragPreview . querySelector ( BDFDB . dotCNC . guildlowerbadge + BDFDB . dotCNC . guildupperbadge + BDFDB . dotCN . guildpillwrapper ) ) ;
document . querySelector ( BDFDB . dotCN . appmount ) . appendChild ( dragPreview ) ;
let rects = BDFDB . DOMUtils . getRects ( dragPreview ) ;
BDFDB . DOMUtils . hide ( dragPreview ) ;
dragPreview . style . setProperty ( "pointer-events" , "none" , "important" ) ;
dragPreview . style . setProperty ( "left" , event . clientX - ( rects . width / 2 ) + "px" , "important" ) ;
dragPreview . style . setProperty ( "top" , event . clientY - ( rects . height / 2 ) + "px" , "important" ) ;
return dragPreview ;
}
2019-04-26 23:16:20 +02:00
2020-09-19 20:49:33 +02:00
updateDragPreview ( dragPreview , event ) {
if ( ! Node . prototype . isPrototypeOf ( dragPreview ) ) return ;
BDFDB . DOMUtils . show ( dragPreview ) ;
let rects = BDFDB . DOMUtils . getRects ( dragPreview ) ;
dragPreview . style . setProperty ( "left" , event . clientX - ( rects . width / 2 ) + "px" , "important" ) ;
dragPreview . style . setProperty ( "top" , event . clientY - ( rects . height / 2 ) + "px" , "important" ) ;
2020-02-11 17:05:06 +01:00
}
2020-07-26 17:02:25 +02:00
2021-01-06 12:38:36 +01:00
setLabelsByLanguage ( ) {
2020-09-19 20:49:33 +02:00
switch ( BDFDB . LanguageUtils . getLanguage ( ) . id ) {
2020-12-21 19:56:36 +01:00
case "bg" : // Bulgarian
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "Добавяне към нова категория" ,
context _disablepredefined : "Деактивирайте предварително определена категория" ,
context _inpredefined : "Фиксирано в предварително дефинирана категория" ,
context _pinchannel : "Фиксиране към списъка с канали" ,
context _pindm : "Закачете директно съобщение" ,
context _pinguild : "Фиксиране към списъка със сървъри" ,
context _unpinchannel : "Отделяне от списъка с канали" ,
context _unpinguild : "Отделете от списъка със сървъри" ,
header _pinneddms : "Закачени директни съобщения" ,
modal _colorpicker1 : "Категория цвят"
2020-09-19 20:49:33 +02:00
} ;
2021-06-25 16:06:39 +02:00
case "cs" : // Czech
return {
context _addtonewcategory : "Přidat do nové kategorie" ,
context _disablepredefined : "Deaktivovat předdefinovanou kategorii" ,
context _inpredefined : "Připnuté v předdefinované katrgorii" ,
context _pinchannel : "Připnout do seznamu kanálů" ,
context _pindm : "Připnout do PZ" ,
context _pinguild : "Připnout do seznamu serverů" ,
context _unpinchannel : "Odepnout ze seznamu kanálů" ,
context _unpinguild : "Odepnout ze seznamu serverů" ,
header _pinneddms : "Připnuté přímé zprávy" ,
modal _colorpicker1 : "Barva kategorie"
} ;
2020-12-21 19:56:36 +01:00
case "da" : // Danish
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "Føj til ny kategori" ,
context _disablepredefined : "Deaktiver foruddefineret kategori" ,
context _inpredefined : "Fastgjort i en foruddefineret kategori" ,
context _pinchannel : "Fastgør til kanallisten" ,
context _pindm : "Pin direkte besked" ,
context _pinguild : "Fastgør til serverlisten" ,
context _unpinchannel : "Fjern fra kanallisten" ,
context _unpinguild : "Fjern fra serverlisten" ,
header _pinneddms : "Fastgjorte direkte beskeder" ,
modal _colorpicker1 : "Kategorifarve"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "de" : // German
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "Zur neuen Kategorie hinzufügen" ,
context _disablepredefined : "Vordefinierte Kategorie deaktivieren" ,
context _inpredefined : "In vordefinierter Kategorie angeheftet" ,
context _pinchannel : "An Kanalliste anheften" ,
context _pindm : "Direktnachricht anheften" ,
context _pinguild : "An Serverliste anheften" ,
context _unpinchannel : "Von Kanalliste loslösen" ,
context _unpinguild : "Von Serverliste loslösen" ,
header _pinneddms : "Gepinnte Direktnachrichten" ,
modal _colorpicker1 : "Kategoriefarbe"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "el" : // Greek
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "Προσθήκη σε νέα κατηγορία" ,
context _disablepredefined : "Απενεργοποίηση προκαθορισμένης κατηγορίας" ,
context _inpredefined : "Καρφιτσώθηκε σε μια προκαθορισμένη κατηγορία" ,
context _pinchannel : "Καρφίτσωμα στη λίστα καναλιών" ,
context _pindm : "Καρφιτσώστε το άμεσο μήνυμα" ,
context _pinguild : "Καρφίτσωμα στη λίστα διακομιστών" ,
context _unpinchannel : "Αποσύνδεση από τη λίστα καναλιών" ,
context _unpinguild : "Αποσύνδεση από τη λίστα διακομιστών" ,
header _pinneddms : "Καρφιτσωμένα άμεσα μηνύματα" ,
modal _colorpicker1 : "Χρώμα κατηγορίας"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "es" : // Spanish
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "Agregar a una nueva categoría" ,
context _disablepredefined : "Desactivar categoría predefinida" ,
context _inpredefined : "Anclado en una categoría predefinida" ,
context _pinchannel : "Anclar a la lista de canales" ,
context _pindm : "Pin de mensaje directo" ,
context _pinguild : "Anclar a la lista de servidores" ,
context _unpinchannel : "Separar de la lista de canales" ,
context _unpinguild : "Separar de la lista de servidores" ,
header _pinneddms : "Mensajes directos fijados" ,
modal _colorpicker1 : "Color de categoría"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "fi" : // Finnish
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "Lisää uuteen luokkaan" ,
context _disablepredefined : "Poista ennalta määritetty luokka käytöstä" ,
context _inpredefined : "Kiinnitetty ennalta määritettyyn luokkaan" ,
context _pinchannel : "Kiinnitä kanavaluetteloon" ,
context _pindm : "Kiinnitä suora viesti" ,
context _pinguild : "Kiinnitä palvelinluetteloon" ,
context _unpinchannel : "Irrota kanavaluettelosta" ,
context _unpinguild : "Irrota palvelinluettelosta" ,
header _pinneddms : "Kiinnitetyt suorat viestit" ,
modal _colorpicker1 : "Luokan väri"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "fr" : // French
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "Ajouter à une nouvelle catégorie" ,
context _disablepredefined : "Désactiver la catégorie prédéfinie" ,
context _inpredefined : "Épinglé dans une catégorie prédéfinie" ,
context _pinchannel : "Épingler à la liste des salons" ,
context _pindm : "Épingler le message privé" ,
context _pinguild : "Épingler à la liste des serveurs" ,
context _unpinchannel : "Détacher de la liste des salons" ,
context _unpinguild : "Détacher de la liste des serveurs" ,
header _pinneddms : "Messages privés épinglés" ,
modal _colorpicker1 : "Couleur de la catégorie"
2020-09-19 20:49:33 +02:00
} ;
2021-06-25 16:06:39 +02:00
case "hi" : // Hindi
return {
context _addtonewcategory : "नई श्रेणी में जोड़ें" ,
context _disablepredefined : "पूर्वनिर्धारित श्रेणी को निष्क्रिय करें" ,
context _inpredefined : "एक पूर्वनिर्धारित श्रेणी में पिन किया गया" ,
context _pinchannel : "चैनल सूची में पिन करें" ,
context _pindm : "पिन डीएम" ,
context _pinguild : "सर्वर सूची में पिन करें" ,
context _unpinchannel : "चैनल सूची से अलग करें" ,
context _unpinguild : "सर्वर सूची से अलग करें" ,
header _pinneddms : "पिन किए गए सीधे संदेश" ,
modal _colorpicker1 : "श्रेणी रंग"
} ;
2020-12-21 19:56:36 +01:00
case "hr" : // Croatian
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "Dodaj u novu kategoriju" ,
context _disablepredefined : "Deaktivirajte unaprijed definiranu kategoriju" ,
context _inpredefined : "Prikvačeno u unaprijed definiranoj kategoriji" ,
context _pinchannel : "Prikvači na popis kanala" ,
context _pindm : "Prikvači izravnu poruku" ,
context _pinguild : "Prikvači na popis poslužitelja" ,
context _unpinchannel : "Odvojite se od popisa kanala" ,
context _unpinguild : "Odvojite se od popisa poslužitelja" ,
header _pinneddms : "Prikvačene izravne poruke" ,
modal _colorpicker1 : "Boja kategorije"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "hu" : // Hungarian
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "Hozzáadás új kategóriához" ,
context _disablepredefined : "Deaktiválja az előre definiált kategóriát" ,
context _inpredefined : "Előre meghatározott kategóriában rögzítve" ,
context _pinchannel : "Rögzítés a csatornalistához" ,
context _pindm : "Közvetlen üzenet rögzítése" ,
context _pinguild : "Rögzítés a kiszolgáló listához" ,
context _unpinchannel : "Leválasztás a csatornalistáról" ,
context _unpinguild : "Leválasztás a kiszolgáló listáról" ,
header _pinneddms : "Rögzített közvetlen üzenetek" ,
modal _colorpicker1 : "Kategória színe"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "it" : // Italian
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "Aggiungi a una nuova categoria" ,
context _disablepredefined : "Disattiva la categoria predefinita" ,
context _inpredefined : "Bloccato in una categoria predefinita" ,
context _pinchannel : "Fissa all'elenco dei canali" ,
context _pindm : "Metti il messaggio diretto" ,
context _pinguild : "Aggiungi all'elenco dei server" ,
context _unpinchannel : "Scollega dall'elenco dei canali" ,
context _unpinguild : "Scollega dall'elenco dei server" ,
header _pinneddms : "Messaggi diretti appuntati" ,
modal _colorpicker1 : "Colore della categoria"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "ja" : // Japanese
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "新しいカテゴリに追加" ,
context _disablepredefined : "事前定義されたカテゴリを非アクティブ化" ,
context _inpredefined : "事前定義されたカテゴリに固定" ,
context _pinchannel : "チャネルリストに固定" ,
context _pindm : "ダイレクトメッセージを固定する" ,
context _pinguild : "サーバーリストに固定する" ,
context _unpinchannel : "チャネルリストから切り離す" ,
context _unpinguild : "サーバーリストから切り離す" ,
header _pinneddms : "固定されたダイレクトメッセージ" ,
modal _colorpicker1 : "カテゴリカラー"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "ko" : // Korean
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "새 카테고리에 추가" ,
context _disablepredefined : "사전 정의 된 카테고리 비활성화" ,
context _inpredefined : "사전 정의 된 카테고리에 고정됨" ,
context _pinchannel : "채널 목록에 고정" ,
context _pindm : "쪽지 고정" ,
context _pinguild : "서버 목록에 고정" ,
context _unpinchannel : "채널 목록에서 분리" ,
context _unpinguild : "서버 목록에서 분리" ,
header _pinneddms : "고정 된 쪽지" ,
modal _colorpicker1 : "카테고리 색상"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "lt" : // Lithuanian
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "Pridėti prie naujos kategorijos" ,
context _disablepredefined : "Išjunkite iš anksto nustatytą kategoriją" ,
context _inpredefined : "Prisegta iš anksto nustatytoje kategorijoje" ,
context _pinchannel : "Prisegti prie kanalų sąrašo" ,
context _pindm : "Prisegti tiesioginį pranešimą" ,
context _pinguild : "Prisegti prie serverio sąrašo" ,
context _unpinchannel : "Atsijungti nuo kanalų sąrašo" ,
context _unpinguild : "Atsijungti nuo serverio sąrašo" ,
header _pinneddms : "Prisegti tiesioginiai pranešimai" ,
modal _colorpicker1 : "Kategorijos spalva"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "nl" : // Dutch
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "Toevoegen aan nieuwe categorie" ,
context _disablepredefined : "Schakel de voorgedefinieerde categorie uit" ,
context _inpredefined : "Vastgezet in een vooraf gedefinieerde categorie" ,
context _pinchannel : "Vastzetten op kanalenlijst" ,
context _pindm : "Direct bericht vastzetten" ,
context _pinguild : "Vastzetten op serverlijst" ,
context _unpinchannel : "Maak los van de zenderlijst" ,
context _unpinguild : "Maak los van de serverlijst" ,
header _pinneddms : "Vastgezette directe berichten" ,
modal _colorpicker1 : "Categorie kleur"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "no" : // Norwegian
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "Legg til i ny kategori" ,
context _disablepredefined : "Deaktiver forhåndsdefinert kategori" ,
context _inpredefined : "Festet i en forhåndsdefinert kategori" ,
context _pinchannel : "Fest til kanallisten" ,
context _pindm : "Fest direkte melding" ,
context _pinguild : "Fest til serverlisten" ,
context _unpinchannel : "Koble fra kanallisten" ,
context _unpinguild : "Koble fra serverlisten" ,
header _pinneddms : "Festede direktemeldinger" ,
modal _colorpicker1 : "Kategorifarge"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "pl" : // Polish
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "Dodaj do nowej kategorii" ,
context _disablepredefined : "Dezaktywuj predefiniowaną kategorię" ,
context _inpredefined : "Przypięty w predefiniowanej kategorii" ,
context _pinchannel : "Przypnij do listy kanałów" ,
context _pindm : "Przypnij bezpośrednią wiadomość" ,
context _pinguild : "Przypnij do listy serwerów" ,
context _unpinchannel : "Odłącz od listy kanałów" ,
context _unpinguild : "Odłącz od listy serwerów" ,
header _pinneddms : "Przypięte czaty" ,
modal _colorpicker1 : "Kolor kategorii"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "pt-BR" : // Portuguese (Brazil)
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "Adicionar à nova categoria" ,
context _disablepredefined : "Desativar categoria predefinida" ,
context _inpredefined : "Fixado em uma categoria predefinida" ,
context _pinchannel : "Fixar na lista de canais" ,
context _pindm : "Fixar mensagem direta" ,
context _pinguild : "Fixar na lista de servidores" ,
context _unpinchannel : "Desanexar da lista de canais" ,
context _unpinguild : "Desanexar da lista de servidores" ,
header _pinneddms : "Mensagens diretas fixadas" ,
modal _colorpicker1 : "Cor da categoria"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "ro" : // Romanian
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "Adăugați la o nouă categorie" ,
context _disablepredefined : "Dezactivați categoria predefinită" ,
context _inpredefined : "Fixat într-o categorie predefinită" ,
context _pinchannel : "Fixați în lista de canale" ,
context _pindm : "Fixați mesajul direct" ,
context _pinguild : "Fixați pe lista serverului" ,
context _unpinchannel : "Desprindeți din lista de canale" ,
context _unpinguild : "Desprindeți din lista serverelor" ,
header _pinneddms : "Mesaje directe fixate" ,
modal _colorpicker1 : "Culoarea categoriei"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "ru" : // Russian
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "Добавить в новую категорию" ,
context _disablepredefined : "Отключить предопределенную категорию" ,
context _inpredefined : "Закреплено в предопределенной категории" ,
context _pinchannel : "Закрепить в списке каналов" ,
context _pindm : "Закрепить прямую переписку" ,
context _pinguild : "Закрепить в списке серверов" ,
context _unpinchannel : "Отключить от списка каналов" ,
context _unpinguild : "Отключить от списка серверов" ,
header _pinneddms : "Закрепленные личные сообщения" ,
modal _colorpicker1 : "Цвет категории"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "sv" : // Swedish
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "Lägg till i ny kategori" ,
context _disablepredefined : "Inaktivera fördefinierad kategori" ,
context _inpredefined : "Fästs i en fördefinierad kategori" ,
context _pinchannel : "Fäst i kanallistan" ,
context _pindm : "Fäst direktmeddelande" ,
context _pinguild : "Fäst i serverlistan" ,
context _unpinchannel : "Ta bort från kanallistan" ,
context _unpinguild : "Ta bort från serverlistan" ,
header _pinneddms : "Fästa direktmeddelanden" ,
modal _colorpicker1 : "Kategorifärg"
2020-09-19 20:49:33 +02:00
} ;
2020-12-21 19:56:36 +01:00
case "th" : // Thai
2020-09-19 20:49:33 +02:00
return {
2020-12-21 19:56:36 +01:00
context _addtonewcategory : "เพิ่มในหมวดหมู่ใหม่" ,
context _disablepredefined : "ปิดใช้งานหมวดหมู่ที่กำหนดไว้ล่วงหน้า" ,
context _inpredefined : "ตรึงไว้ในหมวดหมู่ที่กำหนดไว้ล่วงหน้า" ,
context _pinchannel : "ตรึงในรายการช่อง" ,
context _pindm : "ตรึงข้อความโดยตรง" ,
context _pinguild : "ปักหมุดรายการเซิร์ฟเวอร์" ,
context _unpinchannel : "แยกออกจากรายการช่อง" ,
context _unpinguild : "แยกออกจากรายการเซิร์ฟเวอร์" ,
header _pinneddms : "ข้อความโดยตรงที่ตรึงไว้" ,
modal _colorpicker1 : "สีหมวดหมู่"
} ;
case "tr" : // Turkish
return {
context _addtonewcategory : "Yeni kategoriye ekle" ,
context _disablepredefined : "Önceden tanı mlanmı ş kategoriyi devre dı şı bı rakı n" ,
context _inpredefined : "Önceden tanı mlanmı ş bir kategoriye sabitlenmiş" ,
context _pinchannel : "Kanal listesine sabitle" ,
context _pindm : "Doğrudan mesajı sabitle" ,
context _pinguild : "Sunucu listesine sabitle" ,
context _unpinchannel : "Kanal listesinden çı kar" ,
context _unpinguild : "Sunucu listesinden ayı r" ,
header _pinneddms : "Sabitlenmiş doğrudan mesajlar" ,
modal _colorpicker1 : "Kategori rengi"
} ;
case "uk" : // Ukrainian
return {
context _addtonewcategory : "Додати до нової категорії" ,
context _disablepredefined : "Вимкнути заздалегідь визначену категорію" ,
context _inpredefined : "Закріплено в наперед визначеній категорії" ,
context _pinchannel : "Закріпити в списку каналів" ,
context _pindm : "Закріпити пряме повідомлення" ,
context _pinguild : "Закріпити на списку серверів" ,
context _unpinchannel : "Від’єднати від списку каналів" ,
context _unpinguild : "Від'єднати від списку серверів" ,
header _pinneddms : "Закріплені прямі повідомлення" ,
modal _colorpicker1 : "Колір категорії"
} ;
case "vi" : // Vietnamese
return {
context _addtonewcategory : "Thêm vào danh mục mới" ,
context _disablepredefined : "Hủy kích hoạt danh mục xác định trước" ,
context _inpredefined : "Được ghim trong một danh mục xác định trước" ,
context _pinchannel : "Ghim vào danh sách kênh" ,
context _pindm : "Ghim tin nhắn trực tiếp" ,
context _pinguild : "Ghim vào danh sách máy chủ" ,
context _unpinchannel : "Tách khỏi danh sách kênh" ,
context _unpinguild : "Tách khỏi danh sách máy chủ" ,
header _pinneddms : "Tin nhắn trực tiếp được ghim" ,
modal _colorpicker1 : "Màu sắc"
} ;
2021-01-15 17:54:22 +01:00
case "zh-CN" : // Chinese (China)
2020-12-21 19:56:36 +01:00
return {
context _addtonewcategory : "添加到新类别" ,
context _disablepredefined : "停用预定义类别" ,
context _inpredefined : "固定在预定义的类别中" ,
context _pinchannel : "固定到频道列表" ,
context _pindm : "固定直接讯息" ,
context _pinguild : "固定到服务器列表" ,
context _unpinchannel : "从频道列表中分离" ,
context _unpinguild : "从服务器列表中分离" ,
header _pinneddms : "固定直接讯息" ,
modal _colorpicker1 : "类别颜色"
} ;
2021-01-15 17:54:22 +01:00
case "zh-TW" : // Chinese (Taiwan)
2020-12-21 19:56:36 +01:00
return {
context _addtonewcategory : "添加到新類別" ,
context _disablepredefined : "停用預定義類別" ,
context _inpredefined : "固定在預定義的類別中" ,
context _pinchannel : "固定到頻道列表" ,
context _pindm : "固定直接訊息" ,
context _pinguild : "固定到服務器列表" ,
context _unpinchannel : "從頻道列表中分離" ,
context _unpinguild : "從服務器列表中分離" ,
header _pinneddms : "固定直接訊息" ,
modal _colorpicker1 : "類別顏色"
} ;
default : // English
return {
context _addtonewcategory : "Add to new Category" ,
context _disablepredefined : "Deactivate predefined Category" ,
context _inpredefined : "Pinned in a predefined Category" ,
context _pinchannel : "Pin to Channel List" ,
context _pindm : "Pin DM" ,
context _pinguild : "Pin to Server List" ,
context _unpinchannel : "Detach from Channel List" ,
context _unpinguild : "Detach from Server List" ,
header _pinneddms : "Pinned Direct Messages" ,
modal _colorpicker1 : "Category Color"
2020-09-19 20:49:33 +02:00
} ;
}
}
} ;
2020-10-09 21:09:35 +02:00
} ) ( window . BDFDB _Global . PluginUtils . buildPlugin ( config ) ) ;
2020-12-20 21:32:12 +01:00
} ) ( ) ;