Skip to content

Commit

Permalink
Merge pull request #89 from mihaiconstantin/feature-total-sessions
Browse files Browse the repository at this point in the history
Added counter for total work sessions (follow-up #84)
  • Loading branch information
Splode authored May 16, 2020
2 parents cc7b6e9 + 780e059 commit adbc536
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/renderer/components/timer/Timer-controller.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ export default {
checkRound() {
if (this.currentRound === 'work' && this.round >= this.workRounds) {
this.$store.dispatch('setCurrentRound', 'long-break')
this.$store.dispatch('incrementTotalWorkRounds')
EventBus.$emit('ready-long-break')
console.log('long-break ready')
} else if (this.currentRound === 'work') {
this.$store.dispatch('setCurrentRound', 'short-break')
this.$store.dispatch('incrementTotalWorkRounds')
EventBus.$emit('ready-short-break')
console.log('short-break ready')
} else if (this.currentRound === 'short-break') {
Expand Down
11 changes: 10 additions & 1 deletion src/renderer/components/timer/Timer-footer.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<section class="Container Footer">
<div class="Round-wrapper">
<p>{{ round + '/' + workRounds }}</p>
<p>{{ round + '/' + workRounds }} <span v-if="totalWorkRounds > 0" class="Total-rounds">({{ totalWorkRounds }})</span></p>
<p
class="TextButton"
@click="callForReset"
Expand Down Expand Up @@ -150,6 +150,10 @@ export default {
return this.$store.getters.workRounds
},
totalWorkRounds() {
return this.$store.getters.totalWorkRounds
},
volume() {
return this.$store.getters.volume
}
Expand Down Expand Up @@ -253,6 +257,11 @@ export default {
.Round-wrapper {
text-align: center;
.Total-rounds {
color: #858c99;
font-size: .7rem;
}
}
.Slider-wrapper {
Expand Down
12 changes: 12 additions & 0 deletions src/renderer/store/modules/Timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { defaults } from './../../utils/LocalStore'
const state = {
round: 1,
workRounds: parseInt(localStore.get('workRounds')),
totalWorkRounds: 0,
timeLongBreak: parseInt(localStore.get('timeLongBreak')),
timeShortBreak: parseInt(localStore.get('timeShortBreak')),
timeWork: parseInt(localStore.get('timeWork')),
Expand All @@ -18,6 +19,9 @@ const getters = {
workRounds() {
return state.workRounds
},
totalWorkRounds() {
return state.totalWorkRounds
},
timeLongBreak() {
return state.timeLongBreak
},
Expand All @@ -44,6 +48,10 @@ const mutations = {
state.round = 1
},

INCREMENT_TOTAL_WORK_ROUNDS(state) {
state.totalWorkRounds += 1
},

RESET_DEFAULTS(state) {
state.workRounds = defaults.workRounds
state.timeLongBreak = defaults.timeLongBreak
Expand Down Expand Up @@ -85,6 +93,10 @@ const actions = {
commit('RESET_ROUND')
},

incrementTotalWorkRounds({ commit }) {
commit('INCREMENT_TOTAL_WORK_ROUNDS')
},

resetDefaults({ commit }) {
commit('RESET_DEFAULTS')
localStore.set('workRounds', defaults.workRounds)
Expand Down

0 comments on commit adbc536

Please sign in to comment.