mirror of
https://github.com/Lightcord/Lightcord.git
synced 2025-04-12 00:55:40 +02:00
+ Fixing notifications
+ adding sending emoji
This commit is contained in:
parent
677d0a9945
commit
7eb053fd5a
File diff suppressed because one or more lines are too long
@ -23,18 +23,14 @@ export default new class EmojiModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async init(){
|
async init(){
|
||||||
|
/** Emoji AutoComplete */
|
||||||
if(!AutocompleteModule)AutocompleteModule = await window.Lightcord.Api.ensureExported(e => e.default && e.default.displayName === "Autocomplete")
|
if(!AutocompleteModule)AutocompleteModule = await window.Lightcord.Api.ensureExported(e => e.default && e.default.displayName === "Autocomplete")
|
||||||
if(!AutoCompletionTemplates)AutoCompletionTemplates = await window.Lightcord.Api.ensureExported(e => e.getAutocompleteOptions)
|
if(!AutoCompletionTemplates)AutoCompletionTemplates = await window.Lightcord.Api.ensureExported(e => e.getAutocompleteOptions)
|
||||||
if(!EmojiModuleQuery)EmojiModuleQuery = await window.Lightcord.Api.ensureExported(e => e.default && e.default.queryEmojiResults)
|
if(!EmojiModuleQuery)EmojiModuleQuery = await window.Lightcord.Api.ensureExported(e => e.default && e.default.queryEmojiResults)
|
||||||
if(!Messages)Messages = await window.Lightcord.Api.ensureExported(e => e.default && e.default.Messages && e.default.Messages.EMOJI_MATCHING)
|
if(!Messages)Messages = await window.Lightcord.Api.ensureExported(e => e.default && e.default.Messages && e.default.Messages.EMOJI_MATCHING)
|
||||||
if(!guildModule)guildModule = await window.Lightcord.Api.ensureExported(e => e.default && e.default.getGuild && e.default.getGuilds && !e.default.isFetching)
|
if(!guildModule)guildModule = await window.Lightcord.Api.ensureExported(e => e.default && e.default.getGuild && e.default.getGuilds && !e.default.isFetching)
|
||||||
if(!emojiSearch)emojiSearch = await window.Lightcord.Api.ensureExported(e => e.default && e.default.getDisambiguatedEmojiContext)
|
if(!emojiSearch)emojiSearch = await window.Lightcord.Api.ensureExported(e => e.default && e.default.getDisambiguatedEmojiContext)
|
||||||
if(true /** AutocompleteModule && AutoCompletionTemplates && EmojiModuleQuery && Messages && guildModule && emojiSearch */){/*
|
if(AutocompleteModule && AutoCompletionTemplates && EmojiModuleQuery && Messages && guildModule && emojiSearch){
|
||||||
if(!this.cancelAutocompleteRender){
|
|
||||||
this.cancelAutocompleteRender = Utils.monkeyPatch(AutocompleteModule, "default", {
|
|
||||||
|
|
||||||
})
|
|
||||||
}*/
|
|
||||||
console.log(`Patching getAutocompleteOptions of AutoCompletionTemplates`, AutoCompletionTemplates)
|
console.log(`Patching getAutocompleteOptions of AutoCompletionTemplates`, AutoCompletionTemplates)
|
||||||
const getAutocompleteOptions = AutoCompletionTemplates.getAutocompleteOptions
|
const getAutocompleteOptions = AutoCompletionTemplates.getAutocompleteOptions
|
||||||
AutoCompletionTemplates.getAutocompleteOptions = function(e, t, n, r, a){
|
AutoCompletionTemplates.getAutocompleteOptions = function(e, t, n, r, a){
|
||||||
@ -61,9 +57,12 @@ export default new class EmojiModule {
|
|||||||
return "." + e + "."
|
return "." + e + "."
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
getPlainText(id, emojis){
|
getPlainText(id, guild){
|
||||||
var emojis = emojis.emojis;
|
var emojis = guild.emojis;
|
||||||
return null == emojis || null == emojis[id] ? "" : "." + emojis[id].name + "."
|
if (null == emojis || null == emojis[id]) return "";
|
||||||
|
var emoji = emojis[id],
|
||||||
|
isAnimated = emoji.animated ? "a" : "";
|
||||||
|
return emoji.managed || null == emoji.id ? "." + emoji.name + "." : "<" + isAnimated + "." + (emoji.originalName || emoji.name) + "." + emoji.id + ">"
|
||||||
},
|
},
|
||||||
getRawText(id, guild){
|
getRawText(id, guild){
|
||||||
var emojis = guild.emojis;
|
var emojis = guild.emojis;
|
||||||
@ -79,8 +78,8 @@ export default new class EmojiModule {
|
|||||||
console.error(new Error("Couldn't start autocompletion of Lightcord's emojis."))
|
console.error(new Error("Couldn't start autocompletion of Lightcord's emojis."))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Emoji display */
|
||||||
while (!BDV2.MessageComponent) await new Promise(resolve => setTimeout(resolve, 100));
|
while (!BDV2.MessageComponent) await new Promise(resolve => setTimeout(resolve, 100));
|
||||||
|
|
||||||
if (!this.cancelEmojiRender){
|
if (!this.cancelEmojiRender){
|
||||||
this.cancelEmoteRender = Utils.monkeyPatch(BDV2.MessageComponent, "default", {before: (data) => {
|
this.cancelEmoteRender = Utils.monkeyPatch(BDV2.MessageComponent, "default", {before: (data) => {
|
||||||
const message = Utils.getNestedProp(data.methodArguments[0], "childrenMessageContent.props.message")
|
const message = Utils.getNestedProp(data.methodArguments[0], "childrenMessageContent.props.message")
|
||||||
@ -224,8 +223,11 @@ function setEmojiUsable(usable){
|
|||||||
if(!isEmojiDisabled)isEmojiDisabled = EmojiFilterModule.default.isEmojiDisabled
|
if(!isEmojiDisabled)isEmojiDisabled = EmojiFilterModule.default.isEmojiDisabled
|
||||||
|
|
||||||
hasPatched = true
|
hasPatched = true
|
||||||
EmojiFilterModule.default.isEmojiDisabled = function(){
|
EmojiFilterModule.default.isEmojiDisabled = function(emoji){
|
||||||
if(isUsable)return false
|
if(isUsable){
|
||||||
|
if(emoji.surrogates || emoji.diversity)return true
|
||||||
|
return false
|
||||||
|
}
|
||||||
return isEmojiDisabled.call(this, ...arguments)
|
return isEmojiDisabled.call(this, ...arguments)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -137,13 +137,13 @@ function handleNotificationClick(e, notificationId) {
|
|||||||
let isClosing = []
|
let isClosing = []
|
||||||
function handleNotificationClose(e, notificationId) {
|
function handleNotificationClose(e, notificationId) {
|
||||||
if(isClosing.includes(notificationId))return
|
if(isClosing.includes(notificationId))return
|
||||||
|
isClosing.push(notificationId)
|
||||||
if (notificationWindow) {
|
if (notificationWindow) {
|
||||||
webContentsSend(notificationWindow, 'FADE_OUT', notificationId);
|
webContentsSend(notificationWindow, 'FADE_OUT', notificationId);
|
||||||
}
|
}
|
||||||
isClosing.push(notificationId)
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
notifications = notifications.filter(notification => notification.id !== notificationId);
|
notifications = notifications.filter(notification => notification.id !== notificationId);
|
||||||
isClosing = isClosing.filter(e => e.id !== notificationId)
|
isClosing = isClosing.filter(e => e!== notificationId)
|
||||||
updateNotifications();
|
updateNotifications();
|
||||||
}, VARIABLES.outDuration);
|
}, VARIABLES.outDuration);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user