Changeset View
Changeset View
Standalone View
Standalone View
lib/reducers/draft-reducer.js
// @flow | // @flow | ||||
import { setClientDBStoreActionType } from '../actions/client-db-store-actions'; | |||||
import { | import { | ||||
moveDraftActionType, | moveDraftActionType, | ||||
setDraftStoreDrafts, | |||||
updateDraftActionType, | updateDraftActionType, | ||||
} from '../actions/draft-actions'; | } from '../actions/draft-actions'; | ||||
import { | import { | ||||
deleteAccountActionTypes, | deleteAccountActionTypes, | ||||
logOutActionTypes, | logOutActionTypes, | ||||
} from '../actions/user-actions'; | } from '../actions/user-actions'; | ||||
import type { DraftStore, DraftStoreOperation } from '../types/draft-types'; | import type { DraftStore, DraftStoreOperation } from '../types/draft-types'; | ||||
import type { BaseAction } from '../types/redux-types'; | import type { BaseAction } from '../types/redux-types'; | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | return { | ||||
draftStore: { | draftStore: { | ||||
...draftStore, | ...draftStore, | ||||
drafts: { | drafts: { | ||||
...draftsWithoutOldKey, | ...draftsWithoutOldKey, | ||||
[newKey]: text, | [newKey]: text, | ||||
}, | }, | ||||
}, | }, | ||||
}; | }; | ||||
} else if (action.type === setDraftStoreDrafts) { | } else if (action.type === setClientDBStoreActionType) { | ||||
const drafts = {}; | const drafts = {}; | ||||
for (const dbDraftInfo of action.payload) { | for (const dbDraftInfo of action.payload.drafts) { | ||||
drafts[dbDraftInfo.key] = dbDraftInfo.text; | drafts[dbDraftInfo.key] = dbDraftInfo.text; | ||||
} | } | ||||
return { | return { | ||||
draftStoreOperations: [], | draftStoreOperations: [], | ||||
draftStore: { | draftStore: { | ||||
...draftStore, | ...draftStore, | ||||
drafts: drafts, | drafts: drafts, | ||||
}, | }, | ||||
}; | }; | ||||
} | } | ||||
return { draftStore, draftStoreOperations: [] }; | return { draftStore, draftStoreOperations: [] }; | ||||
} | } | ||||
export { reduceDraftStore }; | export { reduceDraftStore }; |