diff --git a/platform/whatsNew/src/com/intellij/platform/whatsNew/WhatsNewAction.kt b/platform/whatsNew/src/com/intellij/platform/whatsNew/WhatsNewAction.kt index 05a3c7250d72..ecb96ed389c5 100644 --- a/platform/whatsNew/src/com/intellij/platform/whatsNew/WhatsNewAction.kt +++ b/platform/whatsNew/src/com/intellij/platform/whatsNew/WhatsNewAction.kt @@ -9,15 +9,12 @@ import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.DataContext import com.intellij.openapi.application.ApplicationNamesInfo -import com.intellij.openapi.components.Service import com.intellij.openapi.components.service import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.diagnostic.runAndLogException +import com.intellij.openapi.progress.currentThreadCoroutineScope import com.intellij.openapi.project.Project import com.intellij.platform.whatsNew.reaction.FUSReactionChecker -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.async import kotlinx.coroutines.launch import org.jetbrains.concurrency.await @@ -29,12 +26,6 @@ internal class WhatsNewAction : AnAction(), com.intellij.openapi.project.DumbAwa private val REACTIONS_STATE = "whatsnew.reactions.state" private val reactionChecker = FUSReactionChecker(REACTIONS_STATE) - private val hasWhatsNewContent by lazy { - appScope.async { - WhatsNewContent.hasWhatsNewContent() - } - } - suspend fun openWhatsNew(project: Project) { LOG.info("Open What's New page requested.") val dataContext = LOG.runAndLogException { DataManager.getInstance().dataContextFromFocusAsync.await() } @@ -55,9 +46,8 @@ internal class WhatsNewAction : AnAction(), com.intellij.openapi.project.DumbAwa return ActionUpdateThread.BGT } - @OptIn(ExperimentalCoroutinesApi::class) override fun update(e: AnActionEvent) { - e.presentation.isEnabledAndVisible = if (hasWhatsNewContent.isCompleted) hasWhatsNewContent.getCompleted() else false + e.presentation.isEnabledAndVisible = service().isContentAvailable e.presentation.setText(IdeBundle.messagePointer("whats.new.action.custom.text", ApplicationNamesInfo.getInstance().fullProductName)) e.presentation.setDescription(IdeBundle.messagePointer("whats.new.action.custom.description", ApplicationNamesInfo.getInstance().fullProductName)) } @@ -65,7 +55,7 @@ internal class WhatsNewAction : AnAction(), com.intellij.openapi.project.DumbAwa override fun actionPerformed(e: AnActionEvent) { val project = e.project if (project != null) { - project.getScope().launch { + currentThreadCoroutineScope().launch { openWhatsNewPage(project, e.dataContext, true) } } else { @@ -74,13 +64,4 @@ internal class WhatsNewAction : AnAction(), com.intellij.openapi.project.DumbAwa } } -@Service(Service.Level.PROJECT) -private class ScopeProvider(val scope: CoroutineScope) -private fun Project.getScope() = this.service().scope - -@Service(Service.Level.APP) -private class AppScopeProvider(val scope: CoroutineScope) -private val appScope: CoroutineScope - get() = service().scope - private val LOG = logger() diff --git a/platform/whatsNew/src/com/intellij/platform/whatsNew/WhatsNewShowOnStartCheckService.kt b/platform/whatsNew/src/com/intellij/platform/whatsNew/WhatsNewShowOnStartCheckService.kt index c9cf1b2f80b4..b066d189f2b2 100644 --- a/platform/whatsNew/src/com/intellij/platform/whatsNew/WhatsNewShowOnStartCheckService.kt +++ b/platform/whatsNew/src/com/intellij/platform/whatsNew/WhatsNewShowOnStartCheckService.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.platform.whatsNew import com.intellij.codeWithMe.ClientId @@ -10,6 +10,8 @@ import com.intellij.openapi.actionSystem.ActionManager import com.intellij.openapi.application.ex.ApplicationInfoEx import com.intellij.openapi.client.ClientKind import com.intellij.openapi.client.ClientSessionsManager +import com.intellij.openapi.components.Service +import com.intellij.openapi.components.serviceAsync import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.project.Project import com.intellij.openapi.startup.ProjectActivity @@ -70,6 +72,14 @@ private class WhatsNewEnvironmentAccessorImpl : WhatsNewEnvironmentAccessor { } } +@Service +internal class WhatsNewStatus { + private val isContentAvailableFlag = AtomicBoolean() + var isContentAvailable: Boolean + get() = isContentAvailableFlag.get() + set(value) = isContentAvailableFlag.set(value) +} + internal class WhatsNewShowOnStartCheckService(private val environment: WhatsNewEnvironmentAccessor) : ProjectActivity { @Suppress("unused") // used by the component container constructor() : this(WhatsNewEnvironmentAccessorImpl()) @@ -87,6 +97,7 @@ internal class WhatsNewShowOnStartCheckService(private val environment: WhatsNew val content = environment.getWhatsNewContent() logger.info("Got What's New content: $content") if (content != null) { + serviceAsync().isContentAvailable = content.isAvailable() if (WhatsNewContentVersionChecker.isNeedToShowContent(content).also { logger.info("Should show What's New: $it") }) { val whatsNewAction = environment.findAction() if (whatsNewAction != null) {