Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
notifications: (state = { results: [], refreshing: false }, action) => {
switch (action.type) {
case getType(actions.refreshNotificationsStart):
return { ...state, refreshing: true }
case getType(actions.refreshNotificationsSuccess): {
// Add it to our list for display
const { results } = action.payload
return { ...state, results, refreshing: false }
}
case getType(actions.refreshNotificationsFailure):
return { ...state, refreshing: false }
case getType(actions.newNotificationRequest): {
// Useful so that new notifications you receive while staring at the Feed will just pop in
const results = state.results.slice(0, 99)
results.unshift(action.payload.notification)
return { ...state, results }
}
default:
return state
}
},
...state,
error: undefined,
readme: undefined,
readmeError: undefined,
values: undefined,
version: action.payload,
};
case getType(actions.charts.receiveChartVersions):
return {
...state,
error: undefined,
versions: action.payload,
};
case getType(actions.charts.selectReadme):
return { ...state, readme: action.payload, readmeError: undefined };
case getType(actions.charts.errorChart):
return { ...state, error: action.payload };
case getType(actions.charts.errorReadme):
return { ...state, readmeError: action.payload };
case getType(actions.charts.selectValues):
return { ...state, values: action.payload };
case getType(actions.charts.resetChartVersion):
return initialState.selected;
default:
}
return state;
};
export default function(state: State, action: Action): State {
switch (action.type) {
case getType(actions.sampleAction):
return state;
default:
return state;
}
}
const reposReducer = (
state: IAppRepositoryState = initialState,
action: AppReposAction | LocationChangeAction,
): IAppRepositoryState => {
switch (action.type) {
case getType(actions.repos.receiveRepos):
return { ...state, isFetching: false, repos: action.payload, errors: {} };
case getType(actions.repos.receiveRepo):
return { ...state, isFetching: false, repo: action.payload, errors: {} };
case getType(actions.repos.requestRepos):
return { ...state, isFetching: true };
case getType(actions.repos.addRepo):
return { ...state, addingRepo: true };
case getType(actions.repos.addedRepo):
return {
...state,
addingRepo: false,
lastAdded: action.payload,
repos: [...state.repos, action.payload],
};
case getType(actions.repos.resetForm):
return { ...state, form: { ...state.form, name: "", namespace: "", url: "" } };
case getType(actions.repos.showForm):
return { ...state, form: { ...state.form, show: true } };
case getType(actions.repos.hideForm):
return { ...state, form: { ...state.form, show: false } };
case getType(actions.repos.redirect):
return { ...state, redirectTo: action.payload };
function* monitorSharedPhotos(addTaskChannel: Channel<{}>) {
while (true) {
const action: ActionType = yield take(
getType(actions.sharePhotoRequest)
)
const { sharedImage, destinationThreadId, comment } = action.payload
yield fork(
handleSharedPhoto,
addTaskChannel,
sharedImage,
destinationThreadId,
comment
)
}
}
const reducer: Reducer> = (
state = initialState,
action,
): UsersState => {
switch (action.type) {
case getType(actions.beginFetchCurrentUser):
return {
...state,
currentUser: undefined,
};
case getType(actions.abortFetchCurrentUser):
return {
...state,
currentUser: initialState.currentUser,
};
case getType(actions.loadCurrentUser):
return {
...state,
currentUser: createInternalUser(action.payload.user),
};
case getType(actions.logOut):
return {
...state,
currentUser: null,
};
default:
return state;
remainingUploadAttempts: attempts
}
}
}
}
case getType(actions.imageUploadProgress): {
const { dataId, progress } = action.payload
const image = state.images[dataId]
const updated: UploadingImage = {
...image,
state: 'uploading',
uploadProgress: progress / 100
}
return { ...state, images: { ...state.images, [dataId]: updated } }
}
case getType(actions.imageUploadComplete): {
const { dataId, responseCode, responseBody } = action.payload
const image = state.images[dataId]
const updated: UploadingImage = {
...image,
state: 'complete',
responseCode,
responseBody
}
return { ...state, images: { ...state.images, [dataId]: updated } }
}
case getType(actions.imageUploadError): {
const { dataId, errorMessage } = action.payload
const image = state.images[dataId]
const updated: UploadingImage = {
...image,
state: 'error',
const fileHandler: Middleware<{}, RootState> = store => next => action => {
switch (action.type) {
case getType(subtitleActions.newData):
case getType(subtitleActions.loadData):
store.dispatch(welcomeActions.setSubtitleReady(true));
return next(action);
case getType(playerActions.loadVideo):
store.dispatch(welcomeActions.setVideoReady(true));
return next(action);
case getType(subtitleActions.saveData):
const { filepath, data } = action.payload;
ipcRenderer.send('request-save-subtitle', filepath, data);
return next(action);
default:
return next(action);
}
};
case getType(actions.refreshPeerIdSuccess):
const { peerId } = action.payload
return { ...state, peerId: { value: peerId } }
case getType(actions.refreshPeerIdError): {
const obj = action.payload.error
const error = obj.message as string || obj as string || 'unknown error'
return { ...state, peerId: { ...state.peerId, error } }
}
case getType(actions.setAvatarError): {
const obj = action.payload.error
const error = obj.message as string || obj as string || 'unknown error'
return { ...state, avatar: { ...state.avatar, error } }
}
case getType(actions.setPendingAvatar):
return { ...state, avatar: { ...state.avatar, pending: action.payload.avatar } }
case getType(actions.setRecoveryPhrase):
return { ...state, recoveryPhrase: action.payload.recoveryPhrase }
case getType(actions.getCafeSessionsRequest):
case getType(actions.refreshCafeSessionsRequest):
return { ...state, cafeSessions: { ...state.cafeSessions, processing: true, error: undefined } }
case getType(actions.cafeSessionsSuccess):
return { ...state, cafeSessions: { sessions: action.payload.sessions , processing: false, error: undefined } }
case getType(actions.cafeSessionsError):
const obj = action.payload.error
const error = obj.message as string || obj as string || 'unknown error'
return { ...state, cafeSessions: { ...state.cafeSessions, processing: false, error } }
default:
return state
}
}
addressBookSearchResults: (state = { processing: false }, action) => {
switch (action.type) {
case getType(actions.searchRequest): {
return {
processing: false
}
}
case getType(actions.searchStarted): {
return {
processing: true
}
}
case getType(actions.searchResultsAddressBook): {
return {
processing: false,
results: action.payload.results
}
}
case getType(actions.searchErrorAddressBook): {
const { error } = action.payload
const message = error.message as string || error as string || 'unknown'
return {
processing: false,
error: message
}
}
case getType(actions.clearSearch): {
return {
processing: false