Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Decides whether or not to show the Congrats message
// Set to true after all stages are done
congratsMessage: boolean
}
const defState = {
annotationStage: '',
powerSearchStage: '',
taggingStage: '',
backupStage: '',
showOnboardingBox: false,
congratsMessage: false,
}
const reducer = createReducer({}, defState)
reducer.on(actions.setAnnotationStage, (state, payload) => ({
...state,
annotationStage: payload,
}))
reducer.on(actions.setPowerSearchStage, (state, payload) => ({
...state,
powerSearchStage: payload,
}))
reducer.on(actions.setTaggingStage, (state, payload) => ({
...state,
taggingStage: payload,
}))
: [...state.results, ...payload.docs]
const annotsByDay =
payload.annotsByDay && overwrite
? payload.annotsByDay
: { ...state.annotsByDay, ...payload.annotsByDay }
return {
...state,
...commonState,
results,
annotsByDay,
}
}
const reducer = createReducer({}, defState)
reducer.on(acts.setShowOnboardingMessage, (state, showOnboardingMessage) => ({
...state,
showOnboardingMessage,
}))
reducer.on(acts.addTag, (state, { tag, index }) => {
const doc = state.results[index]
return {
...state,
results: [
...state.results.slice(0, index),
{
...doc,
tags: [...doc.tags, tag],
}
const initialState: ContactsState = {
groupClaimsBy: null,
roomForSharing: null,
editing: null,
newClaimType: null,
newClaimValue: null,
selectedContact: null,
list: Config.contacts.defaultList,
claims: Config.contacts.defaultClaimsList,
matrixClaims: [],
hiddenDataSources: [],
}
export const reducer = createReducer({}, initialState)
reducer.on(resetToInitialState, (state: ContactsState) => {
return initialState
})
export const toggleHiddenDataSource = createAction('Toggle hidden datasource')
reducer.on(toggleHiddenDataSource, (state: ContactsState, payload?: DataSource) => {
let currentHiddenDataSources = [...state.hiddenDataSources]
if (find(currentHiddenDataSources, payload)) {
remove(currentHiddenDataSources, (source: DataSource) => {
return source.type === payload.type && source.id === payload.id
})
} else {
currentHiddenDataSources.push(payload)
}
return {
...state,
const emptyBurnTransaction: BurnTransaction = {
numTokens: '0',
reward: '0',
}
const initialState: TokensState = {
current: Config.tokens.defaultList[0].address,
mintTransaction: emptyMintTransaction,
burnTransaction: emptyBurnTransaction,
new: null,
list: Config.tokens.defaultList,
available: [],
}
export const reducer = createReducer({}, initialState)
reducer.on(resetToInitialState, (state: TokensState) => {
return initialState
})
export const addToken = createAction('Add token')
reducer.on(addToken, (state: TokensState, payload?: Token) => {
return {
...state,
list: uniqBy([ ...state.list, payload ], (token: Token) => token.address),
}
})
export const selectToken = createAction('Select token')
reducer.on(selectToken, (state: TokensState, payload?: string) => {
return {
...state,
import {combineReducers} from 'redux';
import {createReducer} from 'redux-act';
import {IndexedTracks} from 'models';
import {actions} from './player.actions';
export const initialState = {
list: null as IndexedTracks,
isPlaying: false,
currentTime: null as number,
duration: null as number,
currentId: null as string,
};
const currentId = createReducer({}, initialState.currentId).on(
actions.playMusic,
(_state, payload) => payload,
);
const isPlaying = createReducer({}, initialState.isPlaying)
.on(actions.playMusic, () => true)
.on(actions.toggle, (state) => !state);
const currentTime = createReducer({}, initialState.currentTime).on(
actions.updateTime,
(_state, {currentTime}) => currentTime,
);
const duration = createReducer({}, initialState.duration)
.on(actions.updateTime, (_state, {duration}) => duration)
.on(actions.playMusic, () => null);
get reducer() {
return createReducer({
[this.createForm]: this.createFormHandle.bind(this),
[this.updateItemData]: this.updateItemDataHandle.bind(this),
[this.updateItemMeta]: this.updateItemMetaHandle.bind(this),
[this.addItem]: this.addItemDataHandle.bind(this),
[this.removeItem]: this.removeItemHandle.bind(this),
[this.moveToItem]: this.moveItemHandle.bind(this),
[this.removeItemData]: this.removeItemDataMetaHandle.bind(this),
[this.combineActions]: this.combineActionsHandle.bind(this),
[this.removeForm]: this.removeFormHandle.bind(this),
[this.removeMetaKeys]: this.removeMetaKeysHandle.bind(this),
}, this.initialState);
}
removeFormHandle(state, parentKeys) {
get reducer() {
return createReducer({
[this.updateItem]: this.updateItemHandle.bind(this),
[this.toggleItem]: this.toggleItemHandle.bind(this),
[this.addItem]: this.addItemHandle.bind(this),
[this.removeItem]: this.removeItemHandle.bind(this),
[this.switchItem]: this.switchItemHandle.bind(this),
[this.updateMetaState]: this.updateMetaStateHandle.bind(this),
[this.updateItemMeta]: this.updateMetaHandle.bind(this),
[this.updateData]: this.updateDataHandle.bind(this),
[this.removeItemMap]: this.removeItemMapHandle.bind(this)
}, this.initialState);
}
updateDataHandle(state, data) {
get reducer() {
return createReducer({
[this.createForm]: this.createFormHandle.bind(this),
[this.updateItemData]: this.updateItemDataHandle.bind(this),
[this.updateItemMeta]: this.updateItemMetaHandle.bind(this),
[this.addItem]: this.addItemDataHandle.bind(this),
[this.removeItem]: this.removeItemDataHandle.bind(this),
[this.switchItem]: this.switchItemHandle.bind(this),
[this.moveToItem]: this.moveItemHandle.bind(this),
}, this.initialState);
}
resolveKeys(state, keys) {
get reducer() {
return createReducer({
[this.createForm]: this.createFormHandle.bind(this),
[this.updateItemData]: this.updateItemDataHandle.bind(this),
[this.updateItemMeta]: this.updateItemMetaHandle.bind(this),
[this.addItem]: this.addItemDataHandle.bind(this),
[this.removeItem]: this.removeItemDataHandle.bind(this),
[this.switchItem]: this.switchItemHandle.bind(this),
[this.moveToItem]: this.moveItemHandle.bind(this),
}, this.initialState);
}
resolveKeys(state, keys) {