Skip to content

Commit

Permalink
ensure that first presenceMap will be fired
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreKoepke committed Nov 1, 2024
1 parent b6ece5b commit aca66d9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void setupPresenceMap() {
UserConfig::getName,
user -> user.getFailedPings() < ALLOWED_FAILS
));
presenceMap$.onNext(presenceMap);
}

@ConsumeEvent(value = GENERAL, blocking = true)
Expand Down Expand Up @@ -141,6 +142,7 @@ private boolean canPingIp(UserConfig userConfig) {

public Flowable<Boolean> isAnyoneAtHome$() {
return presenceMap$
.distinctUntilChanged()
.subscribeOn(RxHelper.blockingScheduler(vertx))
.map(presenceMapUpdate -> presenceMapUpdate.values().stream().anyMatch(isAtHome -> isAtHome))
.toFlowable(BackpressureStrategy.ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ public void entered(boolean quiet) {

super.disposeWhenClosed(userService.isAnyoneAtHome$()
.skip(1)
.distinctUntilChanged()
.filter(anyOneAtHome -> deviceService.isAnyLightOn())
.delay(10, TimeUnit.MINUTES)
.switchMap(this::shouldLightsTurnedOff)
Expand Down

0 comments on commit aca66d9

Please sign in to comment.