Add State.create()

This commit is contained in:
Simon Ser 2021-09-21 12:33:22 +02:00
parent 0b0467f019
commit e7f8620933
2 changed files with 8 additions and 3 deletions

View file

@ -116,6 +116,7 @@ function showNotification(title, options) {
export default class App extends Component { export default class App extends Component {
state = { state = {
...State.create(),
connectParams: { connectParams: {
url: null, url: null,
pass: null, pass: null,
@ -126,10 +127,7 @@ export default class App extends Component {
autoconnect: false, autoconnect: false,
autojoin: [], autojoin: [],
}, },
servers: new Map(),
buffers: new Map(),
bouncerNetworks: new Map(), bouncerNetworks: new Map(),
activeBuffer: null,
connectForm: true, connectForm: true,
loading: true, loading: true,
dialog: null, dialog: null,

View file

@ -161,6 +161,13 @@ let lastBufferID = 0;
let lastMessageKey = 0; let lastMessageKey = 0;
export const State = { export const State = {
create() {
return {
servers: new Map(),
buffers: new Map(),
activeBuffer: null,
};
},
updateServer(state, id, updater) { updateServer(state, id, updater) {
let server = state.servers.get(id); let server = state.servers.get(id);
if (!server) { if (!server) {