Skip to content
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

Notification popups #2027

Merged
merged 14 commits into from
Jul 14, 2024
Prev Previous commit
Next Next commit
Only show top-level achievement notification when first obtained
  • Loading branch information
byorgey committed Jul 14, 2024
commit b3738e2ffbae726886c0687b5ff3f427a3b41921
6 changes: 5 additions & 1 deletion src/swarm-tui/Swarm/TUI/Model/Achievements.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ module Swarm.TUI.Model.Achievements (
) where

import Control.Lens hiding (from, (<.>))
import Control.Monad (when)
import Control.Monad.IO.Class (MonadIO (liftIO))
import Control.Monad.State (MonadState)
import Data.Map qualified as M
import Data.Maybe (isNothing)
import Data.Time (ZonedTime, getZonedTime)
import Swarm.Game.Achievement.Attainment
import Swarm.Game.Achievement.Definitions
Expand All @@ -34,7 +36,9 @@ attainAchievement' ::
CategorizedAchievement ->
m ()
attainAchievement' t p a = do
notifyAchievement a
mAttainment <- use $ uiState . uiAchievements . at a
when (isNothing mAttainment) $ notifyAchievement a

(uiState . uiAchievements)
%= M.insertWith
(<>)
Expand Down