maintenance

This commit is contained in:
2025-09-04 20:25:15 -04:00
parent 1469c7f52f
commit e8f2df9e69
214 changed files with 8507 additions and 1836 deletions

View File

@@ -2,6 +2,8 @@ import {createSlice, PayloadAction, createAsyncThunk, createSelector} from '@red
import AuthenticationService from '../../services/Authentication.service';
import {PhenixWebSocketStatusType} from 'services/net/websockets/PhenixWebSocketStatus';
import {IPhenixWebSocketResponse} from 'services/net/websockets/PhenixWebSocket';
import PCastApiService from 'services/PCastApi.service';
import ChannelService from 'services/Channel.service';
export interface IAuthenticationState {
applicationId: string | null;
@@ -137,6 +139,12 @@ const authenticationSlice = createSlice({
state.roles = authenticationResponse.roles ?? [];
state.status = 'Online';
state.isLoading = false;
PCastApiService.initialize('https://pcast-stg.phenixrts.com', {
id: state.applicationId ?? 'phenixrts.com-alex.zinn',
secret: state.secret ?? ''
});
ChannelService.initializeWithPCastApi(PCastApiService.channels);
} else {
state.applicationId = null;
state.sessionId = null;

View File

@@ -1,6 +1,7 @@
import {createAsyncThunk, createSelector, createSlice, PayloadAction, WritableDraft} from '@reduxjs/toolkit';
import {ApplicationCredentials, Channel} from '@techniker-me/pcast-api';
import PCastApiService from 'services/PCastApi.service';
import {listChannels, createChannelThunk, deleteChannelThunk, getChannelThunk, getPublisherCountThunk} from '../action/channels';
export interface IChannelsState {
isLoading: boolean;
@@ -23,6 +24,7 @@ export const selectChannelList = createSelector([selectChannels], channels => ch
export const fetchChannelList = createAsyncThunk('channels/fetchChannelList', async (_, {rejectWithValue}) => {
try {
return PCastApiService.channels.list();
} catch (error) {
return rejectWithValue(error);
}
@@ -72,30 +74,110 @@ const channelsSlice = createSlice({
}
},
extraReducers: builder => {
builder.addCase(fetchChannelList.pending, state => {
state.isLoading = true;
});
builder.addCase(fetchChannelList.fulfilled, (state, action) => {
state.channels = action.payload as WritableDraft<Channel[]>;
state.isLoading = false;
state.error = null;
});
builder.addCase(fetchChannelList.rejected, (state, action) => {
state.isLoading = false;
state.error = action.payload as string;
});
builder.addCase(fetchChannelsListPublisherStatus.pending, state => {
state.isLoading = true;
});
builder.addCase(fetchChannelsListPublisherStatus.fulfilled, (state, action) => {
state.channels = action.payload as WritableDraft<Channel[]>;
state.isLoading = false;
state.error = null;
});
builder.addCase(fetchChannelsListPublisherStatus.rejected, (state, action) => {
state.isLoading = false;
state.error = action.payload as string;
});
builder
// fetchChannelList cases
.addCase(fetchChannelList.pending, state => {
state.isLoading = true;
state.error = null;
})
.addCase(fetchChannelList.fulfilled, (state, action) => {
state.channels = action.payload as WritableDraft<Channel[]>;
state.isLoading = false;
state.error = null;
})
.addCase(fetchChannelList.rejected, (state, action) => {
state.isLoading = false;
state.error = action.payload as string;
})
// fetchChannelsListPublisherStatus cases
.addCase(fetchChannelsListPublisherStatus.pending, state => {
state.isLoading = true;
state.error = null;
})
.addCase(fetchChannelsListPublisherStatus.fulfilled, (state, action) => {
state.channels = action.payload as WritableDraft<Channel[]>;
state.isLoading = false;
state.error = null;
})
.addCase(fetchChannelsListPublisherStatus.rejected, (state, action) => {
state.isLoading = false;
state.error = action.payload as string;
})
// listChannels cases (used by the component)
.addCase(listChannels.pending, state => {
state.isLoading = true;
state.error = null;
})
.addCase(listChannels.fulfilled, (state, action) => {
state.channels = action.payload as WritableDraft<Channel[]>;
state.isLoading = false;
state.error = null;
})
.addCase(listChannels.rejected, (state, action) => {
state.isLoading = false;
state.error = action.payload as string;
})
// createChannelThunk cases
.addCase(createChannelThunk.pending, state => {
state.isLoading = true;
state.error = null;
})
.addCase(createChannelThunk.fulfilled, (state, _action) => {
// Channel is already added to the list by the thunk calling listChannels
state.isLoading = false;
state.error = null;
})
.addCase(createChannelThunk.rejected, (state, action) => {
state.isLoading = false;
state.error = action.payload as string;
})
// deleteChannelThunk cases
.addCase(deleteChannelThunk.pending, state => {
state.isLoading = true;
state.error = null;
})
.addCase(deleteChannelThunk.fulfilled, (state, _action) => {
// Channel is already removed from the list by the thunk calling listChannels
state.isLoading = false;
state.error = null;
})
.addCase(deleteChannelThunk.rejected, (state, action) => {
state.isLoading = false;
state.error = action.payload as string;
})
// getChannelThunk cases
.addCase(getChannelThunk.pending, state => {
state.isLoading = true;
state.error = null;
})
.addCase(getChannelThunk.fulfilled, (state, action) => {
state.selectedChannel = action.payload as WritableDraft<Channel>;
state.isLoading = false;
state.error = null;
})
.addCase(getChannelThunk.rejected, (state, action) => {
state.isLoading = false;
state.error = action.payload as string;
})
// getPublisherCountThunk cases
.addCase(getPublisherCountThunk.pending, state => {
state.isLoading = true;
state.error = null;
})
.addCase(getPublisherCountThunk.fulfilled, (state, action) => {
// Update the specific channel with publisher count
const {channelId, count} = action.payload;
const channelIndex = state.channels.findIndex(channel => channel.channelId === channelId);
if (channelIndex !== -1) {
(state.channels[channelIndex] as any).publisherCount = count;
}
state.isLoading = false;
state.error = null;
})
.addCase(getPublisherCountThunk.rejected, (state, action) => {
state.isLoading = false;
state.error = action.payload as string;
});
}
});