Skip to content

Commit

Permalink
Update based on review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jkppr committed Jan 24, 2025
1 parent c94ba06 commit ff479dc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions timesketch/frontend-ng/src/components/Explore/Comments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default {
this.comments.push(response.data.objects[0][0])
this.event._source.comment.push(this.comment)
this.comment = ''
this.$store.dispatch('updateEventLabels', { labels: [...this.$store.state.meta.filter_labels], label: "__ts_comment", num: 1 })
this.$store.dispatch('updateEventLabels', { label: "__ts_comment", num: 1 })
})
.catch((e) => {})
},
Expand All @@ -136,7 +136,7 @@ export default {
.then((response) => {
this.comments.splice(commentIndex, 1)
this.event._source.comment.splice(commentIndex, 1)
this.$store.dispatch('updateEventLabels', { labels: [...this.$store.state.meta.filter_labels], label: "__ts_comment", num: -1 })
this.$store.dispatch('updateEventLabels', { label: "__ts_comment", num: -1 })
})
.catch((e) => {
console.error(e)
Expand Down
4 changes: 2 additions & 2 deletions timesketch/frontend-ng/src/components/Explore/EventList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ export default {
}
ApiClient.saveEventAnnotation(this.sketch.id, 'label', '__ts_star', event, this.currentSearchNode)
.then((response) => {
this.$store.dispatch('updateEventLabels', { labels: [...this.$store.state.meta.filter_labels], label: "__ts_star", num: count })
this.$store.dispatch('updateEventLabels', { label: "__ts_star", num: count })
})
.catch((e) => {
console.error(e)
Expand All @@ -1015,7 +1015,7 @@ export default {
})
ApiClient.saveEventAnnotation(this.sketch.id, 'label', '__ts_star', this.selectedEvents, this.currentSearchNode)
.then((response) => {
this.$store.dispatch('updateEventLabels',{ labels: [...this.$store.state.meta.filter_labels], label: "__ts_star", num: netStarCountChange })
this.$store.dispatch('updateEventLabels',{ label: "__ts_star", num: netStarCountChange })
this.selectedEvents = []
})
.catch((e) => {})
Expand Down
16 changes: 8 additions & 8 deletions timesketch/frontend-ng/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,18 +242,18 @@ export default new Vuex.Store({
})
.catch((e) => {})
},
updateEventLabels(context, payload) {
if (!payload.labels || !payload.label || !payload.num) {
updateEventLabels(context, {label: inputLabel, num}) {
if (!inputLabel || !num) {
return
}
let labels = payload.labels
let starLabelIndex = labels.findIndex(label => label.label === payload.label);
if (starLabelIndex > -1) {
labels[starLabelIndex].count = labels[starLabelIndex].count + payload.num
let allLabels = context.state.meta.filter_labels
let label = allLabels.find(label => label.label === inputLabel);
if (label !== undefined) {
label.count += num
} else {
labels.push({ label: payload.label, count: 1 })
allLabels.push({ label: inputLabel, count: num })
}
context.commit('SET_EVENT_LABELS', labels)
context.commit('SET_EVENT_LABELS', allLabels)
},
updateTimelineTags(context, payload) {
if (!context.state.sketch.active_timelines.length) {
Expand Down

0 comments on commit ff479dc

Please sign in to comment.