Skip to content

Commit

Permalink
Merge pull request #49 from RNGeek/fix-measure-count
Browse files Browse the repository at this point in the history
`count` が何故か 2191 or 0 で固定されて集計されてしまう問題を修正
  • Loading branch information
mizdra authored Sep 5, 2020
2 parents 48ce3b0 + bf8726d commit 1399f49
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
10 changes: 7 additions & 3 deletions src/frontend/lib/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,22 @@ class AppStateManager {
}

updateState (newState: DeepPartial<AppState>) {
this.currentState = {
// NOTE: Vue の data は getter を使って構成されているので、プロパティにアクセスするタイミングによって値が変わってしまう。
// これでは集計上不都合なので、ここで一度 pure なオブジェクトに変換している。
this.currentState = JSON.parse(JSON.stringify({
configInUse: {
...this.currentState.configInUse,
...newState.configInUse,
// Infinity は JSON に変換できないので -1 として扱う
maxLoop: newState.configInUse?.maxLoop === Infinity ? -1 : (newState.configInUse?.maxLoop ?? this.currentState.configInUse.maxLoop),
},
state: {
...this.currentState.state,
...newState.state,
},
countdownId: newState.countdownId ?? this.currentState.countdownId,
count: newState.count ?? this.currentState.count,
}
}))
}

getCurrentState (): AppState {
Expand Down Expand Up @@ -160,7 +164,7 @@ class MemoryMeasurementScheduler {

const scheduleMeasurement = () => {
const interval = measurementInterval()
console.log('Scheduling memory measurement in ' + Math.round(interval / 1000) + ' seconds.')
console.log(`Scheduling memory measurement in ${Math.round(interval / 1000)} seconds (${new Date(Date.now() + interval).toLocaleString()}).`)
window.setTimeout(() => {
this.measureAndReportMemory()
scheduleMeasurement()
Expand Down
12 changes: 3 additions & 9 deletions src/frontend/pages/SimpleTimer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,15 @@ export default Vue.extend({
configInUse: {
handler (newConfigInUse): void {
appStateManager.updateState({
// NOTE: Vue の data は getter を使って構成されているので、プロパティにアクセスするタイミングによって値が変わってしまう。
// これでは集計上不都合なので、pure なオブジェクトに変換してから渡すようにしている。
configInUse: JSON.parse(JSON.stringify(newConfigInUse)),
configInUse: newConfigInUse,
})
},
deep: true,
},
state: {
handler (newState): void {
appStateManager.updateState({
// NOTE: Vue の data は getter を使って構成されているので、プロパティにアクセスするタイミングによって値が変わってしまう。
// これでは集計上不都合なので、pure なオブジェクトに変換してから渡すようにしている。
state: JSON.parse(JSON.stringify(newState)),
state: newState,
})
},
deep: true,
Expand Down Expand Up @@ -144,9 +140,7 @@ export default Vue.extend({
}
},
onCountdownprogress (count): void {
appStateManager.updateState({
count,
})
appStateManager.updateState({ count })
},
onCountdownEnd (): void {
this.state.counting = false
Expand Down

0 comments on commit 1399f49

Please sign in to comment.