Skip to content

Commit c8dcc53

Browse files
Copilotsds100
andcommitted
Address PR review feedback
- Use action.hashCode() for notification ID as requested - Rename ConfigCreateNotification to ConfigNotificationAction Co-authored-by: sds100 <16245954+sds100@users.noreply.github.com>
1 parent e182815 commit c8dcc53

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

base/src/main/java/io/github/sds100/keymapper/base/BaseMainNavHost.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ fun BaseMainNavHost(
9191
)
9292
}
9393

94-
composable<NavDestination.ConfigCreateNotification> { backStackEntry ->
94+
composable<NavDestination.ConfigNotificationAction> { backStackEntry ->
9595
val viewModel: ConfigCreateNotificationViewModel = hiltViewModel()
9696

97-
backStackEntry.handleRouteArgs<NavDestination.ConfigCreateNotification> { destination ->
97+
backStackEntry.handleRouteArgs<NavDestination.ConfigNotificationAction> { destination ->
9898
destination.actionJson?.let { viewModel.loadAction(Json.decodeFromString(it)) }
9999
}
100100

base/src/main/java/io/github/sds100/keymapper/base/actions/CreateActionDelegate.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ class CreateActionDelegate(
889889

890890
return navigate(
891891
"config_create_notification_action",
892-
NavDestination.ConfigCreateNotification(
892+
NavDestination.ConfigNotificationAction(
893893
oldAction?.let {
894894
Json.encodeToString(oldAction)
895895
},

base/src/main/java/io/github/sds100/keymapper/base/actions/PerformActionsUseCase.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -932,11 +932,8 @@ class PerformActionsUseCaseImpl @AssistedInject constructor(
932932
}
933933

934934
is ActionData.CreateNotification -> {
935-
// Generate a unique notification ID using absolute value to avoid negative IDs
936-
// Combine timestamp and hash to ensure uniqueness
937-
val timestamp = (System.currentTimeMillis() / 1000).toInt()
938-
val contentHash = (action.title + action.text).hashCode()
939-
val notificationId = (timestamp.toLong() + contentHash).toInt().let {
935+
// Use the hashcode of the action instance as the unique notification ID
936+
val notificationId = action.hashCode().let {
940937
if (it < 0) -it else it
941938
}
942939

base/src/main/java/io/github/sds100/keymapper/base/utils/navigation/NavDestination.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ abstract class NavDestination<R>(val isCompose: Boolean = false) {
174174
}
175175

176176
@Serializable
177-
data class ConfigCreateNotification(val actionJson: String?) :
177+
data class ConfigNotificationAction(val actionJson: String?) :
178178
NavDestination<ActionData.CreateNotification>(isCompose = true) {
179179
override val id: String = ID_CREATE_NOTIFICATION_ACTION
180180
}

0 commit comments

Comments
 (0)