Skip to content

Commit 5232867

Browse files
committed
feat: Add notify logic for level up and achievement completion notifications based on notification type
1 parent 67003c7 commit 5232867

File tree

1 file changed

+22
-8
lines changed
  • src/main/kotlin/com/github/ilovegamecoding/intellijcodexp/services

1 file changed

+22
-8
lines changed

src/main/kotlin/com/github/ilovegamecoding/intellijcodexp/services/CodeXPService.kt

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,19 @@ class CodeXPService : PersistentStateComponent<CodeXPState>, CodeXPEventListener
128128
val currentLevelInfo = CodeXPLevel.createLevelInfo(codeXPState.xp)
129129

130130
if (beforeLevelInfo.level != currentLevelInfo.level && beforeLevelInfo.level != 0 && codeXPState.codeXPConfiguration.showLevelUpNotification) {
131-
CodeXPNotificationManager.notifyLevelUp(
132-
codeXPState.nickname,
133-
currentLevelInfo.level,
134-
currentLevelInfo.totalXPForNextLevel
135-
)
131+
if (codeXPState.codeXPConfiguration.showLevelUpNotification) {
132+
when (codeXPState.codeXPConfiguration.notificationType) {
133+
"Intellij Notification" ->
134+
CodeXPNotificationManager.notifyLevelUp(
135+
codeXPState.nickname,
136+
currentLevelInfo.level,
137+
currentLevelInfo.totalXPForNextLevel
138+
)
139+
140+
"CodeXP Notification" ->
141+
messageBus.syncPublisher(CodeXPListener.CODEXP).levelUp(currentLevelInfo)
142+
}
143+
}
136144
}
137145

138146
messageBus.syncPublisher(CodeXPListener.CODEXP).xpUpdated(currentLevelInfo)
@@ -150,11 +158,17 @@ class CodeXPService : PersistentStateComponent<CodeXPState>, CodeXPEventListener
150158
if (challenge.progress >= challenge.goal) {
151159
increaseXP(challenge.rewardXP)
152160
replaceChallengeWithNew(challenge, event)
153-
CodeXPUIManager.showCodeXPDialog()
154161

155-
if (codeXPState.codeXPConfiguration.showCompleteChallengeNotification)
156-
CodeXPNotificationManager.notifyChallengeComplete(challenge)
162+
if (codeXPState.codeXPConfiguration.showCompleteChallengeNotification) {
163+
when (codeXPState.codeXPConfiguration.notificationType) {
164+
"Intellij Notification" -> CodeXPNotificationManager.notifyChallengeComplete(
165+
challenge
166+
)
157167

168+
"CodeXP Notification" ->
169+
messageBus.syncPublisher(CodeXPListener.CODEXP).challengeCompleted(event, challenge)
170+
}
171+
}
158172
messageBus.syncPublisher(CodeXPListener.CODEXP)
159173
.challengeUpdated(event, challenge, state.challenges[event])
160174
} else {

0 commit comments

Comments
 (0)