From 6b27db0d4f84721cad5b47e53f9473bc29e05681 Mon Sep 17 00:00:00 2001 From: Eric Handley Date: Thu, 27 Nov 2025 23:19:35 -0800 Subject: [PATCH] fix: remove unnecessary fallbacks and redundant code --- Modules/Panels/Launcher/Launcher.qml | 8 ++++---- Modules/Panels/Launcher/Plugins/EmojiPlugin.qml | 5 ++--- Services/Keyboard/EmojiService.qml | 8 ++++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Modules/Panels/Launcher/Launcher.qml b/Modules/Panels/Launcher/Launcher.qml index 026bd9dc..b944983d 100644 --- a/Modules/Panels/Launcher/Launcher.qml +++ b/Modules/Panels/Launcher/Launcher.qml @@ -774,8 +774,8 @@ SmartPanel { NText { id: emojiDisplay anchors.centerIn: parent - visible: modelData.emojiChar ? true : (!imagePreview.visible && !iconLoader.visible) - text: modelData.emojiChar ? modelData.emojiChar : (modelData.name ? modelData.name.charAt(0).toUpperCase() : "?") + visible: modelData.emojiChar || (!imagePreview.visible && !iconLoader.visible) + text: modelData.emojiChar ? modelData.emojiChar : modelData.name.charAt(0).toUpperCase() pointSize: modelData.emojiChar ? Style.fontSizeXXXL : Style.fontSizeXXL // Larger font for emojis font.weight: Style.fontWeightBold color: modelData.emojiChar ? Color.mOnSurface : Color.mOnPrimary // Different color for emojis @@ -1016,8 +1016,8 @@ SmartPanel { NText { id: gridEmojiDisplay anchors.centerIn: parent - visible: modelData.emojiChar ? true : (!gridImagePreview.visible && !gridIconLoader.visible) - text: modelData.emojiChar ? modelData.emojiChar : (modelData.name ? modelData.name.charAt(0).toUpperCase() : "?") + visible: modelData.emojiChar || (!gridImagePreview.visible && !gridIconLoader.visible) + text: modelData.emojiChar ? modelData.emojiChar : modelData.name.charAt(0).toUpperCase() pointSize: modelData.emojiChar ? Style.fontSizeXXL * 2 : Style.fontSizeXL font.weight: Style.fontWeightBold color: modelData.emojiChar ? Color.mOnSurface : Color.mOnPrimary diff --git a/Modules/Panels/Launcher/Plugins/EmojiPlugin.qml b/Modules/Panels/Launcher/Plugins/EmojiPlugin.qml index 202fce36..07f038aa 100644 --- a/Modules/Panels/Launcher/Plugins/EmojiPlugin.qml +++ b/Modules/Panels/Launcher/Plugins/EmojiPlugin.qml @@ -33,8 +33,7 @@ Item { target: EmojiService function onLoadedChanged() { if (EmojiService.loaded && root.launcher) { - // Update launcher results to refresh the UI - root.launcher?.updateResults(); + root.launcher.updateResults(); } } } @@ -105,7 +104,7 @@ Item { // Format an emoji entry for the results list function formatEmojiEntry(emoji) { let title = emoji.name; - let description = (emoji.keywords || []).join(", "); + let description = emoji.keywords.join(", "); if (emoji.category) { description += " • Category: " + emoji.category; diff --git a/Services/Keyboard/EmojiService.qml b/Services/Keyboard/EmojiService.qml index 5cbf0cc7..e5fc8dcd 100644 --- a/Services/Keyboard/EmojiService.qml +++ b/Services/Keyboard/EmojiService.qml @@ -33,9 +33,9 @@ Singleton { const results = emojis.filter(emoji => { for (let term of terms) { const emojiMatch = emoji.emoji.toLowerCase().includes(term); - const nameMatch = (emoji.name || "").toLowerCase().includes(term); - const keywordMatch = (emoji.keywords || []).some(kw => kw.toLowerCase().includes(term)); - const categoryMatch = (emoji.category || "").toLowerCase().includes(term); + const nameMatch = emoji.name.toLowerCase().includes(term); + const keywordMatch = emoji.keywords.some(kw => kw.toLowerCase().includes(term)); + const categoryMatch = emoji.category.toLowerCase().includes(term); if (!emojiMatch && !nameMatch && !keywordMatch && !categoryMatch) { return false; @@ -62,7 +62,7 @@ Singleton { if (b.usageCount !== a.usageCount) { return b.usageCount - a.usageCount; } - return (a.emoji.name || "").localeCompare(b.emoji.name || ""); + return a.emoji.name.localeCompare(b.emoji.name); }); // Return the emoji objects limited by the specified count