2018-04-05 19:13:32 +00:00
|
|
|
import createReducer from 'utils/createReducer';
|
2017-06-06 23:03:35 +00:00
|
|
|
import * as actions from './actions';
|
|
|
|
|
|
|
|
export const getApp = state => state.app;
|
|
|
|
export const getConnected = state => state.app.connected;
|
|
|
|
export const getWrapWidth = state => state.app.wrapWidth;
|
|
|
|
export const getCharWidth = state => state.app.charWidth;
|
|
|
|
export const getWindowWidth = state => state.app.windowWidth;
|
|
|
|
export const getConnectDefaults = state => state.app.connectDefaults;
|
|
|
|
|
2018-04-25 03:36:27 +00:00
|
|
|
const initialState = {
|
2020-05-03 07:05:16 +00:00
|
|
|
connected: false,
|
2017-06-06 23:03:35 +00:00
|
|
|
wrapWidth: 0,
|
|
|
|
charWidth: 0,
|
|
|
|
windowWidth: 0,
|
2018-04-25 03:36:27 +00:00
|
|
|
connectDefaults: {
|
|
|
|
name: '',
|
2020-05-08 08:12:21 +00:00
|
|
|
host: '',
|
|
|
|
port: '',
|
2018-04-25 03:36:27 +00:00
|
|
|
channels: [],
|
|
|
|
ssl: false,
|
|
|
|
password: false,
|
|
|
|
readonly: false,
|
|
|
|
showDetails: false
|
2018-08-10 18:24:29 +00:00
|
|
|
},
|
2018-11-06 10:13:32 +00:00
|
|
|
hexIP: false,
|
2018-11-10 11:18:45 +00:00
|
|
|
newVersionAvailable: false,
|
|
|
|
installable: null
|
2018-04-25 03:36:27 +00:00
|
|
|
};
|
2017-06-06 23:03:35 +00:00
|
|
|
|
2018-04-25 03:36:27 +00:00
|
|
|
export default createReducer(initialState, {
|
|
|
|
[actions.APP_SET](state, { key, value }) {
|
2018-11-22 11:00:18 +00:00
|
|
|
if (typeof key === 'object') {
|
2019-01-05 06:08:34 +00:00
|
|
|
Object.assign(state, key);
|
2018-11-22 11:00:18 +00:00
|
|
|
} else {
|
|
|
|
state[key] = value;
|
|
|
|
}
|
2017-06-06 23:03:35 +00:00
|
|
|
},
|
|
|
|
|
2020-06-05 06:56:11 +00:00
|
|
|
[actions.socket.CONNECTED](state, { connected }) {
|
|
|
|
state.connected = connected;
|
|
|
|
},
|
|
|
|
|
2017-06-06 23:03:35 +00:00
|
|
|
[actions.UPDATE_MESSAGE_HEIGHT](state, action) {
|
2018-04-25 03:36:27 +00:00
|
|
|
state.wrapWidth = action.wrapWidth;
|
|
|
|
state.charWidth = action.charWidth;
|
|
|
|
state.windowWidth = action.windowWidth;
|
2020-06-24 23:50:10 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
[actions.INIT](state, { app }) {
|
|
|
|
Object.assign(state, app);
|
2017-06-06 23:03:35 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export function appSet(key, value) {
|
|
|
|
return {
|
|
|
|
type: actions.APP_SET,
|
|
|
|
key,
|
|
|
|
value
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function setCharWidth(width) {
|
|
|
|
return appSet('charWidth', width);
|
|
|
|
}
|