-
Notifications
You must be signed in to change notification settings - Fork 274
Notification dismissal state tracking #5129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
samgst-amazon
merged 15 commits into
samgst/notificationPolling
from
samgst/notificationStates
Nov 27, 2024
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8e9325c
split notifications into separated lists.
samgst-amazon ff7debe
split notifs into two lists
samgst-amazon f2072e4
add persistent notification dismissal state logic
samgst-amazon 5009de3
boolean changes
samgst-amazon 9b60583
group persistant states
samgst-amazon 34cbdfa
comments
samgst-amazon 71e90d3
Merge branch 'samgst/notificationPolling' into samgst/notificationStates
samgst-amazon 45bc05d
Service initialized automatically
samgst-amazon 37b18f9
isStartup global
samgst-amazon 54799ef
Deserialized notification schedule type
samgst-amazon 81fa23a
tests
samgst-amazon e15c0a4
persistent state syntax
samgst-amazon 911b61e
convert to light services
samgst-amazon 594ecff
Remove state from companion object
samgst-amazon 3e1725f
detekt
samgst-amazon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
...ommunity/src/software/aws/toolkits/jetbrains/core/notifications/NotificationStateUtils.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| // Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package software.aws.toolkits.jetbrains.core.notifications | ||
|
|
||
| import com.intellij.openapi.components.PersistentStateComponent | ||
| import com.intellij.openapi.components.RoamingType | ||
| import com.intellij.openapi.components.Service | ||
| import com.intellij.openapi.components.State | ||
| import com.intellij.openapi.components.Storage | ||
| import com.intellij.openapi.components.service | ||
|
|
||
| @Service | ||
| @State(name = "notificationDismissals", storages = [Storage("aws.xml", roamingType = RoamingType.DISABLED)]) | ||
| class NotificationDismissalState : PersistentStateComponent<NotificationDismissalConfiguration> { | ||
| private val state = NotificationDismissalConfiguration() | ||
|
|
||
| override fun getState(): NotificationDismissalConfiguration = state | ||
|
|
||
| override fun loadState(state: NotificationDismissalConfiguration) { | ||
| this.state.dismissedNotificationIds.clear() | ||
| this.state.dismissedNotificationIds.addAll(state.dismissedNotificationIds) | ||
| } | ||
|
|
||
| fun isDismissed(notificationId: String): Boolean = | ||
| state.dismissedNotificationIds.contains(notificationId) | ||
|
|
||
| fun dismissNotification(notificationId: String) { | ||
| state.dismissedNotificationIds.add(notificationId) | ||
| } | ||
|
|
||
| companion object { | ||
| fun getInstance(): NotificationDismissalState = | ||
| service() | ||
| } | ||
| } | ||
|
|
||
| data class NotificationDismissalConfiguration( | ||
| var dismissedNotificationIds: MutableSet<String> = mutableSetOf(), | ||
| ) | ||
|
|
||
| @Service | ||
| @State(name = "notificationEtag", storages = [Storage("aws.xml", roamingType = RoamingType.DISABLED)]) | ||
| class NotificationEtagState : PersistentStateComponent<NotificationEtagConfiguration> { | ||
| private val state = NotificationEtagConfiguration() | ||
|
|
||
| override fun getState(): NotificationEtagConfiguration = state | ||
|
|
||
| override fun loadState(state: NotificationEtagConfiguration) { | ||
| this.state.etag = state.etag | ||
| } | ||
|
|
||
| var etag: String? | ||
| get() = state.etag | ||
| set(value) { | ||
| state.etag = value | ||
| } | ||
|
|
||
| companion object { | ||
| fun getInstance(): NotificationEtagState = | ||
| service() | ||
| } | ||
| } | ||
|
|
||
| data class NotificationEtagConfiguration( | ||
| var etag: String? = null, | ||
| ) | ||
|
|
||
| @Service | ||
| class BannerNotificationService { | ||
| private val notifications = mutableMapOf<String, BannerContent>() | ||
|
|
||
| fun addNotification(id: String, content: BannerContent) { | ||
| notifications[id] = content | ||
| } | ||
|
|
||
| fun getNotifications(): Map<String, BannerContent> = notifications | ||
|
|
||
| fun removeNotification(id: String) { | ||
| notifications.remove(id) | ||
| } | ||
|
|
||
| companion object { | ||
| fun getInstance(): BannerNotificationService = | ||
| service() | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not convinced we actually need a custom deserializer but ok