18 lines
702 B
JavaScript
18 lines
702 B
JavaScript
function createTodayCompletion({ todayWork, todaySync, workSession, refresh, warm, announce, advance = null }) {
|
|
return function completeTodayItem(item, options = {}) {
|
|
if (!item || !todayWork.remove(item)) {
|
|
announce(options.failureMessage || 'Could not update Today on this device. Try again.');
|
|
return false;
|
|
}
|
|
todaySync.enqueue('remove', todayWork.identity(item));
|
|
todaySync.flush();
|
|
refresh();
|
|
warm();
|
|
(advance || (() => workSession.complete()))();
|
|
announce(options.successMessage || 'Done for Today. The Gitea item is unchanged.');
|
|
return true;
|
|
};
|
|
}
|
|
|
|
if (typeof module !== 'undefined' && module.exports) module.exports = createTodayCompletion;
|