Port to Redux and add settings
This commit is contained in:
4
src/store/settings/actions.ts
Normal file
4
src/store/settings/actions.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { createAction } from '@reduxjs/toolkit';
|
||||
|
||||
export const setJellyfinCredentials = createAction<{ access_token: string, user_id: string, uri: string, deviced_id: string; }>('SET_JELLYFIN_CREDENTIALS');
|
||||
export const setBitrate = createAction<number>('SET_BITRATE');
|
||||
29
src/store/settings/index.ts
Normal file
29
src/store/settings/index.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { setBitrate, setJellyfinCredentials } from './actions';
|
||||
|
||||
interface State {
|
||||
jellyfin?: {
|
||||
uri: string;
|
||||
user_id: string;
|
||||
access_token: string;
|
||||
device_id: string;
|
||||
}
|
||||
bitrate: number;
|
||||
}
|
||||
|
||||
const initialState: State = {
|
||||
bitrate: 140000000
|
||||
};
|
||||
|
||||
const settings = createReducer(initialState, {
|
||||
[setJellyfinCredentials.type]: (state, action) => ({
|
||||
...state,
|
||||
jellyfin: action.payload,
|
||||
}),
|
||||
[setBitrate.type]: (state, action) => ({
|
||||
...state,
|
||||
bitrate: action.payload,
|
||||
}),
|
||||
});
|
||||
|
||||
export default settings;
|
||||
Reference in New Issue
Block a user