tpmkms_4wp 9.3.0-beta.33 → 9.3.0-beta.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/common/reminders.js +21 -13
- package/common/reminders.test.json +5990 -0
- package/package.json +2 -2
package/common/reminders.js
CHANGED
@@ -16,19 +16,19 @@ const helpers = require('./helpers')
|
|
16
16
|
remind every truck driver to whatever tomorrow at 8 am
|
17
17
|
*/
|
18
18
|
|
19
|
-
const query = (missing,
|
19
|
+
const query = (missing, reminder_id) => {
|
20
20
|
return {
|
21
21
|
where: where(),
|
22
22
|
// oneShot: false,
|
23
23
|
onNevermind: ({verbatim, ...args}) => {
|
24
24
|
const api = args.kms.reminders.api
|
25
|
-
api.delete_reminder(
|
25
|
+
api.delete_reminder(reminder_id)
|
26
26
|
},
|
27
27
|
|
28
|
-
matchq: ({ api, context }) => api.missing(missing,
|
28
|
+
matchq: ({ api, context }) => api.missing(missing, reminder_id) && context.marker == 'controlEnd',
|
29
29
|
applyq: async ({ api, context, gs }) => {
|
30
30
|
context.cascade = false
|
31
|
-
const item = api.missing(missing,
|
31
|
+
const item = api.missing(missing, reminder_id)
|
32
32
|
let who
|
33
33
|
if (Array.isArray(item.who)) {
|
34
34
|
who = await gs(item.who.map((who) => who.text), ', ', ' and ')
|
@@ -48,7 +48,10 @@ const query = (missing, reminder) => {
|
|
48
48
|
},
|
49
49
|
|
50
50
|
matchr: ({ isA, api, context }) => {
|
51
|
-
|
51
|
+
if (context.evaluate) {
|
52
|
+
return false
|
53
|
+
}
|
54
|
+
const gotADate = ((isA(context.marker, 'onDateValue_dates') || isA(context.marker, 'dateTimeSelector')) && api.missing(missing, reminder_id))
|
52
55
|
if (missing == 'missingDate') {
|
53
56
|
return gotADate
|
54
57
|
} else {
|
@@ -58,7 +61,7 @@ const query = (missing, reminder) => {
|
|
58
61
|
return false
|
59
62
|
},
|
60
63
|
applyr: async ({ context, api, gp }) => {
|
61
|
-
const item = api.missing(missing,
|
64
|
+
const item = api.missing(missing, reminder_id)
|
62
65
|
await api.update({ id: item.id, dateTimeSelector: context, dateTimeSelectorText: await gp(context) })
|
63
66
|
}
|
64
67
|
}
|
@@ -132,7 +135,8 @@ class API {
|
|
132
135
|
getCurrent() {
|
133
136
|
}
|
134
137
|
|
135
|
-
missing(what,
|
138
|
+
missing(what, reminder_id) {
|
139
|
+
const reminder = this.reminder(reminder_id)
|
136
140
|
if (what == 'missingReminder' && !reminder.text) {
|
137
141
|
return { when: true, who: reminder.who, text: reminder.text, id: reminder.id, missingReminder: true }
|
138
142
|
}
|
@@ -141,6 +145,10 @@ class API {
|
|
141
145
|
}
|
142
146
|
}
|
143
147
|
|
148
|
+
reminder(id) {
|
149
|
+
return this._objects.reminders.find((reminder) => reminder.id == id)
|
150
|
+
}
|
151
|
+
|
144
152
|
reminders() {
|
145
153
|
return this._objects.reminders
|
146
154
|
}
|
@@ -152,11 +160,11 @@ class API {
|
|
152
160
|
askAbout(what) {
|
153
161
|
const items = []
|
154
162
|
for (const item of this.reminders()) {
|
155
|
-
if (this.missing('missingReminder', item)) {
|
156
|
-
items.push(this.missing('missingReminder', item))
|
163
|
+
if (this.missing('missingReminder', item.id)) {
|
164
|
+
items.push(this.missing('missingReminder', item.id))
|
157
165
|
}
|
158
|
-
if (this.missing('missingDate', item)) {
|
159
|
-
items.push(this.missing('missingDate', item))
|
166
|
+
if (this.missing('missingDate', item.id)) {
|
167
|
+
items.push(this.missing('missingDate', item.id))
|
160
168
|
}
|
161
169
|
}
|
162
170
|
return items
|
@@ -283,8 +291,8 @@ const template = {
|
|
283
291
|
// await api.instantiate(reminder)
|
284
292
|
await api.add(reminder)
|
285
293
|
reminder.cleanUp = ask([
|
286
|
-
query('missingReminder', reminder),
|
287
|
-
query('missingDate', reminder),
|
294
|
+
query('missingReminder', reminder.id),
|
295
|
+
query('missingDate', reminder.id),
|
288
296
|
])
|
289
297
|
},
|
290
298
|
},
|