Skip to content

Commit

Permalink
Merge pull request #4560 from gemini-hlsw/throttle-take-2
Browse files Browse the repository at this point in the history
Throttle general updates
  • Loading branch information
rpiaggio authored Feb 13, 2025
2 parents 458b4a2 + e6b7f7f commit 75aadee
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 207 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ import explore.model.UserPreferences
import explore.model.enums.GridLayoutSection
import explore.model.layout
import explore.model.layout.LayoutsMap
import explore.utils.*
import japgolly.scalajs.react.*
import lucuma.core.model.User
import lucuma.react.common.ReactFnProps
import queries.common.UserPreferencesQueriesGQL.UserGridLayoutUpdates
import queries.common.UserPreferencesQueriesGQL.UserPreferencesUpdates
import queries.schemas.UserPreferencesDB

import scala.concurrent.duration.*

case class PreferencesCacheController(
userId: User.Id,
modUserPrefrences: (Pot[UserPreferences] => Pot[UserPreferences]) => IO[Unit]
Expand Down Expand Up @@ -64,7 +67,7 @@ object PreferencesCacheController
.subscribe[IO](props.userId.show)
.ignoreGraphQLErrors
.map:
_.map: data =>
_.throttle(5.seconds).map: data =>
UserPreferences.gridLayouts
.modify(GridLayouts.updateLayouts(data.lucumaGridLayoutPositions))

Expand All @@ -73,7 +76,7 @@ object PreferencesCacheController
.subscribe[IO](props.userId.show)
.ignoreGraphQLErrors
.map:
_.map: data =>
_.throttle(5.seconds).map: data =>
UserPreferences.globalPreferences
.modify(_ => data.lucumaUserPreferencesByPk.getOrElse(GlobalPreferences.Default))

Expand Down
Loading

0 comments on commit 75aadee

Please sign in to comment.