This commit is contained in:
Mirco Wittrien 2019-07-28 08:17:38 +02:00
parent 1dc997d185
commit c78e70021d
4 changed files with 65 additions and 23 deletions

File diff suppressed because one or more lines are too long

View File

@ -1731,21 +1731,23 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins ? BDFDB.myPlugins : {}, BDv2Api
}; };
BDFDB.readUnreadServerList = function (servers) { BDFDB.readUnreadServerList = function (servers) {
var found = []; var found = [], UnreadUtils = BDFDB.WebModules.findByProperties("hasUnread", "getUnreadGuilds");
for (let info of servers === undefined || !Array.isArray(servers) ? BDFDB.readServerList() : servers) { for (let eleOrInfoOrId of servers === undefined || !Array.isArray(servers) ? BDFDB.readServerList() : servers) {
let div = Node.prototype.isPrototypeOf(info) ? info : info && info.div ? info.div : null; if (!eleOrInfoOrId) return null;
let props = BDFDB.getReactValue(div, "return.stateNode.props"); let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.getServerID(eleOrInfoOrId) : typeof eleOrInfoOrId == 'object' ? eleOrInfoOrId.id : eleOrInfoOrId;
if (props && (props.unread || props.badge > 0)) found.push(info); id = typeof id == 'number' ? id.toFixed() : id;
if (id && UnreadUtils.hasUnread(id)) found.push(eleOrInfoOrId);
} }
return found; return found;
}; };
BDFDB.readMutedServerList = function (servers) { BDFDB.readMutedServerList = function (servers) {
var found = [], UnreadUtils = BDFDB.WebModules.findByProperties("isGuildOrCategoryOrChannelMuted"); var found = [], MutedUtils = BDFDB.WebModules.findByProperties("isGuildOrCategoryOrChannelMuted");
for (let info of servers === undefined || !Array.isArray(servers) ? BDFDB.readServerList() : servers) { for (let eleOrInfoOrId of servers === undefined || !Array.isArray(servers) ? BDFDB.readServerList() : servers) {
let div = Node.prototype.isPrototypeOf(info) ? info : info && info.div ? info.div : null; if (!eleOrInfoOrId) return null;
let id = BDFDB.getReactValue(div, "return.stateNode.props.guild.id"); let id = Node.prototype.isPrototypeOf(eleOrInfoOrId) ? BDFDB.getServerID(eleOrInfoOrId) : typeof eleOrInfoOrId == 'object' ? eleOrInfoOrId.id : eleOrInfoOrId;
if (id && UnreadUtils.isGuildOrCategoryOrChannelMuted(id)) found.push(info); id = typeof id == 'number' ? id.toFixed() : id;
if (id && MutedUtils.isGuildOrCategoryOrChannelMuted(id)) found.push(eleOrInfoOrId);
} }
return found; return found;
}; };
@ -1860,28 +1862,54 @@ var BDFDB = {myPlugins: BDFDB && BDFDB.myPlugins ? BDFDB.myPlugins : {}, BDv2Api
return null; return null;
}; };
var unreadingchannels = false;
BDFDB.markChannelAsRead = function (channels) { BDFDB.markChannelAsRead = function (channels) {
if (!channels) return; if (!channels) return;
var UnreadUtils = BDFDB.WebModules.findByProperties("getOldestUnreadMessageId"); var UnreadUtils = BDFDB.WebModules.findByProperties("getOldestUnreadMessageId");
var ChannelAckUtils = BDFDB.WebModules.findByProperties("ack", "localAck"); var ChannelAckUtils = BDFDB.WebModules.findByProperties("ack", "localAck");
if (!UnreadUtils || !ChannelAckUtils) return; if (!UnreadUtils || !ChannelAckUtils) return;
for (let info of Array.isArray(channels) ? channels : (typeof channels == "string" || typeof channels == "number" ? Array.of(channels) : Array.from(channels))) { else if (unreadingchannels) return BDFDB.showToast("Already marking some channels as unread, please wait...", {type:"error"});
let id = Node.prototype.isPrototypeOf(info) ? (BDFDB.getChannelID(info) || BDFDB.getDmID(info)) : info && typeof info == 'object' ? info.id : info; unreadingchannels = true;
channels = Array.isArray(channels) ? channels : (typeof channels == "string" || typeof channels == "number" ? Array.of(channels) : Array.from(channels));
var unread = () => {
var channel = channels.pop();
if (!channel) {
unreadingchannels = false;
return;
}
else {
let id = Node.prototype.isPrototypeOf(channel) ? (BDFDB.getChannelID(channel) || BDFDB.getDmID(channel)) : channel && typeof channel == 'object' ? channel.id : channel;
if (id) { if (id) {
let messageid = UnreadUtils.getOldestUnreadMessageId(id); let messageid = UnreadUtils.getOldestUnreadMessageId(id);
if (messageid) ChannelAckUtils.ack(id, true, true); if (messageid) ChannelAckUtils.ack(id, true, true);
} }
setTimeout(unread, Math.floor((Math.random() * (3000 - 1000)) + 1000));
} }
}
unread();
}; };
var unreadingguilds = false;
BDFDB.markGuildAsRead = function (servers) { BDFDB.markGuildAsRead = function (servers) {
if (!servers) return; if (!servers) return;
var GuildManageUtils = BDFDB.WebModules.findByProperties('markGuildAsRead'); var GuildManageUtils = BDFDB.WebModules.findByProperties('markGuildAsRead');
if (!GuildManageUtils) return; if (!GuildManageUtils) return;
for (let info of Array.isArray(servers) ? servers : (typeof servers == "string" || typeof servers == "number" ? Array.of(servers) : Array.from(servers))) { else if (unreadingguilds) return BDFDB.showToast("Already marking some servers as unread, please wait...", {type:"error"});
let id = Node.prototype.isPrototypeOf(info) ? BDFDB.getServerID(info) : info && typeof info == 'object' ? info.id : info; unreadingguilds = true;
if (id) GuildManageUtils.markGuildAsRead(id); servers = Array.isArray(servers) ? servers : (typeof servers == "string" || typeof servers == "number" ? Array.of(servers) : Array.from(servers));
var unread = () => {
var server = servers.pop();
if (!server) {
unreadingguilds = false;
return;
} }
else {
let id = Node.prototype.isPrototypeOf(server) ? BDFDB.getServerID(server) : server && typeof server == 'object' ? server.id : server;
if (id) GuildManageUtils.markGuildAsRead(id);
setTimeout(unread, Math.floor((Math.random() * (3000 - 1000)) + 1000));
}
}
unread();
}; };
BDFDB.saveAllData = function (data, plugin, key) { BDFDB.saveAllData = function (data, plugin, key) {

View File

@ -48,8 +48,12 @@ class EditUsers {
${BDFDB.dotCNS.message + BDFDB.dotCN.messageheadercozy} { ${BDFDB.dotCNS.message + BDFDB.dotCN.messageheadercozy} {
padding-top: 0; padding-top: 0;
} }
${BDFDB.dotCN.messageheadercozymeta} > span:first-child { ${BDFDB.dotCN.messageheadercompact} > span.popout-open,
${BDFDB.dotCN.messageheadercompact} > span[class=""],
${BDFDB.dotCN.messageheadercozymeta} > span.popout-open,
${BDFDB.dotCN.messageheadercozymeta} > span[class=""] {
display: inline-flex; display: inline-flex;
align-items: center;
} }
${BDFDB.dotCN.bottag} { ${BDFDB.dotCN.bottag} {
line-height: 13px; line-height: 13px;

View File

@ -3,7 +3,7 @@
class TopRoleEverywhere { class TopRoleEverywhere {
getName () {return "TopRoleEverywhere";} getName () {return "TopRoleEverywhere";}
getVersion () {return "2.8.1";} getVersion () {return "2.8.2";}
getAuthor () {return "DevilBro";} getAuthor () {return "DevilBro";}
@ -21,10 +21,20 @@ class TopRoleEverywhere {
}; };
this.css = ` this.css = `
${BDFDB.dotCNS.message + BDFDB.dotCN.messageheadercozy} {
padding-top: 0;
}
${BDFDB.dotCN.messageheadercompact} > span.popout-open,
${BDFDB.dotCN.messageheadercompact} > span[class=""],
${BDFDB.dotCN.messageheadercozymeta} > span.popout-open,
${BDFDB.dotCN.messageheadercozymeta} > span[class=""] {
display: inline-flex;
align-items: center;
}
.TRE-tag { .TRE-tag {
border-radius: 3px; border-radius: 3px;
box-sizing: border-box; box-sizing: border-box;
display: block; display: inline-block;
flex-shrink: 0; flex-shrink: 0;
font-size: 10px; font-size: 10px;
font-weight: 500; font-weight: 500;