2019-09-20 22:32:52 +02:00
|
|
|
|
//META{"name":"PinDMs","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/PinDMs","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/PinDMs/PinDMs.plugin.js"}*//
|
2018-10-11 10:21:26 +02:00
|
|
|
|
|
|
|
|
|
class PinDMs {
|
2019-01-11 15:32:04 +01:00
|
|
|
|
getName () {return "PinDMs";}
|
|
|
|
|
|
2019-10-18 15:07:30 +02:00
|
|
|
|
getVersion () {return "1.4.9";}
|
2019-01-11 15:32:04 +01:00
|
|
|
|
|
|
|
|
|
getAuthor () {return "DevilBro";}
|
|
|
|
|
|
2019-01-31 18:09:39 +01:00
|
|
|
|
getDescription () {return "Allows you to pin DMs, making them appear at the top of your DMs/Guild-list.";}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-09-04 12:34:02 +02:00
|
|
|
|
constructor () {
|
2019-02-05 14:23:34 +01:00
|
|
|
|
this.changelog = {
|
2019-10-18 15:07:30 +02:00
|
|
|
|
"fixed":[["Home/Library/Store","Fixed Pinned DMs not being added while switching to one of the pages"]]
|
2019-02-05 14:23:34 +01:00
|
|
|
|
};
|
2019-09-04 12:34:02 +02:00
|
|
|
|
|
2019-01-11 15:32:04 +01:00
|
|
|
|
this.patchModules = {
|
2019-01-24 22:27:15 +01:00
|
|
|
|
"Guilds":"componentDidMount",
|
2019-02-05 14:23:34 +01:00
|
|
|
|
"PrivateChannel":"componentDidMount",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
"DirectMessage":["componentDidMount","componentDidUpdate","componentWillUnmount"],
|
2019-02-28 10:44:12 +01:00
|
|
|
|
"LazyScroller":"render",
|
|
|
|
|
"StandardSidebarView":"componentWillUnmount"
|
2019-01-11 15:32:04 +01:00
|
|
|
|
};
|
2019-09-04 12:34:02 +02:00
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-09-04 12:34:02 +02:00
|
|
|
|
initConstructor () {
|
2019-03-07 23:56:18 +01:00
|
|
|
|
this.recentDMMarkup =
|
2019-04-24 11:03:10 +02:00
|
|
|
|
`<div class="pinned-dm" style="opacity: 1; height: 56px; transform: scale(1);">
|
|
|
|
|
<div class="${BDFDB.disCN.guildouter}">
|
|
|
|
|
<div class="${BDFDB.disCNS.guildpillwrapper + BDFDB.disCN.dmpill}">
|
2019-04-26 23:16:20 +02:00
|
|
|
|
<span class="${BDFDB.disCN.guildpillitem}" style="opacity: 0; height: 8px; transform: translate3d(0px, 0px, 0px);"></span>
|
2019-04-24 11:03:10 +02:00
|
|
|
|
</div>
|
2019-06-06 17:24:58 +02:00
|
|
|
|
<div class="${BDFDB.disCN.guildinnerwrapper}">
|
2019-06-06 17:15:42 +02:00
|
|
|
|
<div class="${BDFDB.disCN.guildinner}">
|
|
|
|
|
<svg width="48" height="48" viewBox="0 0 48 48" class="${BDFDB.disCN.guildsvg}">
|
|
|
|
|
<mask id="" fill="black" x="0" y="0" width="48" height="48">
|
|
|
|
|
<path d="M0 0 l50 0l0 50l-50 0l0 -50Z" fill="white"></path>
|
|
|
|
|
<rect x="28" y="-4" width="24" height="24" rx="12" ry="12" transform="translate(0 0)" fill="black"></rect>
|
|
|
|
|
<rect x="28" y="28" width="24" height="24" rx="12" ry="12" transform="translate(-20 20)" fill="black"></rect>
|
|
|
|
|
</mask>
|
|
|
|
|
<foreignObject mask="" x="0" y="0" width="48" height="48">
|
|
|
|
|
<a class="${BDFDB.disCN.guildiconwrapper}" draggable="false" style="border-radius: 50%;">
|
|
|
|
|
<img class="${BDFDB.disCN.guildicon}" src="" width="48" height="48" draggable="false"></img>
|
|
|
|
|
</a>
|
|
|
|
|
</foreignObject>
|
|
|
|
|
</svg>
|
2019-10-14 12:31:52 +02:00
|
|
|
|
<div class="${BDFDB.disCN.guildupperbadge} pin-badge" style="opacity: 1; transform: translate(0px, 0px);">
|
|
|
|
|
<div class="${BDFDB.disCNS.guildbadgeiconbadge + BDFDB.disCN.guildbadgeiconbadge2}" style="width: 16px; padding-right: 1px;">
|
|
|
|
|
<svg class="${BDFDB.disCN.guildbadgeicon}" name="Nova_Pin" width="24" height="24" viewBox="0 0 520 520">
|
|
|
|
|
<g fill="white">
|
|
|
|
|
<path d="M291.31, 402.761L109.241, 220.693C79.073, 190.525, 30.166, 190.526, 0, 220.692l291.31, 291.31C321.474, 481.835, 321.476, 432.927, 291.31, 402.761z"></path>
|
|
|
|
|
<polygon points="273.104, 111.449 154.758, 211.589 300.412, 357.242 400.55, 238.898"></polygon>
|
|
|
|
|
<path d="M500.688, 175.174L336.827, 11.313c-15.085-15.085-39.539-15.083-54.621, 0c-15.082, 15.082-15.082, 39.538, 0, 54.62 l163.861, 163.861c15.083, 15.085, 39.539, 15.085, 54.621, 0.001C515.773, 214.712, 515.773, 190.257, 500.688, 175.174z"></path>
|
|
|
|
|
<polygon points="91.032, 366.346 0, 512 145.655, 420.967"></polygon>
|
|
|
|
|
</g>
|
|
|
|
|
</svg>
|
2019-04-24 11:03:10 +02:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2019-10-14 12:31:52 +02:00
|
|
|
|
<div class="${BDFDB.disCN.guildlowerbadge}" style="opacity: 1; transform: translate(0px, 0px); display: none;">
|
|
|
|
|
<div class="${BDFDB.disCN.guildbadgenumberbadge}" style="background-color: rgb(240, 71, 71); width: 16px; padding-right: 1px;">0</div>
|
|
|
|
|
</div>
|
2019-04-24 11:03:10 +02:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>`;
|
|
|
|
|
|
|
|
|
|
this.dragPlaceholderMarkup =
|
|
|
|
|
`<div class="dmplaceholder" style="opacity: 1; height: 56px; transform: scale(1);">
|
|
|
|
|
<div class="${BDFDB.disCN.guildouter}">
|
|
|
|
|
<div class="${BDFDB.disCNS.guildpillwrapper + BDFDB.disCN.dmpill}">
|
|
|
|
|
<span class="${BDFDB.disCN.guildpillitem}"></span>
|
|
|
|
|
</div>
|
2019-06-06 17:30:06 +02:00
|
|
|
|
<div class="${BDFDB.disCN.guildinnerwrapper}">
|
|
|
|
|
<div class="${BDFDB.disCN.guildinner}">
|
|
|
|
|
<svg width="48" height="48" viewBox="0 0 48 48" class="${BDFDB.disCN.guildsvg}">
|
|
|
|
|
<mask id="PINDMSDRAG" fill="black" x="0" y="0" width="48" height="48">
|
|
|
|
|
<path d="M48 24C48 37.2548 37.2548 48 24 48C10.7452 48 0 37.2548 0 24C0 10.7452 10.7452 0 24 0C37.2548 0 48 10.7452 48 24Z" fill="white"></path>
|
|
|
|
|
</mask>
|
|
|
|
|
<foreignObject mask="url(#PINDMSDRAG)" x="0" y="0" width="48" height="48">
|
|
|
|
|
<div class="${BDFDB.disCN.guildplaceholder}"></div>
|
|
|
|
|
</foreignObject>
|
|
|
|
|
</svg>
|
|
|
|
|
</div>
|
2019-01-24 22:27:15 +01:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>`;
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-01-24 22:27:15 +01:00
|
|
|
|
this.css = `
|
2019-02-28 10:44:12 +01:00
|
|
|
|
${BDFDB.dotCN.dmchannel}.pindms-dragpreview,
|
2019-04-24 11:03:10 +02:00
|
|
|
|
.pinned-dm.pindms-dragpreview {
|
2019-02-28 10:44:12 +01:00
|
|
|
|
pointer-events: none !important;
|
|
|
|
|
position: absolute !important;
|
|
|
|
|
opacity: 0.5 !important;
|
|
|
|
|
z-index: 10000 !important;
|
|
|
|
|
}
|
2019-04-24 11:03:10 +02:00
|
|
|
|
.pinned-dm.pindms-dragpreview ${BDFDB.dotCN.guildupperbadge},
|
|
|
|
|
.pinned-dm.pindms-dragpreview ${BDFDB.dotCN.guildlowerbadge} {
|
2019-02-28 10:44:12 +01:00
|
|
|
|
display: none !important;
|
2019-09-11 12:14:43 +02:00
|
|
|
|
}
|
|
|
|
|
${BDFDB.dotCN.dmchannel}.dmchannelplaceholder {
|
|
|
|
|
border: 1px dashed var(--channels-default);
|
2019-02-28 10:44:12 +01:00
|
|
|
|
}`;
|
|
|
|
|
|
|
|
|
|
this.defaults = {
|
|
|
|
|
settings: {
|
|
|
|
|
showPinIcon: {value:true, description:"Shows a little 'Pin' icon for pinned DMs in the server list:"}
|
2019-02-05 14:23:34 +01:00
|
|
|
|
}
|
2019-02-28 10:44:12 +01:00
|
|
|
|
};
|
2019-01-24 22:27:15 +01:00
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-01-24 22:27:15 +01:00
|
|
|
|
getSettingsPanel () {
|
|
|
|
|
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
2019-10-22 23:04:35 +02:00
|
|
|
|
let settings = BDFDB.DataUtils.get(this, "settings");
|
2019-10-09 14:18:28 +02:00
|
|
|
|
var settingshtml = `<div class="${this.name}-settings BDFDB-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.titlesize18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</div><div class="BDFDB-settings-inner">`;
|
2019-02-28 10:44:12 +01:00
|
|
|
|
for (let key in settings) {
|
2019-10-09 14:18:28 +02:00
|
|
|
|
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
|
2019-02-28 10:44:12 +01:00
|
|
|
|
}
|
2019-10-09 14:18:28 +02:00
|
|
|
|
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 0 0 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">Unpin all DMs.</h3><button type="button" class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.button + BDFDB.disCNS.buttonlookfilled + BDFDB.disCNS.buttoncolorred + BDFDB.disCNS.buttonsizemedium + BDFDB.disCN.buttongrow} reset-button" style="flex: 0 0 auto;"><div class="${BDFDB.disCN.buttoncontents}">Reset</div></button></div>`;
|
2019-01-24 22:27:15 +01:00
|
|
|
|
settingshtml += `</div></div>`;
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-10-23 11:10:01 +02:00
|
|
|
|
let settingspanel = BDFDB.DOMUtils.create(settingshtml);
|
2019-01-24 22:27:15 +01:00
|
|
|
|
|
|
|
|
|
BDFDB.initElements(settingspanel, this);
|
|
|
|
|
|
2019-10-22 18:55:25 +02:00
|
|
|
|
BDFDB.ListenerUtils.add(this, settingspanel, "click", ".reset-button", () => {
|
2019-10-30 13:27:14 +01:00
|
|
|
|
BDFDB.ModalUtils.confirm(this, "Are you sure you want to unpin all pinned DMs?", () => {
|
2019-10-22 19:49:57 +02:00
|
|
|
|
BDFDB.DataUtils.remove(this, "pinnedDMs");
|
|
|
|
|
BDFDB.DataUtils.remove(this, "pinnedRecents");
|
2019-01-24 22:27:15 +01:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
return settingspanel;
|
2018-10-11 10:21:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//legacy
|
|
|
|
|
load () {}
|
|
|
|
|
|
|
|
|
|
start () {
|
2019-02-04 09:13:15 +01:00
|
|
|
|
if (!global.BDFDB) global.BDFDB = {myPlugins:{}};
|
|
|
|
|
if (global.BDFDB && global.BDFDB.myPlugins && typeof global.BDFDB.myPlugins == "object") global.BDFDB.myPlugins[this.getName()] = this;
|
2019-05-26 13:55:26 +02:00
|
|
|
|
var libraryScript = document.querySelector('head script#BDFDBLibraryScript');
|
|
|
|
|
if (!libraryScript || (performance.now() - libraryScript.getAttribute("date")) > 600000) {
|
2018-10-11 10:21:26 +02:00
|
|
|
|
if (libraryScript) libraryScript.remove();
|
|
|
|
|
libraryScript = document.createElement("script");
|
2019-05-26 13:55:26 +02:00
|
|
|
|
libraryScript.setAttribute("id", "BDFDBLibraryScript");
|
2018-10-11 10:21:26 +02:00
|
|
|
|
libraryScript.setAttribute("type", "text/javascript");
|
2019-10-18 10:56:41 +02:00
|
|
|
|
libraryScript.setAttribute("src", "https://mwittrien.github.io/BetterDiscordAddons/Plugins/BDFDB.min.js");
|
2019-01-17 23:48:29 +01:00
|
|
|
|
libraryScript.setAttribute("date", performance.now());
|
2019-05-26 13:55:26 +02:00
|
|
|
|
libraryScript.addEventListener("load", () => {this.initialize();});
|
2018-10-11 10:21:26 +02:00
|
|
|
|
document.head.appendChild(libraryScript);
|
|
|
|
|
}
|
2019-01-17 23:48:29 +01:00
|
|
|
|
else if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) this.initialize();
|
2019-11-01 10:27:07 +01:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initialize () {
|
2019-01-17 23:48:29 +01:00
|
|
|
|
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
2019-01-22 11:05:54 +01:00
|
|
|
|
if (this.started) return;
|
2019-10-22 18:55:25 +02:00
|
|
|
|
BDFDB.PluginUtils.init(this);
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-01-11 15:32:04 +01:00
|
|
|
|
this.forceAdding = true;
|
2019-10-22 18:55:25 +02:00
|
|
|
|
BDFDB.ModuleUtils.forceAllUpdates(this);
|
2019-01-11 15:32:04 +01:00
|
|
|
|
delete this.forceAdding;
|
2018-10-11 10:21:26 +02:00
|
|
|
|
}
|
2019-11-01 10:14:50 +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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stop () {
|
2019-01-17 23:48:29 +01:00
|
|
|
|
if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) {
|
2019-10-22 11:37:23 +02:00
|
|
|
|
this.stopping = true;
|
|
|
|
|
|
2019-10-22 18:55:25 +02:00
|
|
|
|
let dmsscrollerinstance = BDFDB.ReactUtils.getInstance(document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller));
|
2019-01-11 15:32:04 +01:00
|
|
|
|
if (dmsscrollerinstance) {
|
|
|
|
|
let dms = dmsscrollerinstance.return.return.return.memoizedProps.children;
|
2018-11-26 23:36:18 +01:00
|
|
|
|
let amount = 0;
|
|
|
|
|
let insertpoint = null;
|
|
|
|
|
for (let i in dms) {
|
|
|
|
|
let ele = dms[i];
|
|
|
|
|
if (ele && ele.pinned) {
|
|
|
|
|
delete ele.pinned;
|
|
|
|
|
if (ele.props.ispin) {
|
2019-10-22 18:55:25 +02:00
|
|
|
|
if (ele && ele.type == "header" || BDFDB.ReactUtils.getValue(ele, "type.displayName") == "ListSectionItem") insertpoint = i;
|
2018-11-26 23:36:18 +01:00
|
|
|
|
amount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dms.splice(insertpoint, amount);
|
2019-01-11 15:32:04 +01:00
|
|
|
|
this.forceUpdateScroller(dmsscrollerinstance.stateNode);
|
2018-11-26 23:36:18 +01:00
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-10-23 11:10:01 +02:00
|
|
|
|
for (let info of BDFDB.DMUtils.getAll()) {
|
2019-01-24 22:27:15 +01:00
|
|
|
|
this.unhideNativeDM(info.id);
|
|
|
|
|
if (info.div) info.div.removeEventListener("contextmenu", info.div.PinDMsContextMenuListener);
|
|
|
|
|
}
|
2019-10-23 11:10:01 +02:00
|
|
|
|
BDFDB.DOMUtils.remove(".pinned-dm", ".dmplaceholder", ".pindms-dragpreview");
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-10-22 18:55:25 +02:00
|
|
|
|
BDFDB.PluginUtils.clear(this);
|
2018-10-11 10:21:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-04 12:34:02 +02:00
|
|
|
|
|
2019-04-26 23:16:20 +02:00
|
|
|
|
onSwitch () {
|
2019-04-29 10:23:27 +02:00
|
|
|
|
for (let pin of document.querySelectorAll(".pinned-dm")) this.updatePinnedRecent(pin.getAttribute("channelid"));
|
2019-04-26 23:16:20 +02:00
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
|
|
|
|
|
2018-10-11 10:21:26 +02:00
|
|
|
|
// begin of own functions
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-09-11 12:14:43 +02:00
|
|
|
|
onUserContextMenu (instance, menu, returnvalue) {
|
|
|
|
|
if (instance.props && instance.props.user && !menu.querySelector(`${this.name}-contextMenuSubItem`)) {
|
2019-10-22 19:38:25 +02:00
|
|
|
|
let [children, index] = BDFDB.ReactUtils.findChildren(returnvalue, {name:"UserCloseChatItem"});
|
2019-09-11 12:14:43 +02:00
|
|
|
|
if (index > -1) {
|
|
|
|
|
let id = BDFDB.LibraryModules.ChannelStore.getDMFromUserId(instance.props.user.id);
|
|
|
|
|
if (id) this.appendItem(menu, id, children, index);
|
2019-10-22 18:55:25 +02:00
|
|
|
|
else BDFDB.LibraryModules.DirectMessageUtils.ensurePrivateChannel(BDFDB.UserUtils.me.id, instance.props.user.id).then(id => {this.appendItem(menu, id, children, index);});
|
2019-01-11 15:32:04 +01:00
|
|
|
|
}
|
2018-10-11 10:21:26 +02:00
|
|
|
|
}
|
2019-01-11 15:32:04 +01:00
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-09-11 12:14:43 +02:00
|
|
|
|
onGroupDMContextMenu (instance, menu, returnvalue) {
|
|
|
|
|
if (instance.props && instance.props.channelId && !menu.querySelector(`${this.name}-contextMenuSubItem`)) {
|
2019-10-22 19:38:25 +02:00
|
|
|
|
let [children, index] = BDFDB.ReactUtils.findChildren(returnvalue, {name:"ChangeIcon"});
|
2019-09-11 12:14:43 +02:00
|
|
|
|
if (index > -1) this.appendItem(menu, instance.props.channelId, children, index);
|
2018-10-11 10:21:26 +02:00
|
|
|
|
}
|
2019-01-11 15:32:04 +01:00
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-09-11 12:14:43 +02:00
|
|
|
|
appendItem (menu, id, children, index) {
|
2019-10-22 19:49:57 +02:00
|
|
|
|
let pinnedInChannel = BDFDB.DataUtils.load(this, "pinnedDMs")[id] != undefined;
|
|
|
|
|
let pinnedInGuild = BDFDB.DataUtils.load(this, "pinnedRecents")[id] != undefined;
|
2019-09-11 12:14:43 +02:00
|
|
|
|
let items = [];
|
2019-10-22 18:55:25 +02:00
|
|
|
|
items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
2019-09-11 12:14:43 +02:00
|
|
|
|
label: this.labels[pinnedInChannel ? "context_unpinchannel_text" : "context_pinchannel_text"],
|
|
|
|
|
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-${pinnedInChannel ? "unpin" : "pin"}channel-contextMenuItem`,
|
|
|
|
|
danger: pinnedInChannel,
|
|
|
|
|
action: e => {
|
2019-11-01 10:14:50 +01:00
|
|
|
|
BDFDB.ContextMenuUtils.close(menu);
|
2019-09-11 12:14:43 +02:00
|
|
|
|
if (!pinnedInChannel) {
|
2019-10-22 18:55:25 +02:00
|
|
|
|
let dmsscrollerinstance = BDFDB.ReactUtils.getInstance(document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller));
|
2019-01-24 22:27:15 +01:00
|
|
|
|
if (dmsscrollerinstance) {
|
2019-09-11 12:14:43 +02:00
|
|
|
|
let dms = dmsscrollerinstance.return.return.return.stateNode.props.children;
|
2019-01-24 22:27:15 +01:00
|
|
|
|
let insertpoint = this.getInsertPoint(dms);
|
2019-09-04 12:34:02 +02:00
|
|
|
|
this.addPinnedDM(id, dms, insertpoint);
|
2019-01-24 22:27:15 +01:00
|
|
|
|
this.forceUpdateScroller(dmsscrollerinstance.stateNode);
|
|
|
|
|
}
|
2019-02-05 14:23:34 +01:00
|
|
|
|
this.updatePinnedPositions("pinnedDMs");
|
2019-09-11 12:14:43 +02:00
|
|
|
|
}
|
|
|
|
|
else {
|
2019-01-24 22:27:15 +01:00
|
|
|
|
this.removePinnedDM(id);
|
2019-09-11 12:14:43 +02:00
|
|
|
|
}
|
2019-01-24 22:27:15 +01:00
|
|
|
|
}
|
2019-09-11 12:14:43 +02:00
|
|
|
|
}));
|
2019-10-22 18:55:25 +02:00
|
|
|
|
items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
2019-09-11 12:14:43 +02:00
|
|
|
|
label: this.labels[pinnedInGuild ? "context_unpinguild_text" : "context_pinguild_text"],
|
|
|
|
|
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-${pinnedInGuild ? "unpin" : "pin"}guild-contextMenuItem`,
|
|
|
|
|
danger: pinnedInGuild,
|
|
|
|
|
action: e => {
|
2019-11-01 10:14:50 +01:00
|
|
|
|
BDFDB.ContextMenuUtils.close(menu);
|
2019-09-11 12:14:43 +02:00
|
|
|
|
if (!pinnedInGuild) {
|
2019-01-24 22:27:15 +01:00
|
|
|
|
this.addPinnedRecent(id);
|
2019-02-05 14:23:34 +01:00
|
|
|
|
this.updatePinnedPositions("pinnedRecents");
|
2019-09-11 12:14:43 +02:00
|
|
|
|
}
|
|
|
|
|
else {
|
2019-10-23 11:10:01 +02:00
|
|
|
|
BDFDB.DOMUtils.remove(document.querySelector(`.pinned-dm[channelid="${id}"]`));
|
2019-01-24 22:27:15 +01:00
|
|
|
|
this.unhideNativeDM(id);
|
2019-10-22 20:16:05 +02:00
|
|
|
|
BDFDB.DataUtils.remove(this, "pinnedRecents", id);
|
2019-02-05 14:23:34 +01:00
|
|
|
|
this.updatePinnedPositions("pinnedRecents");
|
2019-09-11 12:14:43 +02:00
|
|
|
|
}
|
2019-01-24 22:27:15 +01:00
|
|
|
|
}
|
2019-09-11 12:14:43 +02:00
|
|
|
|
}));
|
2019-10-22 18:55:25 +02:00
|
|
|
|
const subitem = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, {
|
2019-09-11 12:14:43 +02:00
|
|
|
|
label: this.labels.context_pindm_text,
|
|
|
|
|
className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-pindm-contextMenuSubItem`,
|
|
|
|
|
render: items
|
2019-01-24 22:27:15 +01:00
|
|
|
|
});
|
2019-09-11 12:14:43 +02:00
|
|
|
|
children.splice(index, 0, subitem);
|
2019-01-24 22:27:15 +01:00
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-09-11 12:14:43 +02:00
|
|
|
|
processGuilds (instance, wrapper, returnvalue) {
|
2019-03-07 23:56:18 +01:00
|
|
|
|
for (let id of this.sortAndUpdate("pinnedRecents")) this.addPinnedRecent(id);
|
2019-01-24 22:27:15 +01:00
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-09-11 12:14:43 +02:00
|
|
|
|
processPrivateChannel (instance, wrapper, returnvalue) {
|
2019-02-05 14:23:34 +01:00
|
|
|
|
if (instance && instance.props && instance.props.ispin) {
|
2019-10-22 18:55:25 +02:00
|
|
|
|
let id = BDFDB.ReactUtils.getValue(instance, "props.channel.id");
|
2019-02-12 13:19:45 +01:00
|
|
|
|
wrapper.setAttribute("channelid", id);
|
2019-10-23 11:10:01 +02:00
|
|
|
|
BDFDB.DOMUtils.addClass(wrapper, "pinned");
|
|
|
|
|
BDFDB.DOMUtils.removeClass(BDFDB.ChannelUtils.getDiv(id), BDFDB.disCN.namecontainerselected);
|
2019-09-11 12:14:43 +02:00
|
|
|
|
(wrapper.querySelector("a") || wrapper).setAttribute("draggable", false);
|
2019-02-05 14:23:34 +01:00
|
|
|
|
wrapper.addEventListener("click", e => {
|
|
|
|
|
let dmsscroller = document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller);
|
|
|
|
|
if (dmsscroller) {
|
|
|
|
|
this.oldScrollerPos = dmsscroller.scrollTop;
|
2019-11-01 11:09:32 +01:00
|
|
|
|
BDFDB.TimeUtils.timeout(() => {this.oldScrollerPos = null;},1000);
|
2019-02-05 14:23:34 +01:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
wrapper.querySelector(BDFDB.dotCN.dmchannelclose).addEventListener("click", e => {
|
2019-10-22 18:55:25 +02:00
|
|
|
|
BDFDB.ListenerUtils.stopEvent(e);
|
2019-02-05 14:23:34 +01:00
|
|
|
|
this.removePinnedDM(id);
|
|
|
|
|
});
|
|
|
|
|
wrapper.addEventListener("mousedown", e => {
|
|
|
|
|
let x = e.pageX, y = e.pageY;
|
|
|
|
|
let mousemove = e2 => {
|
|
|
|
|
if (Math.sqrt((x - e2.pageX)**2) > 20 || Math.sqrt((y - e2.pageY)**2) > 20) {
|
|
|
|
|
document.removeEventListener("mousemove", mousemove);
|
|
|
|
|
document.removeEventListener("mouseup", mouseup);
|
|
|
|
|
let dmchannelswrap = document.querySelector(`${BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller}`);
|
|
|
|
|
if (!dmchannelswrap) return;
|
|
|
|
|
let hovele = null;
|
2019-10-23 11:10:01 +02:00
|
|
|
|
let placeholder = BDFDB.DOMUtils.create(`<a class="${BDFDB.disCNS.dmchannel + BDFDB.disCNS.namecontainer + BDFDB.disCN.namecontainerclickable} dmchannelplaceholder"><div class="${BDFDB.disCN.namecontainerlayout}"></div></a>`);
|
2019-02-05 14:23:34 +01:00
|
|
|
|
let dragpreview = this.createDragPreview(wrapper, e);
|
|
|
|
|
let dragging = e3 => {
|
2019-10-23 11:10:01 +02:00
|
|
|
|
BDFDB.DOMUtils.remove(placeholder);
|
|
|
|
|
BDFDB.DOMUtils.hide(wrapper);
|
2019-02-05 14:23:34 +01:00
|
|
|
|
this.updateDragPreview(dragpreview, e3);
|
2019-10-23 11:10:01 +02:00
|
|
|
|
hovele = BDFDB.DOMUtils.getParent(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.dmchannel + ".pinned", e3.target);
|
2019-02-05 14:23:34 +01:00
|
|
|
|
if (hovele) dmchannelswrap.insertBefore(placeholder, hovele.nextSibling);
|
|
|
|
|
};
|
|
|
|
|
let releasing = e3 => {
|
|
|
|
|
document.removeEventListener("mousemove", dragging);
|
|
|
|
|
document.removeEventListener("mouseup", releasing);
|
2019-10-23 11:10:01 +02:00
|
|
|
|
BDFDB.DOMUtils.remove(placeholder, dragpreview);
|
|
|
|
|
BDFDB.DOMUtils.show(wrapper);
|
2019-02-05 14:23:34 +01:00
|
|
|
|
if (hovele) {
|
|
|
|
|
dmchannelswrap.insertBefore(wrapper, hovele.nextSibling);
|
|
|
|
|
this.updatePinnedPositions("pinnedDMs");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
document.addEventListener("mousemove", dragging);
|
|
|
|
|
document.addEventListener("mouseup", releasing);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
let mouseup = () => {
|
|
|
|
|
document.removeEventListener("mousemove", mousemove);
|
|
|
|
|
document.removeEventListener("mouseup", mouseup);
|
|
|
|
|
};
|
|
|
|
|
document.addEventListener("mousemove", mousemove);
|
|
|
|
|
document.addEventListener("mouseup", mouseup);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-11 12:14:43 +02:00
|
|
|
|
processDirectMessage (instance, wrapper, returnvalue, methodnames) {
|
2019-01-24 22:27:15 +01:00
|
|
|
|
if (instance.props && instance.props.channel) {
|
|
|
|
|
if (methodnames.includes("componentDidMount")) {
|
|
|
|
|
wrapper.removeEventListener("contextmenu", wrapper.PinDMsContextMenuListener);
|
|
|
|
|
wrapper.PinDMsContextMenuListener = e => {
|
2019-10-22 19:49:57 +02:00
|
|
|
|
if (BDFDB.DataUtils.load(this, "pinnedRecents")[instance.props.channel.id] == undefined) {
|
2019-10-22 18:55:25 +02:00
|
|
|
|
const itemGroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
|
2019-09-11 12:14:43 +02:00
|
|
|
|
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
|
|
|
|
|
children: [
|
2019-10-22 18:55:25 +02:00
|
|
|
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
2019-09-11 12:14:43 +02:00
|
|
|
|
label: this.labels.context_pinguild_text,
|
|
|
|
|
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-pinguild-contextMenuItem`,
|
|
|
|
|
action: e => {
|
2019-11-01 10:14:50 +01:00
|
|
|
|
BDFDB.ContextMenuUtils.close(BDFDB.DOMUtils.getParent(BDFDB.dotCN.contextmenu, e.target));
|
2019-09-11 12:14:43 +02:00
|
|
|
|
this.addPinnedRecent(instance.props.channel.id);
|
|
|
|
|
this.updatePinnedPositions("pinnedRecents");
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
]
|
2019-01-24 22:27:15 +01:00
|
|
|
|
});
|
2019-11-01 10:14:50 +01:00
|
|
|
|
BDFDB.ContextMenuUtils.open(this, e, itemGroup);
|
2019-01-24 22:27:15 +01:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
wrapper.addEventListener("contextmenu", wrapper.PinDMsContextMenuListener);
|
|
|
|
|
}
|
2019-10-22 19:49:57 +02:00
|
|
|
|
let pinnedRecents = BDFDB.DataUtils.load(this, "pinnedRecents");
|
2019-01-24 22:27:15 +01:00
|
|
|
|
if (pinnedRecents[instance.props.channel.id] != undefined) {
|
2019-05-29 17:39:43 +02:00
|
|
|
|
if (methodnames.includes("componentDidMount")) {
|
|
|
|
|
if (!document.querySelector(`.pinned-dm[channelid="${instance.props.channel.id}"]`)) this.addPinnedRecent(instance.props.channel.id);
|
|
|
|
|
else this.hideNativeDM(instance.props.channel.id);
|
|
|
|
|
}
|
2019-04-24 11:03:10 +02:00
|
|
|
|
this.updatePinnedRecent(instance.props.channel.id);
|
2019-01-24 22:27:15 +01:00
|
|
|
|
}
|
2018-10-11 10:21:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-09-11 12:14:43 +02:00
|
|
|
|
processLazyScroller (instance, wrapper, returnvalue) {
|
2019-10-22 18:55:25 +02:00
|
|
|
|
let privateChannelIds = BDFDB.ReactUtils.getValue(instance, "_reactInternalFiber.return.memoizedProps.privateChannelIds");
|
2019-10-24 00:46:46 +02:00
|
|
|
|
if (privateChannelIds && instance.updater.isMounted(instance)) {
|
2019-01-11 15:32:04 +01:00
|
|
|
|
if (this.forceAdding || !instance.props.PinDMsPatched) {
|
|
|
|
|
instance.props.PinDMsPatched = true;
|
|
|
|
|
let dms = instance.props.children;
|
2019-01-24 22:27:15 +01:00
|
|
|
|
let sortedDMs = this.sortAndUpdate("pinnedDMs");
|
2019-01-11 15:32:04 +01:00
|
|
|
|
if (sortedDMs.length > 0) {
|
|
|
|
|
let insertpoint = this.getInsertPoint(dms);
|
|
|
|
|
for (let pos in sortedDMs) this.addPinnedDM(sortedDMs[pos], dms, insertpoint);
|
2018-11-29 17:33:33 +01:00
|
|
|
|
}
|
2019-10-18 15:07:30 +02:00
|
|
|
|
this.forceUpdateScroller(instance.getScrollerNode());
|
2018-11-29 15:19:09 +01:00
|
|
|
|
}
|
2019-10-18 10:33:34 +02:00
|
|
|
|
if (this.oldScrollerPos != null) instance.getScrollerNode().scrollTop = this.oldScrollerPos;
|
2019-02-28 10:44:12 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-11 12:14:43 +02:00
|
|
|
|
processStandardSidebarView (instance, wrapper, returnvalue) {
|
2019-02-28 10:44:12 +01:00
|
|
|
|
if (this.SettingsUpdated) {
|
|
|
|
|
delete this.SettingsUpdated;
|
2019-04-24 11:03:10 +02:00
|
|
|
|
for (let id of this.sortAndUpdate("pinnedRecents")) this.updatePinnedRecent(id);
|
2018-10-11 10:21:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2018-11-26 23:36:18 +01:00
|
|
|
|
getInsertPoint (dms) {
|
|
|
|
|
let insertpoint = null;
|
|
|
|
|
for (let i in dms) {
|
|
|
|
|
let ele = dms[i];
|
2019-10-22 18:55:25 +02:00
|
|
|
|
if (ele && ele.type == "header" || BDFDB.ReactUtils.getValue(ele, "type.displayName") == "ListSectionItem") {
|
2018-11-27 00:15:10 +01:00
|
|
|
|
insertpoint = parseInt(i);
|
2018-11-26 23:36:18 +01:00
|
|
|
|
if (!ele.pinned && !ele.props.ispin) {
|
|
|
|
|
ele.pinned = true;
|
|
|
|
|
let headerpin = Object.assign({},ele);
|
|
|
|
|
headerpin.key = "pin" + headerpin.key;
|
2019-09-11 12:14:43 +02:00
|
|
|
|
headerpin.props = {className:ele.props.className,children:this.labels.header_pinneddms_text,ispin:true};
|
2019-01-24 22:27:15 +01:00
|
|
|
|
dms.splice(insertpoint, 0, headerpin);
|
2018-11-26 23:36:18 +01:00
|
|
|
|
}
|
|
|
|
|
insertpoint++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-10-11 10:21:26 +02:00
|
|
|
|
}
|
2018-11-26 23:36:18 +01:00
|
|
|
|
return insertpoint;
|
2018-10-11 10:21:26 +02:00
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2018-11-26 23:36:18 +01:00
|
|
|
|
addPinnedDM (id, dms, insertpoint) {
|
2019-01-24 22:27:15 +01:00
|
|
|
|
for (let ele of dms) if (ele && !ele.pinned && id == ele.key) {
|
|
|
|
|
ele.pinned = true;
|
|
|
|
|
let dmpin = Object.assign({ispin:true},ele);
|
|
|
|
|
dmpin.key = "pin" + ele.key;
|
|
|
|
|
dmpin.props = {channel:ele.props.channel,selected:ele.props.selected,ispin:true};
|
|
|
|
|
dms.splice(insertpoint, 0, dmpin);
|
2018-10-11 10:21:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-01-11 15:32:04 +01:00
|
|
|
|
removePinnedDM (id) {
|
|
|
|
|
if (!id) return;
|
2019-02-05 14:23:34 +01:00
|
|
|
|
let div = document.querySelector(`${BDFDB.dotCNS.dmchannels + BDFDB.dotCN.dmchannel}.pinned[channelid="${id}"]`);
|
|
|
|
|
if (div) {
|
2019-10-23 11:10:01 +02:00
|
|
|
|
BDFDB.DOMUtils.removeClass(div, "pinned");
|
2019-02-05 14:23:34 +01:00
|
|
|
|
div.removeAttribute("channelid");
|
|
|
|
|
}
|
2019-10-22 20:16:05 +02:00
|
|
|
|
BDFDB.DataUtils.remove(this, "pinnedDMs", id);
|
2019-02-05 14:23:34 +01:00
|
|
|
|
this.updatePinnedPositions("pinnedDMs");
|
2019-10-22 18:55:25 +02:00
|
|
|
|
let dmsscrollerinstance = BDFDB.ReactUtils.getInstance(document.querySelector(BDFDB.dotCNS.dmchannels + BDFDB.dotCN.scroller));
|
2019-01-11 15:32:04 +01:00
|
|
|
|
if (dmsscrollerinstance) {
|
|
|
|
|
let dms = dmsscrollerinstance.return.return.return.memoizedProps.children;
|
2019-01-24 22:27:15 +01:00
|
|
|
|
let existingDMs = this.sortAndUpdate("pinnedDMs");
|
2019-01-11 15:32:04 +01:00
|
|
|
|
let removepoint = null;
|
|
|
|
|
for (let i in dms) {
|
|
|
|
|
let ele = dms[i];
|
|
|
|
|
if (ele && ele.pinned && (id == ele.key || ("pin" + id) == ele.key)) {
|
|
|
|
|
delete ele.pinned;
|
|
|
|
|
if (ele.props.ispin) removepoint = parseInt(i);
|
|
|
|
|
}
|
2018-11-26 23:36:18 +01:00
|
|
|
|
}
|
2019-01-11 15:32:04 +01:00
|
|
|
|
if (removepoint) {
|
|
|
|
|
let offset = existingDMs.length ? 0 : 1;
|
|
|
|
|
if (offset) delete dms[removepoint + offset].pinned;
|
|
|
|
|
dms.splice(removepoint-offset,1+offset);
|
|
|
|
|
}
|
|
|
|
|
this.forceUpdateScroller(dmsscrollerinstance.stateNode);
|
2018-10-11 10:21:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-01-24 22:27:15 +01:00
|
|
|
|
sortAndUpdate (type) {
|
2019-10-22 19:49:57 +02:00
|
|
|
|
let pinnedDMs = BDFDB.DataUtils.load(this, type);
|
2018-11-26 23:36:18 +01:00
|
|
|
|
delete pinnedDMs[""];
|
2019-02-12 13:18:51 +01:00
|
|
|
|
delete pinnedDMs["null"];
|
|
|
|
|
let sortedDMs = [], existingDMs = [], sortDM = (id, pos) => {
|
|
|
|
|
if (typeof sortedDMs[pos] == "undefined") sortedDMs[pos] = id;
|
|
|
|
|
else sortDM(id, pos+1);
|
2018-11-26 23:36:18 +01:00
|
|
|
|
};
|
2019-02-12 13:18:51 +01:00
|
|
|
|
for (let id in pinnedDMs) sortDM(id, pinnedDMs[id]);
|
2018-11-26 23:36:18 +01:00
|
|
|
|
sortedDMs = sortedDMs.filter(n => n);
|
2019-09-11 12:14:43 +02:00
|
|
|
|
for (let pos in sortedDMs) if (BDFDB.LibraryModules.ChannelStore.getChannel(sortedDMs[pos])) existingDMs.push(sortedDMs[pos]);
|
2019-09-04 12:34:02 +02:00
|
|
|
|
this.updatePinnedPositions(type);
|
2018-12-16 20:31:13 +01:00
|
|
|
|
return existingDMs;
|
2018-10-11 10:21:26 +02:00
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2018-11-26 23:36:18 +01:00
|
|
|
|
forceUpdateScroller (scroller) {
|
2019-01-22 14:24:47 +01:00
|
|
|
|
if (this.updatingScroller) return;
|
2019-10-22 18:55:25 +02:00
|
|
|
|
var stateNode = BDFDB.ReactUtils.getValue(scroller, "return.return.return.stateNode");
|
2019-10-18 15:07:30 +02:00
|
|
|
|
if (stateNode) {
|
2019-02-16 12:58:25 +01:00
|
|
|
|
this.updatingScroller = true;
|
2019-10-22 18:55:25 +02:00
|
|
|
|
BDFDB.ReactUtils.forceUpdate(stateNode);
|
2019-11-01 11:09:32 +01:00
|
|
|
|
BDFDB.TimeUtils.timeout(() => {BDFDB.ReactUtils.forceUpdate(stateNode);},500);
|
|
|
|
|
BDFDB.TimeUtils.timeout(() => {delete this.updatingScroller;},1000);
|
2019-02-16 10:41:56 +01:00
|
|
|
|
}
|
2018-10-11 10:21:26 +02:00
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-01-24 22:27:15 +01:00
|
|
|
|
addPinnedRecent (id) {
|
2019-10-23 11:10:01 +02:00
|
|
|
|
let anker = document.querySelector("#bd-pub-li") || BDFDB.DOMUtils.getParent(BDFDB.dotCN.guildouter, document.querySelector(BDFDB.dotCN.homebuttonicon));
|
2019-04-24 11:03:10 +02:00
|
|
|
|
if (anker && !document.querySelector(`.pinned-dm[channelid="${id}"]`)) {
|
2019-09-11 12:14:43 +02:00
|
|
|
|
let info = BDFDB.LibraryModules.ChannelStore.getChannel(id);
|
2019-01-24 22:27:15 +01:00
|
|
|
|
if (info) {
|
2019-10-23 11:10:01 +02:00
|
|
|
|
let dmdiv = BDFDB.DOMUtils.create(this.recentDMMarkup);
|
2019-06-06 17:30:06 +02:00
|
|
|
|
let dmdivinner = dmdiv.querySelector(BDFDB.dotCN.guildinnerwrapper);
|
2019-04-26 23:16:20 +02:00
|
|
|
|
let dmiconwrapper = dmdiv.querySelector(BDFDB.dotCN.guildiconwrapper);
|
2019-09-11 12:14:43 +02:00
|
|
|
|
dmiconwrapper.style.setProperty("border-radius", BDFDB.LibraryModules.LastChannelStore.getChannelId() == id ? "30%" : "50%");
|
2019-04-26 23:16:20 +02:00
|
|
|
|
dmiconwrapper.style.setProperty("overflow", "hidden");
|
2019-04-25 19:54:26 +02:00
|
|
|
|
dmdiv.querySelector("mask").setAttribute("id", "PINDMS" + id);
|
|
|
|
|
dmdiv.querySelector("foreignObject").setAttribute("mask", "url(#PINDMS" + id + ")");
|
2019-09-11 12:14:43 +02:00
|
|
|
|
let user = info.type == 1 ? BDFDB.LibraryModules.UserStore.getUser(info.recipients[0]) : null;
|
2019-01-25 09:34:56 +01:00
|
|
|
|
dmdiv.setAttribute("channelid", id);
|
2019-03-07 23:56:18 +01:00
|
|
|
|
anker.parentElement.insertBefore(dmdiv, anker.nextSibling);
|
2019-04-24 11:03:10 +02:00
|
|
|
|
let avatar = dmdiv.querySelector(BDFDB.dotCN.guildicon);
|
2019-01-25 09:34:56 +01:00
|
|
|
|
let dmname = info.name;
|
|
|
|
|
if (!dmname && info.recipients.length > 0) {
|
2019-01-24 22:27:15 +01:00
|
|
|
|
for (let dmuser_id of info.recipients) {
|
2019-01-25 09:34:56 +01:00
|
|
|
|
dmname = dmname ? dmname + ", " : dmname;
|
2019-09-11 12:14:43 +02:00
|
|
|
|
dmname = dmname + BDFDB.LibraryModules.UserStore.getUser(dmuser_id).username;
|
2019-01-24 22:27:15 +01:00
|
|
|
|
}
|
2019-01-25 09:34:56 +01:00
|
|
|
|
}
|
2019-10-23 11:10:01 +02:00
|
|
|
|
let EditUsersData = user && BDFDB.BDUtils.isPluginEnabled("EditUsers") ? BDFDB.BDUtils.getPlugin("EditUsers").getUserData(user.id, dmdiv) : {};
|
|
|
|
|
if (!EditUsersData.removeIcon) avatar.setAttribute("src", `${EditUsersData.url || BDFDB.DMUtils.getIcon(id)}`);
|
2019-01-25 09:34:56 +01:00
|
|
|
|
avatar.setAttribute("channel", dmname);
|
|
|
|
|
if (user) avatar.setAttribute("user", user.username);
|
2019-04-24 11:03:10 +02:00
|
|
|
|
dmdivinner.addEventListener("mouseenter", () => {
|
2019-10-23 11:10:01 +02:00
|
|
|
|
let FreshEditUsersData = user && BDFDB.BDUtils.isPluginEnabled("EditUsers") ? BDFDB.BDUtils.getPlugin("EditUsers").getUserData(user.id, dmdiv) : {};
|
2019-10-22 18:55:25 +02:00
|
|
|
|
BDFDB.TooltipUtils.create(dmdivinner, FreshEditUsersData.name || dmname, {selector:(BDFDB.ObjectUtils.isEmpty(FreshEditUsersData) ? "" : "EditUsers-tooltip"),type:"right"});
|
2019-01-24 22:27:15 +01:00
|
|
|
|
});
|
2019-04-24 11:03:10 +02:00
|
|
|
|
avatar.parentElement.addEventListener("click", e => {
|
2019-05-29 17:39:43 +02:00
|
|
|
|
if (user) {
|
2019-10-22 19:49:57 +02:00
|
|
|
|
let DMid = BDFDB.LibraryModules.ChannelStore.getDMFromUserId(user.id);
|
2019-09-11 12:14:43 +02:00
|
|
|
|
if (DMid) BDFDB.LibraryModules.SelectChannelUtils.selectPrivateChannel(DMid);
|
2019-10-22 18:55:25 +02:00
|
|
|
|
else BDFDB.LibraryModules.DirectMessageUtils.openPrivateChannel(BDFDB.UserUtils.me.id, user.id);
|
2019-05-29 17:39:43 +02:00
|
|
|
|
}
|
2019-09-11 12:14:43 +02:00
|
|
|
|
else BDFDB.LibraryModules.SelectChannelUtils.selectPrivateChannel(id);
|
2019-10-22 18:55:25 +02:00
|
|
|
|
BDFDB.ListenerUtils.stopEvent(e);
|
2019-01-24 22:27:15 +01:00
|
|
|
|
});
|
2019-04-24 11:03:10 +02:00
|
|
|
|
avatar.parentElement.addEventListener("contextmenu", e => {
|
2019-10-22 18:55:25 +02:00
|
|
|
|
const itemGroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
|
2019-09-11 12:14:43 +02:00
|
|
|
|
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
|
|
|
|
|
children: [
|
2019-10-22 18:55:25 +02:00
|
|
|
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
2019-09-11 12:14:43 +02:00
|
|
|
|
label: this.labels.context_unpinguild_text,
|
|
|
|
|
danger: true,
|
|
|
|
|
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-unpinguild-contextMenuItem`,
|
|
|
|
|
action: e => {
|
2019-11-01 10:14:50 +01:00
|
|
|
|
BDFDB.ContextMenuUtils.close(BDFDB.DOMUtils.getParent(BDFDB.dotCN.contextmenu, e.target));
|
2019-10-23 11:10:01 +02:00
|
|
|
|
BDFDB.DOMUtils.remove(dmdiv);
|
2019-09-11 12:14:43 +02:00
|
|
|
|
this.unhideNativeDM(id);
|
2019-10-22 20:16:05 +02:00
|
|
|
|
BDFDB.DataUtils.remove(this, "pinnedRecents", id);
|
2019-09-11 12:14:43 +02:00
|
|
|
|
this.updatePinnedPositions("pinnedRecents");
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
]
|
2019-01-24 22:27:15 +01:00
|
|
|
|
});
|
2019-11-01 10:14:50 +01:00
|
|
|
|
BDFDB.ContextMenuUtils.open(this, e, itemGroup);
|
2019-01-24 22:27:15 +01:00
|
|
|
|
});
|
2019-02-05 14:23:34 +01:00
|
|
|
|
dmdiv.addEventListener("mousedown", e => {
|
|
|
|
|
let x = e.pageX, y = e.pageY;
|
|
|
|
|
let mousemove = e2 => {
|
|
|
|
|
if (Math.sqrt((x - e2.pageX)**2) > 20 || Math.sqrt((y - e2.pageY)**2) > 20) {
|
|
|
|
|
document.removeEventListener("mousemove", mousemove);
|
|
|
|
|
document.removeEventListener("mouseup", mouseup);
|
|
|
|
|
let hovele = null;
|
2019-10-23 11:10:01 +02:00
|
|
|
|
let placeholder = BDFDB.DOMUtils.create(this.dragPlaceholderMarkup);
|
2019-02-05 14:23:34 +01:00
|
|
|
|
let dragpreview = this.createDragPreview(dmdiv, e);
|
|
|
|
|
let dragging = e3 => {
|
2019-10-23 11:10:01 +02:00
|
|
|
|
BDFDB.DOMUtils.remove(placeholder);
|
|
|
|
|
BDFDB.DOMUtils.hide(dmdiv);
|
2019-02-05 14:23:34 +01:00
|
|
|
|
this.updateDragPreview(dragpreview, e3);
|
2019-10-23 11:10:01 +02:00
|
|
|
|
hovele = BDFDB.DOMUtils.getParent(".pinned-dm", e3.target);
|
2019-03-07 23:56:18 +01:00
|
|
|
|
if (hovele) hovele.parentElement.insertBefore(placeholder, hovele.nextSibling);
|
2019-02-05 14:23:34 +01:00
|
|
|
|
};
|
|
|
|
|
let releasing = e3 => {
|
|
|
|
|
document.removeEventListener("mousemove", dragging);
|
|
|
|
|
document.removeEventListener("mouseup", releasing);
|
2019-10-23 11:10:01 +02:00
|
|
|
|
BDFDB.DOMUtils.remove(placeholder, dragpreview);
|
|
|
|
|
BDFDB.DOMUtils.show(dmdiv);
|
2019-02-05 14:23:34 +01:00
|
|
|
|
if (hovele) {
|
2019-03-07 23:56:18 +01:00
|
|
|
|
hovele.parentElement.insertBefore(dmdiv, hovele.nextSibling);
|
2019-02-05 14:23:34 +01:00
|
|
|
|
this.updatePinnedPositions("pinnedRecents");
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
document.addEventListener("mousemove", dragging);
|
|
|
|
|
document.addEventListener("mouseup", releasing);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
let mouseup = () => {
|
|
|
|
|
document.removeEventListener("mousemove", mousemove);
|
|
|
|
|
document.removeEventListener("mouseup", mouseup);
|
|
|
|
|
};
|
|
|
|
|
document.addEventListener("mousemove", mousemove);
|
|
|
|
|
document.addEventListener("mouseup", mouseup);
|
|
|
|
|
});
|
2019-03-06 22:13:28 +01:00
|
|
|
|
this.updatePinnedRecent(id);
|
2019-04-26 23:16:20 +02:00
|
|
|
|
this.addHoverBehaviour(dmdiv, id);
|
2019-01-24 22:27:15 +01:00
|
|
|
|
this.hideNativeDM(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-02-05 14:23:34 +01:00
|
|
|
|
createDragPreview (div, e) {
|
|
|
|
|
if (!Node.prototype.isPrototypeOf(div)) return;
|
|
|
|
|
let dragpreview = div.cloneNode(true);
|
2019-10-23 11:10:01 +02:00
|
|
|
|
BDFDB.DOMUtils.addClass(dragpreview, "pindms-dragpreview");
|
2019-02-05 14:23:34 +01:00
|
|
|
|
document.querySelector(BDFDB.dotCN.appmount).appendChild(dragpreview);
|
2019-10-23 11:10:01 +02:00
|
|
|
|
let rects = BDFDB.DOMUtils.getRects(dragpreview);
|
|
|
|
|
BDFDB.DOMUtils.hide(dragpreview);
|
2019-02-05 14:23:34 +01:00
|
|
|
|
dragpreview.style.setProperty("pointer-events", "none", "important");
|
|
|
|
|
dragpreview.style.setProperty("left", e.clientX - (rects.width/2) + "px", "important");
|
|
|
|
|
dragpreview.style.setProperty("top", e.clientY - (rects.height/2) + "px", "important");
|
|
|
|
|
return dragpreview;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateDragPreview (dragpreview, e) {
|
|
|
|
|
if (!Node.prototype.isPrototypeOf(dragpreview)) return;
|
2019-10-23 11:10:01 +02:00
|
|
|
|
BDFDB.DOMUtils.show(dragpreview);
|
|
|
|
|
let rects = BDFDB.DOMUtils.getRects(dragpreview);
|
2019-02-05 14:23:34 +01:00
|
|
|
|
dragpreview.style.setProperty("left", e.clientX - (rects.width/2) + "px", "important");
|
|
|
|
|
dragpreview.style.setProperty("top", e.clientY - (rects.height/2) + "px", "important");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updatePinnedPositions (type) {
|
2019-11-01 11:09:32 +01:00
|
|
|
|
BDFDB.TimeUtils.timeout(() => {
|
2019-10-22 19:49:57 +02:00
|
|
|
|
let newPinned = {}, oldPinned = BDFDB.DataUtils.load(this, type);
|
2019-09-11 12:14:43 +02:00
|
|
|
|
let pins = Array.from(document.querySelectorAll(type == "pinnedRecents" ? `.pinned-dm` : `${BDFDB.dotCNS.dmchannels + BDFDB.dotCN.dmchannel}.pinned`)).map(div => {return div.getAttribute("channelid");}).reverse();
|
|
|
|
|
for (let i in pins) if (pins[i]) newPinned[pins[i]] = parseInt(i);
|
|
|
|
|
for (let id in oldPinned) if (newPinned[id] == undefined) newPinned[id] = Object.keys(newPinned).length;
|
2019-10-22 19:49:57 +02:00
|
|
|
|
BDFDB.DataUtils.save(newPinned, this, type);
|
2019-09-11 12:14:43 +02:00
|
|
|
|
});
|
2019-02-05 14:23:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-24 11:03:10 +02:00
|
|
|
|
updatePinnedRecent (id) {
|
|
|
|
|
let pinneddmdiv = document.querySelector(`.pinned-dm[channelid="${id}"]`);
|
2019-03-06 22:13:28 +01:00
|
|
|
|
if (Node.prototype.isPrototypeOf(pinneddmdiv)) {
|
2019-09-11 12:14:43 +02:00
|
|
|
|
let count = BDFDB.LibraryModules.UnreadChannelUtils.getUnreadCount(id);
|
2019-10-22 20:16:05 +02:00
|
|
|
|
let showpin = BDFDB.DataUtils.get(this, "settings", "showPinIcon");
|
2019-09-04 12:34:02 +02:00
|
|
|
|
|
2019-10-23 11:10:01 +02:00
|
|
|
|
let dmdiv = BDFDB.DMUtils.getDiv(id);
|
2019-04-26 23:16:20 +02:00
|
|
|
|
let pinneddmiconwrapper = pinneddmdiv.querySelector(BDFDB.dotCN.guildiconwrapper);
|
|
|
|
|
let pinneddmdivpill = pinneddmdiv.querySelector(BDFDB.dotCN.guildpillitem);
|
2019-04-25 22:10:32 +02:00
|
|
|
|
let iconbadge = pinneddmdiv.querySelector(BDFDB.dotCN.guildupperbadge);
|
|
|
|
|
let notificationbadge = pinneddmdiv.querySelector(BDFDB.dotCN.guildlowerbadge);
|
2019-09-04 12:34:02 +02:00
|
|
|
|
|
2019-10-23 11:10:01 +02:00
|
|
|
|
BDFDB.DOMUtils.toggleClass(pinneddmdiv, "has-new-messages", count > 0);
|
2019-09-11 12:14:43 +02:00
|
|
|
|
let selected = BDFDB.LibraryModules.LastChannelStore.getChannelId() == id;
|
2019-04-26 23:16:20 +02:00
|
|
|
|
pinneddmiconwrapper.style.setProperty("border-radius", selected ? "30%" : "50%");
|
2019-09-19 12:37:33 +02:00
|
|
|
|
if (pinneddmdivpill) {
|
|
|
|
|
pinneddmdivpill.style.setProperty("opacity", selected ? 1 : (count ? 0.7 : 0));
|
|
|
|
|
pinneddmdivpill.style.setProperty("height", selected ? "40px" : "8px");
|
|
|
|
|
pinneddmdivpill.style.setProperty("transform", "translate3d(0px, 0px, 0px)");
|
|
|
|
|
}
|
2019-09-04 12:34:02 +02:00
|
|
|
|
|
2019-10-23 11:10:01 +02:00
|
|
|
|
BDFDB.DOMUtils.toggle(iconbadge, showpin);
|
2019-04-25 22:10:32 +02:00
|
|
|
|
notificationbadge.firstElementChild.innerText = count;
|
|
|
|
|
notificationbadge.firstElementChild.style.setProperty("width", `${count > 99 ? 30 : (count > 9 ? 22 : 16)}px`);
|
|
|
|
|
notificationbadge.firstElementChild.style.setProperty("padding-right", `${count > 99 ? 0 : (count > 9 ? 0 : 1)}px`);
|
2019-10-23 11:10:01 +02:00
|
|
|
|
BDFDB.DOMUtils.toggle(notificationbadge, count > 0);
|
2019-09-04 12:34:02 +02:00
|
|
|
|
|
2019-04-26 23:16:20 +02:00
|
|
|
|
let masks = pinneddmdiv.querySelectorAll("mask rect");
|
2019-04-24 11:03:10 +02:00
|
|
|
|
masks[0].setAttribute("transform", showpin ? "translate(0 0)" : "translate(20 -20)");
|
|
|
|
|
masks[1].setAttribute("transform", count > 0 ? "translate(0 0)" : "translate(20 20)");
|
2019-04-25 22:10:32 +02:00
|
|
|
|
masks[1].setAttribute("x", `${count > 99 ? 14 : (count > 9 ? 22 : 28)}`);
|
|
|
|
|
masks[1].setAttribute("width", `${count > 99 ? 38 : (count > 9 ? 30 : 24)}`);
|
2019-01-24 22:27:15 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-01-24 22:27:15 +01:00
|
|
|
|
hideNativeDM (id) {
|
2019-10-23 11:10:01 +02:00
|
|
|
|
let dmdiv = BDFDB.DMUtils.getDiv(id);
|
2019-01-24 22:27:15 +01:00
|
|
|
|
if (Node.prototype.isPrototypeOf(dmdiv)) {
|
2019-10-23 11:10:01 +02:00
|
|
|
|
BDFDB.DOMUtils.hide(dmdiv);
|
|
|
|
|
BDFDB.DOMUtils.addClass(dmdiv, "hidden-by-pin");
|
2019-01-24 22:27:15 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-01-24 22:27:15 +01:00
|
|
|
|
unhideNativeDM (id) {
|
2019-10-23 11:10:01 +02:00
|
|
|
|
let dmdiv = BDFDB.DMUtils.getDiv(id);
|
|
|
|
|
if (Node.prototype.isPrototypeOf(dmdiv) && BDFDB.DOMUtils.containsClass(dmdiv, "hidden-by-pin")) {
|
|
|
|
|
BDFDB.DOMUtils.show(dmdiv);
|
|
|
|
|
BDFDB.DOMUtils.removeClass(dmdiv, "hidden-by-pin");
|
2019-01-24 22:27:15 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-01-26 22:45:19 +01:00
|
|
|
|
|
2019-04-26 23:16:20 +02:00
|
|
|
|
addHoverBehaviour (div, id) {
|
2019-06-06 18:31:24 +02:00
|
|
|
|
let divinner = div.querySelector(BDFDB.dotCN.guildinnerwrapper);
|
2019-04-26 23:16:20 +02:00
|
|
|
|
let diviconwrapper = div.querySelector(BDFDB.dotCN.guildiconwrapper);
|
|
|
|
|
let divpillitem = div.querySelector(BDFDB.dotCN.guildpillitem);
|
2019-09-04 12:34:02 +02:00
|
|
|
|
|
2019-09-19 12:37:33 +02:00
|
|
|
|
let pillvisible = divpillitem && divpillitem.style.getPropertyValue("opacity") != 0;
|
2019-04-26 23:16:20 +02:00
|
|
|
|
|
2019-09-11 12:14:43 +02:00
|
|
|
|
let borderRadius = new BDFDB.LibraryModules.AnimationUtils.Value(0);
|
2019-04-26 23:16:20 +02:00
|
|
|
|
borderRadius
|
|
|
|
|
.interpolate({
|
|
|
|
|
inputRange: [0, 1],
|
|
|
|
|
outputRange: [50, 30]
|
|
|
|
|
})
|
|
|
|
|
.addListener((value) => {
|
2019-09-11 12:14:43 +02:00
|
|
|
|
diviconwrapper.style.setProperty("border-radius", `${BDFDB.LibraryModules.LastChannelStore.getChannelId() == id ? 30 : value.value}%`);
|
2019-04-26 23:16:20 +02:00
|
|
|
|
});
|
|
|
|
|
|
2019-09-11 12:14:43 +02:00
|
|
|
|
let pillHeight = new BDFDB.LibraryModules.AnimationUtils.Value(0);
|
2019-04-26 23:16:20 +02:00
|
|
|
|
pillHeight
|
|
|
|
|
.interpolate({
|
|
|
|
|
inputRange: [0, 1],
|
|
|
|
|
outputRange: [8, 20]
|
|
|
|
|
})
|
|
|
|
|
.addListener((value) => {
|
2019-09-19 12:37:33 +02:00
|
|
|
|
if (divpillitem) divpillitem.style.setProperty("height", `${BDFDB.LibraryModules.LastChannelStore.getChannelId() == id ? 40 : value.value}px`);
|
2019-04-26 23:16:20 +02:00
|
|
|
|
});
|
|
|
|
|
|
2019-09-11 12:14:43 +02:00
|
|
|
|
let pillOpacity = new BDFDB.LibraryModules.AnimationUtils.Value(0);
|
2019-04-26 23:16:20 +02:00
|
|
|
|
pillOpacity
|
|
|
|
|
.interpolate({
|
|
|
|
|
inputRange: [0, 1],
|
|
|
|
|
outputRange: [0, 0.7]
|
|
|
|
|
})
|
|
|
|
|
.addListener((value) => {
|
2019-09-19 12:37:33 +02:00
|
|
|
|
if (divpillitem) divpillitem.style.setProperty("opacity", `${BDFDB.LibraryModules.LastChannelStore.getChannelId() == id ? 1 : value.value}`);
|
2019-04-26 23:16:20 +02:00
|
|
|
|
});
|
2019-09-04 12:34:02 +02:00
|
|
|
|
|
2019-04-29 09:01:30 +02:00
|
|
|
|
let animate = (v) => {
|
2019-09-11 12:14:43 +02:00
|
|
|
|
BDFDB.LibraryModules.AnimationUtils.parallel([
|
|
|
|
|
BDFDB.LibraryModules.AnimationUtils.timing(borderRadius, {toValue: v, duration: 200}),
|
|
|
|
|
BDFDB.LibraryModules.AnimationUtils.spring(pillHeight, {toValue: v, friction: 5})
|
2019-04-29 09:01:30 +02:00
|
|
|
|
]).start();
|
|
|
|
|
};
|
2019-09-04 12:34:02 +02:00
|
|
|
|
|
2019-04-29 09:01:30 +02:00
|
|
|
|
let animate2 = (v) => {
|
2019-09-11 12:14:43 +02:00
|
|
|
|
BDFDB.LibraryModules.AnimationUtils.parallel([
|
|
|
|
|
BDFDB.LibraryModules.AnimationUtils.timing(pillOpacity, {toValue: v, duration: 200}),
|
2019-04-26 23:16:20 +02:00
|
|
|
|
]).start();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
divinner.addEventListener("mouseenter", () => {
|
2019-09-19 12:37:33 +02:00
|
|
|
|
pillvisible = divpillitem && divpillitem.style.getPropertyValue("opacity") != 0;
|
2019-09-11 12:14:43 +02:00
|
|
|
|
if (BDFDB.LibraryModules.LastChannelStore.getChannelId() != id) {
|
2019-04-29 09:01:30 +02:00
|
|
|
|
animate(1);
|
|
|
|
|
if (!pillvisible) animate2(1);
|
|
|
|
|
}
|
2019-04-26 23:16:20 +02:00
|
|
|
|
})
|
2019-04-29 09:01:30 +02:00
|
|
|
|
divinner.addEventListener("mouseleave", () => {
|
2019-09-11 12:14:43 +02:00
|
|
|
|
if (BDFDB.LibraryModules.LastChannelStore.getChannelId() != id) {
|
2019-04-29 09:01:30 +02:00
|
|
|
|
animate(0);
|
|
|
|
|
if (!pillvisible) animate2(0);
|
|
|
|
|
}
|
|
|
|
|
});
|
2019-04-26 23:16:20 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-11 10:21:26 +02:00
|
|
|
|
setLabelsByLanguage () {
|
2019-10-23 11:10:01 +02:00
|
|
|
|
switch (BDFDB.LanguageUtils.getLanguage().id) {
|
2018-10-11 10:21:26 +02:00
|
|
|
|
case "hr": //croatian
|
|
|
|
|
return {
|
2018-11-06 22:48:28 +01:00
|
|
|
|
context_pindm_text: "Prikljucite Izravnu Poruku",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "Priložite popisu kanala",
|
|
|
|
|
context_unpinchannel_text: "Ukloni s popisa kanala",
|
|
|
|
|
context_pinguild_text: "Priložite popisu poslužitelja",
|
|
|
|
|
context_unpinguild_text: "Ukloni s popisa poslužitelja",
|
2018-11-06 22:48:28 +01:00
|
|
|
|
header_pinneddms_text: "Prikvačene Izravne Poruke"
|
2018-10-11 10:21:26 +02:00
|
|
|
|
};
|
|
|
|
|
case "da": //danish
|
|
|
|
|
return {
|
2018-11-06 22:48:28 +01:00
|
|
|
|
context_pindm_text: "Fastgør PB",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "Vedhæft til kanalliste",
|
|
|
|
|
context_unpinchannel_text: "Fjern fra kanalliste",
|
|
|
|
|
context_pinguild_text: "Vedhæft til serverliste",
|
|
|
|
|
context_unpinguild_text: "Fjern fra serverliste",
|
2018-10-11 10:21:26 +02:00
|
|
|
|
header_pinneddms_text: "Pinned Privat Beskeder"
|
|
|
|
|
};
|
|
|
|
|
case "de": //german
|
|
|
|
|
return {
|
2018-11-06 22:48:28 +01:00
|
|
|
|
context_pindm_text: "Direktnachricht anheften",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "An Kanalliste anheften",
|
|
|
|
|
context_unpinchannel_text: "Von Kanalliste loslösen",
|
|
|
|
|
context_pinguild_text: "An Serverliste anheften",
|
|
|
|
|
context_unpinguild_text: "Von Serverliste loslösen",
|
2018-10-11 10:21:26 +02:00
|
|
|
|
header_pinneddms_text: "Gepinnte Direktnachrichten"
|
|
|
|
|
};
|
|
|
|
|
case "es": //spanish
|
|
|
|
|
return {
|
2018-11-06 22:48:28 +01:00
|
|
|
|
context_pindm_text: "Anclar MD",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "Adjuntar a la lista de canales",
|
|
|
|
|
context_unpinchannel_text: "Deshazte de la lista de canales",
|
|
|
|
|
context_pinguild_text: "Adjuntar a la lista de servidores",
|
|
|
|
|
context_unpinguild_text: "Deshazte de la lista de servidores",
|
2018-10-11 10:21:26 +02:00
|
|
|
|
header_pinneddms_text: "Mensajes Directos Fijados"
|
|
|
|
|
};
|
|
|
|
|
case "fr": //french
|
|
|
|
|
return {
|
|
|
|
|
context_pindm_text: "Épingler MP",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "Épingler à la liste des chaînes",
|
|
|
|
|
context_unpinchannel_text: "Détacher de la liste des chaînes",
|
|
|
|
|
context_pinguild_text: "Épingler à la liste de serveurs",
|
|
|
|
|
context_unpinguild_text: "Détacher de la liste de serveurs",
|
2018-10-11 10:21:26 +02:00
|
|
|
|
header_pinneddms_text: "Messages Prives Épinglés"
|
|
|
|
|
};
|
|
|
|
|
case "it": //italian
|
|
|
|
|
return {
|
2018-11-06 22:48:28 +01:00
|
|
|
|
context_pindm_text: "Fissa il messaggio diretto",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "Allega alla lista dei canali",
|
|
|
|
|
context_unpinchannel_text: "Rimuovi dalla lista dei canali",
|
|
|
|
|
context_pinguild_text: "Allega alla lista dei server",
|
|
|
|
|
context_unpinguild_text: "Rimuovi dalla lista dei server",
|
2018-10-11 10:21:26 +02:00
|
|
|
|
header_pinneddms_text: "Messaggi Diretti Aggiunti"
|
|
|
|
|
};
|
|
|
|
|
case "nl": //dutch
|
|
|
|
|
return {
|
2018-11-06 22:48:28 +01:00
|
|
|
|
context_pindm_text: "PB pinnen",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "Pin naar de kanalenlijst",
|
|
|
|
|
context_unpinchannel_text: "Losmaken van kanalenlijst",
|
|
|
|
|
context_pinguild_text: "Pin naar de serverlijst",
|
|
|
|
|
context_unpinguild_text: "Losmaken van serverlijst",
|
2018-10-11 10:21:26 +02:00
|
|
|
|
header_pinneddms_text: "Vastgezette Persoonluke Berichten"
|
|
|
|
|
};
|
|
|
|
|
case "no": //norwegian
|
|
|
|
|
return {
|
2018-11-06 22:48:28 +01:00
|
|
|
|
context_pindm_text: "Fest DM",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "Fest på kanalliste",
|
|
|
|
|
context_unpinchannel_text: "Fjern fra kanalliste",
|
|
|
|
|
context_pinguild_text: "Fest på serverliste",
|
|
|
|
|
context_unpinguild_text: "Fjern fra serverlisten",
|
2018-10-11 10:21:26 +02:00
|
|
|
|
header_pinneddms_text: "Pinned Direktemeldinger"
|
|
|
|
|
};
|
|
|
|
|
case "pl": //polish
|
|
|
|
|
return {
|
|
|
|
|
context_pindm_text: "Przypnij PW",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "Dołącz do listy kanałów",
|
|
|
|
|
context_unpinchannel_text: "Usuń z listy kanałów",
|
|
|
|
|
context_pinguild_text: "Dołącz do listy serwerów",
|
|
|
|
|
context_unpinguild_text: "Usuń z listy serwerów",
|
2018-10-11 10:21:26 +02:00
|
|
|
|
header_pinneddms_text: "Prywatne Wiadomości Bezpośrednie"
|
|
|
|
|
};
|
|
|
|
|
case "pt-BR": //portuguese (brazil)
|
|
|
|
|
return {
|
|
|
|
|
context_pindm_text: "Fixar MD",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "Anexar à lista de canais",
|
|
|
|
|
context_unpinchannel_text: "Remover da lista de canais",
|
|
|
|
|
context_pinguild_text: "Anexar à lista de servidores",
|
|
|
|
|
context_unpinguild_text: "Remover da lista de servidores",
|
2018-10-11 10:21:26 +02:00
|
|
|
|
header_pinneddms_text: "Mensagens diretas fixadas"
|
|
|
|
|
};
|
|
|
|
|
case "fi": //finnish
|
|
|
|
|
return {
|
|
|
|
|
context_pindm_text: "Kiinnitä yksityisviestit",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "Liitä kanavaluetteloon",
|
|
|
|
|
context_unpinchannel_text: "Poista kanavaluettelosta",
|
|
|
|
|
context_pinguild_text: "Liitä palvelinluetteloon",
|
|
|
|
|
context_unpinguild_text: "Poista palvelinluettelosta",
|
2018-10-11 10:21:26 +02:00
|
|
|
|
header_pinneddms_text: "Liitetyt yksityisviestit"
|
|
|
|
|
};
|
|
|
|
|
case "sv": //swedish
|
|
|
|
|
return {
|
2018-11-06 22:48:28 +01:00
|
|
|
|
context_pindm_text: "Fäst DM",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "Fäst till kanallista",
|
|
|
|
|
context_unpinchannel_text: "Ta bort från kanallistan",
|
|
|
|
|
context_pinguild_text: "Fäst till servernlista",
|
|
|
|
|
context_unpinguild_text: "Ta bort från servernlista",
|
2018-10-11 10:21:26 +02:00
|
|
|
|
header_pinneddms_text: "Inlagda Direktmeddelanden"
|
|
|
|
|
};
|
|
|
|
|
case "tr": //turkish
|
|
|
|
|
return {
|
|
|
|
|
context_pindm_text: "DM'yi Sabitle",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "Kanal listesine ekle",
|
|
|
|
|
context_unpinchannel_text: "Kanal listesinden kaldır",
|
|
|
|
|
context_pinguild_text: "Sunucu listesine ekle",
|
|
|
|
|
context_unpinguild_text: "Sunucu listesinden kaldır",
|
2018-10-11 10:21:26 +02:00
|
|
|
|
header_pinneddms_text: "Direkt Mesajlar Sabitleyin"
|
|
|
|
|
};
|
|
|
|
|
case "cs": //czech
|
|
|
|
|
return {
|
2018-11-06 22:48:28 +01:00
|
|
|
|
context_pindm_text: "Připnout PZ",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "Připojení k seznamu kanálů",
|
|
|
|
|
context_unpinchannel_text: "Odstranit ze seznamu kanálů",
|
|
|
|
|
context_pinguild_text: "Připojit ke seznamu serverů",
|
|
|
|
|
context_unpinguild_text: "Odstranit ze seznamu serverů",
|
2018-11-06 22:48:28 +01:00
|
|
|
|
header_pinneddms_text: "Připojené Přímá Zpráva"
|
2018-10-11 10:21:26 +02:00
|
|
|
|
};
|
|
|
|
|
case "bg": //bulgarian
|
|
|
|
|
return {
|
2018-11-06 22:48:28 +01:00
|
|
|
|
context_pindm_text: "Закачени ДС",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "Прикачете към списъка с канали",
|
|
|
|
|
context_unpinchannel_text: "Премахване от списъка с канали",
|
|
|
|
|
context_pinguild_text: "Прикачване към списъка със сървъри",
|
|
|
|
|
context_unpinguild_text: "Премахване от списъка със сървъри",
|
2018-10-11 10:21:26 +02:00
|
|
|
|
header_pinneddms_text: "Свързани директни съобщения"
|
|
|
|
|
};
|
|
|
|
|
case "ru": //russian
|
|
|
|
|
return {
|
2018-11-06 22:48:28 +01:00
|
|
|
|
context_pindm_text: "Закрепить ЛС",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "Прикрепить к списку каналов",
|
|
|
|
|
context_unpinchannel_text: "Удалить из списка каналов",
|
|
|
|
|
context_pinguild_text: "Присоединить к списку серверов",
|
|
|
|
|
context_unpinguild_text: "Удалить из списка серверов",
|
2018-11-06 22:48:28 +01:00
|
|
|
|
header_pinneddms_text: "Прикрепленные Личные Сообщения"
|
2018-10-11 10:21:26 +02:00
|
|
|
|
};
|
|
|
|
|
case "uk": //ukrainian
|
|
|
|
|
return {
|
2018-11-06 22:48:28 +01:00
|
|
|
|
context_pindm_text: "Закріпити ОП",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "Додайте до списку каналів",
|
|
|
|
|
context_unpinchannel_text: "Видалити зі списку каналів",
|
|
|
|
|
context_pinguild_text: "Додайте до списку серверів",
|
|
|
|
|
context_unpinguild_text: "Видалити зі списку серверів",
|
2018-10-11 10:21:26 +02:00
|
|
|
|
header_pinneddms_text: "Прикріплені oсобисті повідомлення"
|
|
|
|
|
};
|
|
|
|
|
case "ja": //japanese
|
|
|
|
|
return {
|
2018-11-06 22:48:28 +01:00
|
|
|
|
context_pindm_text: "DMピン",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "チャンネルリストに添付",
|
|
|
|
|
context_unpinchannel_text: "チャンネルリストから削除",
|
|
|
|
|
context_pinguild_text: "サーバーリストに添付",
|
|
|
|
|
context_unpinguild_text: "サーバーリストから削除",
|
2018-10-11 10:21:26 +02:00
|
|
|
|
header_pinneddms_text: "固定された直接メッセージ"
|
|
|
|
|
};
|
|
|
|
|
case "zh-TW": //chinese (traditional)
|
|
|
|
|
return {
|
2018-11-06 22:48:28 +01:00
|
|
|
|
context_pindm_text: "引腳直接留言",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "附加到頻道列表",
|
|
|
|
|
context_unpinchannel_text: "從頻道列表中刪除",
|
|
|
|
|
context_pinguild_text: "附加到服務器列表",
|
|
|
|
|
context_unpinguild_text: "從服務器列表中刪除",
|
2018-10-11 10:21:26 +02:00
|
|
|
|
header_pinneddms_text: "固定私人信息"
|
|
|
|
|
};
|
|
|
|
|
case "ko": //korean
|
|
|
|
|
return {
|
2018-11-06 22:48:28 +01:00
|
|
|
|
context_pindm_text: "비공개 메시지 고정",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "채널 목록에 첨부",
|
|
|
|
|
context_unpinchannel_text: "채널 목록에서 삭제",
|
|
|
|
|
context_pinguild_text: "서버 목록에 첨부",
|
|
|
|
|
context_unpinguild_text: "서버 목록에서 제거",
|
2018-10-11 10:21:26 +02:00
|
|
|
|
header_pinneddms_text: "고정 된 비공개 메시지"
|
|
|
|
|
};
|
|
|
|
|
default: //default: english
|
|
|
|
|
return {
|
|
|
|
|
context_pindm_text: "Pin DM",
|
2019-01-24 22:27:15 +01:00
|
|
|
|
context_pinchannel_text: "Pin to Channellist",
|
|
|
|
|
context_unpinchannel_text: "Unpin from Channellist",
|
|
|
|
|
context_pinguild_text: "Pin to Serverlist",
|
|
|
|
|
context_unpinguild_text: "Unpin from Serverlist",
|
2018-10-11 10:21:26 +02:00
|
|
|
|
header_pinneddms_text: "Pinned Direct Messages"
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|