This commit is contained in:
Oleg Silkin 2020-01-13 16:55:28 -05:00
parent 13cd56dabc
commit c0db949a53
7 changed files with 53 additions and 38 deletions

View file

@ -1,7 +1,8 @@
// @flow
import * as ACTIONS from 'constants/action_types'; import * as ACTIONS from 'constants/action_types';
export function savePosition(claimId: string, outpoint: string, position: number) { export function savePosition(claimId: string, outpoint: string, position: number) {
return dispatch => { return (dispatch: Dispatch) => {
dispatch({ dispatch({
type: ACTIONS.SET_CONTENT_POSITION, type: ACTIONS.SET_CONTENT_POSITION,
data: { claimId, outpoint, position }, data: { claimId, outpoint, position },

View file

@ -30,7 +30,10 @@ function extractUserState(rawObj: SharedData) {
export function doPopulateSharedUserState(sharedSettings: any) { export function doPopulateSharedUserState(sharedSettings: any) {
return (dispatch: Dispatch) => { return (dispatch: Dispatch) => {
const { subscriptions, tags, blocked, settings } = extractUserState(sharedSettings); const { subscriptions, tags, blocked, settings } = extractUserState(sharedSettings);
dispatch({ type: ACTIONS.USER_STATE_POPULATE, data: { subscriptions, tags, blocked, settings } }); dispatch({
type: ACTIONS.USER_STATE_POPULATE,
data: { subscriptions, tags, blocked, settings },
});
}; };
} }

View file

@ -33,8 +33,7 @@ export const blockedReducer = handleActions(
const { blocked } = action.data; const { blocked } = action.data;
return { return {
...state, ...state,
blockedChannels: blockedChannels: blocked && blocked.length ? blocked : state.blockedChannels,
blocked && blocked.length ? blocked : state.blockedChannels,
}; };
}, },
}, },

View file

@ -265,7 +265,8 @@ reducers[ACTIONS.FETCH_CHANNEL_CLAIMS_COMPLETED] = (state: State, action: any):
const paginatedClaimsByChannel = Object.assign({}, state.paginatedClaimsByChannel); const paginatedClaimsByChannel = Object.assign({}, state.paginatedClaimsByChannel);
// check if count has changed - that means cached pagination will be wrong, so clear it // check if count has changed - that means cached pagination will be wrong, so clear it
const previousCount = paginatedClaimsByChannel[uri] && paginatedClaimsByChannel[uri]['itemCount']; const previousCount = paginatedClaimsByChannel[uri] && paginatedClaimsByChannel[uri]['itemCount'];
const byChannel = (claimsInChannel === previousCount) ? Object.assign({}, paginatedClaimsByChannel[uri]) : {}; const byChannel =
claimsInChannel === previousCount ? Object.assign({}, paginatedClaimsByChannel[uri]) : {};
const allClaimIds = new Set(byChannel.all); const allClaimIds = new Set(byChannel.all);
const currentPageClaimIds = []; const currentPageClaimIds = [];
const byId = Object.assign({}, state.byId); const byId = Object.assign({}, state.byId);

View file

@ -1,14 +1,19 @@
// @flow
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { makeSelectClaimForUri } from 'redux/selectors/claims'; import { makeSelectClaimForUri } from 'redux/selectors/claims';
export const selectState = (state: any) => state.content || {}; export const selectState = (state: any) => state.content || {};
export const makeSelectContentPositionForUri = (uri: string) => export const makeSelectContentPositionForUri = (uri: string) =>
createSelector(selectState, makeSelectClaimForUri(uri), (state, claim) => { createSelector(
selectState,
makeSelectClaimForUri(uri),
(state, claim) => {
if (!claim) { if (!claim) {
return null; return null;
} }
const outpoint = `${claim.txid}:${claim.nout}`; const outpoint = `${claim.txid}:${claim.nout}`;
const id = claim.claim_id; const id = claim.claim_id;
return state.positions[id] ? state.positions[id][outpoint] : null; return state.positions[id] ? state.positions[id][outpoint] : null;
}); }
);

View file

@ -1,8 +1,10 @@
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
export const selectState = (state) => state.notifications || {}; export const selectState = state => state.notifications || {};
export const selectToast = createSelector(selectState, (state) => { export const selectToast = createSelector(
selectState,
state => {
if (state.toasts.length) { if (state.toasts.length) {
const { id, params } = state.toasts[0]; const { id, params } = state.toasts[0];
return { return {
@ -12,9 +14,12 @@ export const selectToast = createSelector(selectState, (state) => {
} }
return null; return null;
}); }
);
export const selectError = createSelector(selectState, (state) => { export const selectError = createSelector(
selectState,
state => {
if (state.errors.length) { if (state.errors.length) {
const { error } = state.errors[0]; const { error } = state.errors[0];
return { return {
@ -23,4 +28,5 @@ export const selectError = createSelector(selectState, (state) => {
} }
return null; return null;
}); }
);