Skip to content

Fixes storage not persist after reset #6285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions components/brave_rewards/resources/page/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ const mergeReducers = (state: Rewards.State | undefined, action: any) => {

if (!state) {
state = storage.defaultState
storage.save(state)
} else if (state !== startingState) {
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is where the problem was as we used save directly and then debounced save came after that and override it. So now we use debounce for this one as well


if (state !== startingState) {
storage.debouncedSave(state)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ const updatePromotion = (newPromotion: Rewards.Promotion, promotions: Rewards.Pr
}

const promotionReducer: Reducer<Rewards.State | undefined> = (state: Rewards.State, action) => {
if (!state) {
return
}

const payload = action.payload
switch (action.type) {
case types.FETCH_PROMOTIONS: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import { Reducer } from 'redux'
import { types } from '../constants/rewards_types'

const publishersReducer: Reducer<Rewards.State | undefined> = (state: Rewards.State, action) => {
if (!state) {
return
}

switch (action.type) {
case types.ON_CONTRIBUTE_LIST:
state = { ...state }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import { types } from '../constants/rewards_types'
import { defaultState } from '../storage'

const rewardsReducer: Reducer<Rewards.State | undefined> = (state: Rewards.State, action) => {
if (!state) {
return
}

switch (action.type) {
case types.TOGGLE_ENABLE_MAIN: {
if (state.initializing) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ const createWallet = (state: Rewards.State) => {
}

const walletReducer: Reducer<Rewards.State | undefined> = (state: Rewards.State, action) => {
if (!state) {
return
}

switch (action.type) {
case types.CREATE_WALLET:
state = { ...state }
Expand Down