Persist various things in localstorage.

This commit is contained in:
Håvar Aambø Fosstveit
2019-04-05 21:47:16 +02:00
parent e5026284fa
commit 67b3427485
17 changed files with 127 additions and 278 deletions
-59
View File
@@ -1,8 +1,6 @@
const initialState =
{
name : null,
displayName : null,
displayNameSet : false,
device : null,
canSendMic : false,
canSendWebcam : false,
@@ -14,14 +12,8 @@ const initialState =
audioInProgress : false,
screenShareInProgress : false,
loginEnabled : false,
audioOnly : false,
audioOnlyInProgress : false,
raiseHand : false,
raiseHandInProgress : false,
restartIceInProgress : false,
picture : null,
selectedWebcam : null,
selectedAudioDevice : null,
loggedIn : false
};
@@ -33,8 +25,6 @@ const me = (state = initialState, action) =>
{
const {
peerName,
displayName,
displayNameSet,
device,
loginEnabled
} = action.payload;
@@ -42,8 +32,6 @@ const me = (state = initialState, action) =>
return {
...state,
name : peerName,
displayName,
displayNameSet,
device,
loginEnabled
};
@@ -55,16 +43,6 @@ const me = (state = initialState, action) =>
case 'USER_LOGOUT':
return { ...state, loggedIn: false };
case 'CHANGE_WEBCAM':
{
return { ...state, selectedWebcam: action.payload.deviceId };
}
case 'CHANGE_AUDIO_DEVICE':
{
return { ...state, selectedAudioDevice: action.payload.deviceId };
}
case 'SET_MEDIA_CAPABILITIES':
{
const { canSendMic, canSendWebcam } = action.payload;
@@ -114,31 +92,6 @@ const me = (state = initialState, action) =>
return { ...state, screenShareInProgress: flag };
}
case 'SET_DISPLAY_NAME':
{
let { displayName } = action.payload;
// Be ready for undefined displayName (so keep previous one).
if (!displayName)
displayName = state.displayName;
return { ...state, displayName, displayNameSet: true };
}
case 'SET_AUDIO_ONLY_STATE':
{
const { enabled } = action.payload;
return { ...state, audioOnly: enabled };
}
case 'SET_AUDIO_ONLY_IN_PROGRESS':
{
const { flag } = action.payload;
return { ...state, audioOnlyInProgress: flag };
}
case 'SET_MY_RAISE_HAND_STATE':
{
const { flag } = action.payload;
@@ -153,18 +106,6 @@ const me = (state = initialState, action) =>
return { ...state, raiseHandInProgress: flag };
}
case 'SET_RESTART_ICE_IN_PROGRESS':
{
const { flag } = action.payload;
return { ...state, restartIceInProgress: flag };
}
case 'SET_PICTURE':
{
return { ...state, picture: action.payload.picture };
}
default:
return state;
}
-8
View File
@@ -8,7 +8,6 @@ const initialState =
activeSpeakerName : null,
torrentSupport : false,
showSettings : false,
advancedMode : false,
fullScreenConsumer : null, // ConsumerID
windowConsumer : null, // ConsumerID
toolbarsVisible : true,
@@ -89,13 +88,6 @@ const room = (state = initialState, action) =>
return { ...state, showSettings };
}
case 'TOGGLE_ADVANCED_MODE':
{
const advancedMode = !state.advancedMode;
return { ...state, advancedMode };
}
case 'TOGGLE_FULLSCREEN_CONSUMER':
{
const { consumerId } = action.payload;
+3 -1
View File
@@ -9,6 +9,7 @@ import notifications from './notifications';
import chatmessages from './chatmessages';
import toolarea from './toolarea';
import files from './files';
import settings from './settings';
export default combineReducers({
room,
@@ -20,5 +21,6 @@ export default combineReducers({
notifications,
chatmessages,
toolarea,
files
files,
settings
});
+52
View File
@@ -0,0 +1,52 @@
const initialState =
{
displayName : 'Guest',
picture : null,
selectedWebcam : null,
selectedAudioDevice : null,
advancedMode : false
};
const settings = (state = initialState, action) =>
{
switch (action.type)
{
case 'CHANGE_WEBCAM':
{
return { ...state, selectedWebcam: action.payload.deviceId };
}
case 'CHANGE_AUDIO_DEVICE':
{
return { ...state, selectedAudioDevice: action.payload.deviceId };
}
case 'SET_DISPLAY_NAME':
{
let { displayName } = action.payload;
// Be ready for undefined displayName (so keep previous one).
if (!displayName)
displayName = state.displayName;
return { ...state, displayName };
}
case 'SET_PICTURE':
{
return { ...state, picture: action.payload.picture };
}
case 'TOGGLE_ADVANCED_MODE':
{
const advancedMode = !state.advancedMode;
return { ...state, advancedMode };
}
default:
return state;
}
};
export default settings;