format
This commit is contained in:
@@ -30,8 +30,7 @@ const initialState: ChannelsPublishingState = {
|
||||
};
|
||||
|
||||
// Selectors
|
||||
export const channelsPublishingSelector = (state: RootState): ChannelsPublishingState =>
|
||||
state.channelsPublishing;
|
||||
export const channelsPublishingSelector = (state: RootState): ChannelsPublishingState => state.channelsPublishing;
|
||||
|
||||
export const selectChannelsPublishingState = createSelector(
|
||||
[channelsPublishingSelector],
|
||||
@@ -45,8 +44,7 @@ export const selectChannelsPublishingLoading = createSelector(
|
||||
|
||||
export const selectChannelPublishingState = createSelector(
|
||||
[selectChannelsPublishingState, (_: RootState, channelId: string) => channelId],
|
||||
(publishingStates: ChannelPublishingState[], channelId: string) =>
|
||||
publishingStates.find(state => state.channelId === channelId)
|
||||
(publishingStates: ChannelPublishingState[], channelId: string) => publishingStates.find(state => state.channelId === channelId)
|
||||
);
|
||||
|
||||
// Async thunks
|
||||
@@ -108,7 +106,7 @@ const channelsPublishingSlice = createSlice({
|
||||
name: 'channelsPublishing',
|
||||
initialState,
|
||||
reducers: {
|
||||
clearPublishingState: (state) => {
|
||||
clearPublishingState: state => {
|
||||
state.publishingState = [];
|
||||
state.error = null;
|
||||
},
|
||||
@@ -116,10 +114,8 @@ const channelsPublishingSlice = createSlice({
|
||||
state.error = action.payload;
|
||||
},
|
||||
updateChannelState: (state, action: PayloadAction<ChannelPublishingState>) => {
|
||||
const index = state.publishingState.findIndex(
|
||||
item => item.channelId === action.payload.channelId
|
||||
);
|
||||
|
||||
const index = state.publishingState.findIndex(item => item.channelId === action.payload.channelId);
|
||||
|
||||
if (index >= 0) {
|
||||
state.publishingState[index] = action.payload;
|
||||
} else {
|
||||
@@ -127,9 +123,9 @@ const channelsPublishingSlice = createSlice({
|
||||
}
|
||||
}
|
||||
},
|
||||
extraReducers: (builder) => {
|
||||
extraReducers: builder => {
|
||||
builder
|
||||
.addCase(fetchChannelsPublishingState.pending, (state) => {
|
||||
.addCase(fetchChannelsPublishingState.pending, state => {
|
||||
state.isLoading = true;
|
||||
state.error = null;
|
||||
})
|
||||
@@ -144,10 +140,8 @@ const channelsPublishingSlice = createSlice({
|
||||
state.error = action.payload as string;
|
||||
})
|
||||
.addCase(updateChannelPublishingState.fulfilled, (state, action) => {
|
||||
const index = state.publishingState.findIndex(
|
||||
item => item.channelId === action.payload.channelId
|
||||
);
|
||||
|
||||
const index = state.publishingState.findIndex(item => item.channelId === action.payload.channelId);
|
||||
|
||||
if (index >= 0) {
|
||||
state.publishingState[index] = action.payload;
|
||||
} else {
|
||||
@@ -161,4 +155,4 @@ const channelsPublishingSlice = createSlice({
|
||||
});
|
||||
|
||||
export const {clearPublishingState, setPublishingError, updateChannelState} = channelsPublishingSlice.actions;
|
||||
export default channelsPublishingSlice.reducer;
|
||||
export default channelsPublishingSlice.reducer;
|
||||
|
||||
Reference in New Issue
Block a user