Skip to content

Commit 5819e63

Browse files
committed
vuex: fix history bug when filtering
1 parent 18b8c52 commit 5819e63

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/devtools/views/vuex/VuexHistory.vue

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
<span class="label inspected" v-if="inspectedIndex === -1">inspected</span>
3636
</div>
3737
<div class="entry"
38-
v-for="(entry, index) in filteredHistory"
39-
:class="{ inspected: inspectedIndex === index, active: activeIndex === index }"
40-
@click="step(index)">
38+
v-for="entry in filteredHistory"
39+
:class="{ inspected: isInspected(entry), active: isActive(entry) }"
40+
@click="step(entry)">
4141
<span class="mutation-type">{{ entry.mutation.type }}</span>
42-
<span class="entry-actions" v-if="inspectedIndex === index">
42+
<span class="entry-actions" v-if="isInspected(entry)">
4343
<a class="action" @click.stop="commitSelected" title="Commit This Mutation">
4444
<i class="material-icons">get_app</i>
4545
<span>Commit</span>
@@ -48,16 +48,16 @@
4848
<i class="material-icons">delete</i>
4949
<span>Revert</span>
5050
</a>
51-
<a v-if="activeIndex !== index" class="action" @click.stop="timeTravelToSelected" title="Time Travel to This State">
51+
<a v-if="!isActive(entry)" class="action" @click.stop="timeTravelToSelected" title="Time Travel to This State">
5252
<i class="material-icons">restore</i>
5353
<span>Time Travel</span>
5454
</a>
5555
</span>
5656
<span class="time" :title="entry.timestamp">
5757
{{ entry.timestamp | formatTime }}
5858
</span>
59-
<span class="label active" v-if="activeIndex === index">active</span>
60-
<span class="label inspected" v-if="inspectedIndex === index">inspected</span>
59+
<span class="label active" v-if="isActive(entry)">active</span>
60+
<span class="label inspected" v-if="isInspected(entry)">inspected</span>
6161
</div>
6262
</div>
6363
</scroll-pane>
@@ -129,6 +129,12 @@ export default {
129129
'step',
130130
'timeTravelToSelected'
131131
]),
132+
isActive (entry) {
133+
return this.activeIndex === this.history.indexOf(entry)
134+
},
135+
isInspected (entry) {
136+
return this.inspectedIndex === this.history.indexOf(entry)
137+
},
132138
onKeyNav (dir) {
133139
if (dir === 'up') {
134140
this.step(this.inspectedIndex - 1)

src/devtools/views/vuex/actions.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ export function reset ({ commit, state }) {
2727
travelTo(state, commit)
2828
}
2929

30-
export function step ({ commit, state }, index) {
31-
commit('STEP', index)
30+
export function step ({ commit, state }, entry) {
31+
const index = state.history.indexOf(entry)
32+
if (index > -1) {
33+
commit('STEP', index)
34+
}
3235
}
3336

3437
export function timeTravelToSelected ({ state, commit }) {

0 commit comments

Comments
 (0)