src/libs/state.js
// Import a previously exported state to continue that state
Import a previously exported state to continue that state
Import a previously exported state to continue that state
function importState(stateStr) {
            let importObj = JSON.parse(stateStr);
            if (importObj && importObj.networks) {
                this.resetState();
                importObj.networks.forEach(importNetwork => {
                    let network = createEmptyNetworkObject();
                    network.id = importNetwork.id;
                    network.name = importNetwork.name;
                    network.connection = importNetwork.connection;
                    network.auto_commands = importNetwork.auto_commands || '';
                    network.settings = importNetwork.settings;
                    network.nick = importNetwork.nick;
                    network.username = importNetwork.username;
                    network.gecos = importNetwork.gecos;
                    network.password = importNetwork.password;
                    this.networks.push(network);
                    initialiseNetworkState(network);
                    importNetwork.buffers.forEach(importBuffer => {
                        let buffer = createEmptyBufferObject();
                        buffer.name = importBuffer.name;
                        buffer.key = importBuffer.key;
                        buffer.networkid = network.id;
                        buffer.enabled = !!importBuffer.enabled;
                        buffer.settings = importBuffer.settings;
                        network.buffers.push(buffer);
                        initialiseBufferState(buffer);
                    });
                });
            }
            if (importObj && importObj.user_settings) {
                this.user_settings = importObj.user_settings;
            }
        }
function importState ( stateStr ) { let importObj = JSON . parse ( stateStr ) ; if ( importObj && importObj . networks ) { this . resetState ( ) ; importObj . networks . forEach ( importNetwork => { let network = createEmptyNetworkObject ( ) ; network . id = importNetwork . id ; network . name = importNetwork . name ; network . connection = importNetwork . connection ; network . auto_commands = importNetwork . auto_commands || '' ; network . settings = importNetwork . settings ; network . nick = importNetwork . nick ; network . username = importNetwork . username ; network . gecos = importNetwork . gecos ; network . password = importNetwork . password ; this . networks . push ( network ) ; initialiseNetworkState ( network ) ; importNetwork . buffers . forEach ( importBuffer => { let buffer = createEmptyBufferObject ( ) ; buffer . name = importBuffer . name ; buffer . key = importBuffer . key ; buffer . networkid = network . id ; buffer . enabled = ! ! importBuffer . enabled ; buffer . settings = importBuffer . settings ; network . buffers . push ( buffer ) ; initialiseBufferState ( buffer ) ; } ) ; } ) ; } if ( importObj && importObj . user_settings ) { this . user_settings = importObj . user_settings ; } }
Import a previously exported state to continue that state
Import a previously exported state to continue that state