Skip to content

Commit

Permalink
fix reminders
Browse files Browse the repository at this point in the history
  • Loading branch information
piascikj committed Mar 21, 2018
1 parent 68a6c0f commit e231fbe
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## 2.4.1
- Don't remind if task has completed metadata
- Set reminder to notify every 5 minutes until remind metadata is removed or changed
- Remove reminder if completed
- Fix issue #360

## 2.4.0
- Add export to imdone-export.json with alt-x
Expand Down
4 changes: 4 additions & 0 deletions lib/services/imdoneio-store.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = (repo) ->
log = require('debug') 'imdoneio-store'
transform = require('./transform')
Task = require 'imdone-core/lib/task'
Reminders = require './reminders'
fs = require 'fs'
_ = require 'lodash'
async = require 'async'
Expand Down Expand Up @@ -100,6 +101,7 @@ module.exports = (repo) ->
return cb err
repo.saveModifiedFiles (err) =>
repo.resume()
repo.reminders.schedule()
return cb err if err
cb(null, repo.getTasks())

Expand Down Expand Up @@ -222,10 +224,12 @@ module.exports = (repo) ->
if sortEnabled()
_init (err, files) ->
return cb err if err
repo.reminders = new Reminders(repo);
checkForIIOProject()
populateSort (err) -> cb null, files
else
_init (err, files) ->
repo.reminders = new Reminders(repo);
return cb err if err
checkForIIOProject()
cb null, files
Expand Down
3 changes: 2 additions & 1 deletion lib/services/reminders.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ class Reminders {
this.notify(task, job)
task.meta.remind[0] = reminder.add(5, 'minutes').format()
task.updateMetaData()
repo.modifyTask(task, true)
repo.modifyTask(task, (err) => repo.emit('tasks.updated', [task]))
});
this.jobs.push(job)
})
console.log(`reminders: ${this.jobs.length}`)
}

notify(task, job) {
Expand Down
4 changes: 2 additions & 2 deletions lib/services/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const getTransformers = function (config) {
if (task.meta.completed) return task.text
if (task.list !== list) return task.text
task.addMetaData("completed", this.parseDate('now').format())
task.updateMetaData()
task.removeMetaData('remind')
return task.text
},
pattern: /^((?!\scompleted:).)*$/,
Expand All @@ -95,7 +95,7 @@ const transformTask = function (task, transformers) {

const transformTasks = function (config, tasks) {
const transformers = getTransformers(config)
return tasks.map(task => transformTask(new Task(task), transformers))
return tasks.map(task => transformTask(task, transformers))
}

module.exports = {
Expand Down
2 changes: 0 additions & 2 deletions lib/services/worker-watched-fs-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ var fs = require('fs'),
File = require('imdone-core/lib/file'),
constants = require('imdone-core/lib/constants'),
path = require('path'),
Reminders = require('./reminders'),
config = require('./imdone-config');

var workerPath = path.join(config.getPackagePath(), 'lib', 'services', 'worker.js')
Expand All @@ -33,7 +32,6 @@ function mixin(repo, fs) {
repo.init = function(cb) {
_init.call(repo, function(err, files) {
repo.initWatcher();
repo.reminders = new Reminders(repo);
if (cb) cb(err, files);
});
};
Expand Down
1 change: 0 additions & 1 deletion lib/views/imdone-atom-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,6 @@ class ImdoneAtomView extends ScrollView
onRepoUpdate: (tasks) ->
# BACKLOG: This should be queued so two updates don't colide gh:241 id:90
@imdoneRepo.transformTasks tasks, (err, tasks) =>
@imdoneRepo.reminders.schedule()
@updateBoard(tasks)
@boardWrapper.css 'bottom', 0
@bottomView.attr 'style', ''
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"fs-plus": "^2.8.1",
"git-up": "^2.0.1",
"ignore": "^3.3.7",
"imdone-core": "1.4.1",
"imdone-core": "1.4.2",
"json-editor": "^0.7.28",
"laconic": "^0.2.2",
"lodash": "^4.12.0",
Expand Down

0 comments on commit e231fbe

Please sign in to comment.