Skip to content

Commit

Permalink
fix: console now properly maintains history
Browse files Browse the repository at this point in the history
  • Loading branch information
cadriel committed Oct 19, 2020
1 parent b5ce691 commit 2334c3f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
5 changes: 1 addition & 4 deletions src/store/socket/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,7 @@ export const actions: ActionTree<SocketState, RootState> = {
async removeWait ({ commit }, wait) {
commit('removeWait', wait)
},
async addConsoleEntry ({ commit, state }, payload) {
if (state.console.length >= Globals.CONSOLE_HISTORY_RETENTION) {
commit('removeConsoleFirstEntry')
}
async addConsoleEntry ({ commit }, payload) {
commit('addConsoleEntry', payload.replace(/(?:\r\n|\r|\n)/g, '<br>'))
},
async addMacro ({ commit, rootState }, macro) {
Expand Down
11 changes: 6 additions & 5 deletions src/store/socket/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import Vue from 'vue'
import { MutationTree } from 'vuex'
import { get } from 'lodash-es'
import { SocketState, ChartDataSet, Macro } from './types'
import { state, getDefaultState } from './index'
import { chartConfiguration } from '@/globals'
import { getDefaultState } from './index'
import { Globals, chartConfiguration } from '@/globals'

export const mutations: MutationTree<SocketState> = {
resetState (state) {
Expand Down Expand Up @@ -79,11 +79,12 @@ export const mutations: MutationTree<SocketState> = {
}
},
addConsoleEntry (state, payload) {
while (state.console.length >= Globals.CONSOLE_HISTORY_RETENTION) {
state.console.pop()
}

state.console.unshift(payload)
},
removeConsoleFirstEntry () {
state.console.shift()
},
addMacro (state, macro: Macro) {
Vue.set(state.macros, macro.name, macro)
},
Expand Down

0 comments on commit 2334c3f

Please sign in to comment.