Skip to content

Commit

Permalink
fix supported by database "unread" value calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimiry committed Sep 23, 2018
1 parent 60385d4 commit c836157
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/web/src/app/_accounts/accounts.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {EMPTY, Subject, from, fromEvent, merge, of, timer} from "rxjs";
import {Injectable} from "@angular/core";
import {Store, select} from "@ngrx/store";
import {catchError, concatMap, debounce, filter, finalize, map, mergeMap, takeUntil, tap, withLatestFrom} from "rxjs/operators";
import {equals} from "ramda";

import {ACCOUNTS_ACTIONS, CORE_ACTIONS, OPTIONS_ACTIONS, unionizeActionFilter} from "src/web/src/app/store/actions";
import {AccountTypeAndLoginFieldContainer} from "src/shared/model/container";
Expand Down Expand Up @@ -40,8 +41,8 @@ export class AccountsEffects {
unionizeActionFilter(ACCOUNTS_ACTIONS.is.SetupNotificationChannel),
map(logActionTypeAndBoundLoggerWithActionType({_logger})),
mergeMap(({payload, logger}) => {
const {account: payloadAccount, webView, finishPromise} = payload;
const {type, login, entryUrl} = payloadAccount.accountConfig;
const {webView, finishPromise} = payload;
const {type, login, entryUrl} = payload.account.accountConfig;
const dispose$ = from(finishPromise).pipe(tap(() => logger.info("dispose")));

logger.info("setup");
Expand Down Expand Up @@ -110,8 +111,9 @@ export class AccountsEffects {
of(ACCOUNTS_ACTIONS.Patch({login, patch: {syncingActivated: true}})),
this.api.ipcMainClient({finishPromise})("notification")().pipe(
filter(IPC_MAIN_API_NOTIFICATION_ACTIONS.is.DbPatchAccount),
mergeMap(({payload: statPayload}) => {
return of(ACCOUNTS_ACTIONS.Patch({login, patch: {notifications: {unread: statPayload.stat.unread}}}));
filter(({payload: data}) => equals(data.key, {type, login})),
mergeMap(({payload: data}) => {
return of(ACCOUNTS_ACTIONS.Patch({login, patch: {notifications: {unread: data.stat.unread}}}));
}),
),
merge(
Expand Down

0 comments on commit c836157

Please sign in to comment.