Port to Redux and add settings

This commit is contained in:
Lei Nelissen
2020-06-17 14:58:04 +02:00
parent cffc7567c1
commit 2369ef68ae
22 changed files with 730 additions and 158 deletions

View 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');

View 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;