Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
Feature: AccountNotifications - improve sync
Browse files Browse the repository at this point in the history
  • Loading branch information
ovr committed Feb 24, 2018
1 parent 37acc9f commit 7ed3b37
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
12 changes: 2 additions & 10 deletions actions/account-notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ import Realm from 'utils/realm';
import { paginateBySlice } from 'utils/paginate';

export function trySyncNotifications(): ThunkAction {
return (dispatch: Dispatch, getState: GetState) => {
const state = getState();

if (state.accountNotifications && state.accountNotifications.sync) {
return;
}

return (dispatch: Dispatch) => {
dispatch(syncNotifications());
};
}
Expand Down Expand Up @@ -49,9 +43,7 @@ export function syncNotifications(): ThunkAction {
function (result, page) {
dispatch({
type: ACCOUNT_NOTIFICATIONS_SYNC_PROGRESS,
payload: {
page
}
payload: page
});

Realm.write(
Expand Down
2 changes: 1 addition & 1 deletion constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const NAVIGATION_SET_TITLE = 'NAVIGATION_SET_TITLE';
export const NAVIGATION_HOME = 'NAVIGATION_HOME';
export const NAVIGATION_LOGIN = 'NAVIGATION_LOGIN';

export const ACCOUNT_NOTIFICATIONS_LIMIT = 30;
export const ACCOUNT_NOTIFICATIONS_LIMIT = 50;
export const ACCOUNT_ISSUES_LIMIT = 30;
export const ACCOUNT_FEED_LIMIT = 30;
export const ACCOUNT_PULL_REQUESTS_LIMIT = 30;
3 changes: 3 additions & 0 deletions reducers/account-notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import {
export type AccountNotificationsState = {
// first list fetch
loading: boolean,
page: number,
sync: boolean,
error: Object|string|null,
}

const initialState: AccountNotificationsState = {
loading: false,
page: 0,
error: null,
};

Expand All @@ -32,6 +34,7 @@ export default (state: AccountNotificationsState = initialState, action: Object)
case ACCOUNT_NOTIFICATIONS_SYNC_PROGRESS: {
return {
...state,
page: action.payload,
sync: true,
loading: false,
};
Expand Down

0 comments on commit 7ed3b37

Please sign in to comment.