From d498c599fad08745a54d62acaa8c77cd6a27e0b6 Mon Sep 17 00:00:00 2001 From: WarningImHack3r <43064022+WarningImHack3r@users.noreply.github.com> Date: Mon, 8 Jan 2024 14:14:43 +0100 Subject: [PATCH] Fix compatibility issues, drop support for 212 --- gradle.properties | 2 +- .../backend/sources/Source.kt | 2 +- .../notifications/NotificationManager.kt | 18 ++++++++++-------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/gradle.properties b/gradle.properties index 0854f89..09edd87 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ pluginRepositoryUrl = https://github.com/WarningImHack3r/intellij-shadcn-plugin pluginVersion = 1.0.0 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html -pluginSinceBuild = 212 +pluginSinceBuild = 213 pluginUntilBuild = # IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension diff --git a/src/main/kotlin/com/github/warningimhack3r/intellijshadcnplugin/backend/sources/Source.kt b/src/main/kotlin/com/github/warningimhack3r/intellijshadcnplugin/backend/sources/Source.kt index 62f1bc9..2838ca2 100644 --- a/src/main/kotlin/com/github/warningimhack3r/intellijshadcnplugin/backend/sources/Source.kt +++ b/src/main/kotlin/com/github/warningimhack3r/intellijshadcnplugin/backend/sources/Source.kt @@ -127,7 +127,7 @@ abstract class Source(val project: Project, private val serializer: "Installed $dependenciesList for ${component.name}.", ) } - notif.hideBalloon() + notif.expire() } } } diff --git a/src/main/kotlin/com/github/warningimhack3r/intellijshadcnplugin/notifications/NotificationManager.kt b/src/main/kotlin/com/github/warningimhack3r/intellijshadcnplugin/notifications/NotificationManager.kt index a769f96..ea3fce7 100644 --- a/src/main/kotlin/com/github/warningimhack3r/intellijshadcnplugin/notifications/NotificationManager.kt +++ b/src/main/kotlin/com/github/warningimhack3r/intellijshadcnplugin/notifications/NotificationManager.kt @@ -5,6 +5,9 @@ import com.intellij.notification.NotificationAction import com.intellij.notification.NotificationType import com.intellij.notification.Notifications import com.intellij.openapi.project.Project +import com.intellij.util.concurrency.AppExecutorUtil +import java.util.concurrent.ScheduledExecutorService +import java.util.concurrent.TimeUnit class NotificationManager(val project: Project? = null) { @@ -22,19 +25,18 @@ class NotificationManager(val project: Project? = null) { actions.forEach { addAction(it) } } - @Suppress("UnstableApiUsage") // notifyAndHide is still experimental private fun sendNotification( notification: Notification, hide: Boolean = false ) { + project?.let { + Notifications.Bus.notify(notification, it) + } ?: Notifications.Bus.notify(notification) if (hide) { - project?.let { - Notifications.Bus.notifyAndHide(notification, it) - } ?: Notifications.Bus.notifyAndHide(notification) - } else { - project?.let { - Notifications.Bus.notify(notification, it) - } ?: Notifications.Bus.notify(notification) + // Taken from experimental Notifications.Bus.notifyAndHide + (AppExecutorUtil.getAppExecutorService() as ScheduledExecutorService).schedule({ + notification.expire() + }, 5, TimeUnit.SECONDS) } }