Skip to content

Commit 8ca6f17

Browse files
committed
mostly graceful resuming of missed _notifications (when dmt-proc is offline) with deduplication
1 parent c7619de commit 8ca6f17

File tree

46 files changed

+1087
-593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1087
-593
lines changed

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.222 · 2025-01-20
1+
1.2.235 · 2025-02-18

core/node/aspect-extend/user-engine-load/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ async function init(program) {
1313
function userEngineReady(results) {
1414
deviceLoader(program, userEnginePath);
1515

16-
program.loadDirectoryRecursive(path.join(userEnginePath, '_notifications'));
16+
const notificationsDir = path.join(userEnginePath, '_notifications');
17+
18+
if (fs.existsSync(notificationsDir)) {
19+
log.green(`Loading dmt notifications from ${colors.cyan(notificationsDir)}`);
20+
}
21+
program.loadDirectoryRecursive(notificationsDir);
1722

1823
let notificationsReloadTimeout;
1924
let notificationsReloadTimeout2;
@@ -30,7 +35,7 @@ async function init(program) {
3035
notificationsReloadTimeout = setTimeout(() => {
3136
program.decommissionNotifiers();
3237
notificationsReloadTimeout2 = setTimeout(() => {
33-
program.loadDirectoryRecursive(path.join(userEnginePath, '_notifications'));
38+
program.loadDirectoryRecursive(notificationsDir);
3439
}, DIFF);
3540
}, Math.max(delay - DIFF, 0));
3641
});

core/node/common/lib/logger.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ class Logger {
200200
if (this.buffer.length > 0) {
201201
const prev = this.buffer[this.buffer.length - 1];
202202
const diff = meta.timestamp - prev.meta.timestamp;
203-
204203
diffStr = ` (+${formatMilliseconds(diff)})`;
205204

206205
if (diff > 1000) {

core/node/common/lib/timeutils/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export const ONE_MINUTE = 60 * ONE_SECOND;
1515
export const ONE_HOUR = 60 * ONE_MINUTE;
1616
export const ONE_DAY = 24 * ONE_HOUR;
1717
export const ONE_WEEK = 7 * ONE_DAY;
18+
export const ONE_MONTH = 30 * ONE_DAY;
19+
export const ONE_YEAR = 365 * ONE_DAY;
1820

1921
export function formatSeconds(seconds) {
2022
return formatMilliseconds(1000 * seconds);
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
import { dateFns } from '../../dmtHelper.js';
22

3-
const { formatDistanceToNow } = dateFns;
4-
5-
export function prettyTimeAgo(referenceDate, { detailed = false } = {}) {
6-
const diff = Math.round((Date.now() - referenceDate) / 1000);
3+
const { formatDistance } = dateFns;
4+
export function prettyTimeAgo(referenceDate, { now = Date.now(), detailed = false, lang = undefined } = {}) {
5+
const diff = Math.round((now - referenceDate) / 1000);
76

87
if (detailed && diff < 60) {
98
return `${diff}s ago`;
109
}
1110

12-
return formatDistanceToNow(referenceDate, { addSuffix: true })
11+
const str = formatDistance(referenceDate, now, { addSuffix: true })
1312
.replace('about ', '')
1413
.replace('less than a minute ', 'a few seconds ')
1514
.replace(/^1 day ago$/, 'yesterday')
1615
.trim();
16+
17+
return str;
1718
}
1819

19-
export function prettyTime(ms) {
20-
return prettyTimeAgo(ms)
20+
export function prettyTime(ms, { now = Date.now() } = {}) {
21+
return prettyTimeAgo(ms, { now })
2122
.replace(' ago', '')
2223
.replace('yesterday', '1 day');
2324
}

core/node/connectome/node_modules/bufferutil/build/node_gyp_bins/python3

Lines changed: 0 additions & 1 deletion
This file was deleted.

core/node/connectome/node_modules/utf-8-validate/build/node_gyp_bins/python3

Lines changed: 0 additions & 1 deletion
This file was deleted.

core/node/connectome/stores/node/index.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -378,15 +378,9 @@ class Slot {
378378

379379
get(key) {
380380
const slotState = this.parent.get(this.name) || {};
381-
const val = key ? slotState[key] : slotState;
382-
383-
// if (typeof val == 'object') {
384-
// console.log(val);
385-
// //log.cyan(val);
386-
// }
387-
388-
return typeof val == 'object' ? clone(val) : val;
389-
//return key ? slotState[key] : slotState;
381+
//const val = key ? slotState[key] : slotState;
382+
//return typeof val == 'object' ? clone(val) : val;
383+
return key ? slotState[key] : slotState;
390384
}
391385

392386
set(state, { announce = true } = {}) {

core/node/connectome/stores/node/index.mjs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -364,15 +364,9 @@ class Slot {
364364

365365
get(key) {
366366
const slotState = this.parent.get(this.name) || {};
367-
const val = key ? slotState[key] : slotState;
368-
369-
// if (typeof val == 'object') {
370-
// console.log(val);
371-
// //log.cyan(val);
372-
// }
373-
374-
return typeof val == 'object' ? clone(val) : val;
375-
//return key ? slotState[key] : slotState;
367+
//const val = key ? slotState[key] : slotState;
368+
//return typeof val == 'object' ? clone(val) : val;
369+
return key ? slotState[key] : slotState;
376370
}
377371

378372
set(state, { announce = true } = {}) {

core/node/controller/processes/dmt-proc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ mids.push({ gui: { condition: deviceDef => deviceDef.try('service[gui].disable')
3939
mids.push('nearby/lanbus');
4040
mids.push('nearby/nearby');
4141
mids.push('iot');
42+
mids.push('notify');
4243

4344
mids.push('content/samba');
4445

0 commit comments

Comments
 (0)