solid-ui 2.4.26 → 2.4.27-13192548

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.
@@ -5,12 +5,15 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ exports.ActionClassFromEmoji = ActionClassFromEmoji;
9
+ exports.emojiFromAction = emojiFromAction;
10
+ exports.emojiFromActionClass = emojiFromActionClass;
8
11
  exports.messageToolbar = messageToolbar;
9
12
  exports.sentimentStrip = sentimentStrip;
10
13
  exports.sentimentStripLinked = sentimentStripLinked;
11
14
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
15
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
16
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
14
17
  var debug = _interopRequireWildcard(require("../debug"));
15
18
  var _iconBase = require("../iconBase");
16
19
  var ns = _interopRequireWildcard(require("../ns"));
@@ -51,30 +54,46 @@ var PENCIL_ICON = 'noun_253504.svg'; // edit a message
51
54
  // const SPANNER_ICON = 'noun_344563.svg' -> settings
52
55
  var THUMBS_UP_ICON = 'noun_1384132.svg';
53
56
  var THUMBS_DOWN_ICON = 'noun_1384135.svg';
57
+ var REPLY_ICON = 'noun-reply-5506924.svg';
54
58
  /**
55
59
  * Emoji in Unicode
56
60
  */
57
- var emoji = {};
58
- emoji[ns.schema('AgreeAction')] = '👍';
59
- emoji[ns.schema('DisagreeAction')] = '👎';
60
- emoji[ns.schema('EndorseAction')] = '⭐️';
61
- emoji[ns.schema('LikeAction')] = '❤️';
61
+ var emojiMap = {};
62
+ emojiMap[ns.schema('AgreeAction')] = '👍';
63
+ emojiMap[ns.schema('DisagreeAction')] = '👎';
64
+ emojiMap[ns.schema('EndorseAction')] = '⭐️';
65
+ emojiMap[ns.schema('LikeAction')] = '❤️';
66
+ function emojiFromActionClass(action) {
67
+ return emojiMap[action] || null;
68
+ }
69
+ function ActionClassFromEmoji(emoji) {
70
+ for (var a in emojiMap) {
71
+ if (emojiMap[a] === emoji) {
72
+ return rdf.sym(a.slice(1, -1)); // remove < >
73
+ }
74
+ }
75
+
76
+ return null;
77
+ }
78
+
79
+ // Allow the qction to give its own emoji as content,
80
+ // or get the emoji from the class lof action.
81
+ function emojiFromAction(action) {
82
+ var content = _solidLogic.store.any(action, ns.sioc('content'), null, action.doc());
83
+ if (content) return content;
84
+ var klass = _solidLogic.store.any(action, ns.rdf('type'), null, action.doc());
85
+ if (klass) {
86
+ var em = emojiFromActionClass(klass);
87
+ if (em) return em;
88
+ }
89
+ return '⬜️';
90
+ }
62
91
 
63
92
  /**
64
93
  * Create strip of sentiments expressed
65
94
  */
66
- function sentimentStrip(target, doc) {
67
- // alain seems not used
68
- var latest = (0, _chatLogic.mostRecentVersion)(target);
69
- var actions = _solidLogic.store.holds(latest, ns.schema('dateDeleted').value, null, latest.doc()) ? _solidLogic.store.each(null, ns.schema('target'), target, doc) : [];
70
- var sentiments = actions.map(function (a) {
71
- return _solidLogic.store.any(a, ns.rdf('type'), null, doc);
72
- });
73
- sentiments.sort();
74
- var strings = sentiments.map(function (x) {
75
- return emoji[x] || '';
76
- });
77
- return dom.createTextNode(strings.join(' '));
95
+ function sentimentStrip(_x, _x2) {
96
+ return _sentimentStrip.apply(this, arguments);
78
97
  }
79
98
  /**
80
99
  * Create strip of sentiments expressed, with hyperlinks
@@ -82,275 +101,444 @@ function sentimentStrip(target, doc) {
82
101
  * @param target {NamedNode} - The thing about which they are expressed
83
102
  * @param doc {NamedNode} - The document in which they are expressed
84
103
  */
85
- function sentimentStripLinked(target, doc) {
86
- var strip = dom.createElement('span');
87
- function refresh() {
88
- strip.innerHTML = '';
89
- var actions = (0, _chatLogic.mostRecentVersion)(target).uri !== ns.schema('dateDeleted').uri ? _solidLogic.store.each(null, ns.schema('target'), target, doc) : [];
90
- var sentiments = actions.map(function (a) {
91
- return [_solidLogic.store.any(a, ns.rdf('type'), null, doc), _solidLogic.store.any(a, ns.schema('agent'), null, doc)];
92
- });
93
- sentiments.sort();
94
- sentiments.forEach(function (ss) {
95
- var _ss = (0, _slicedToArray2["default"])(ss, 2),
96
- theClass = _ss[0],
97
- agent = _ss[1];
98
- var res;
99
- if (agent) {
100
- res = dom.createElement('a');
101
- res.setAttribute('href', agent.uri);
102
- } else {
103
- res = dom.createTextNode('');
104
+ function _sentimentStrip() {
105
+ _sentimentStrip = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(target, doc) {
106
+ var versions, actions, strings;
107
+ return _regenerator["default"].wrap(function _callee$(_context) {
108
+ while (1) switch (_context.prev = _context.next) {
109
+ case 0:
110
+ _context.next = 2;
111
+ return (0, _chatLogic.allVersions)(target);
112
+ case 2:
113
+ versions = _context.sent;
114
+ debug.log('sentimentStrip Versions for ' + target, versions);
115
+ actions = versions.map(function (version) {
116
+ return _solidLogic.store.each(null, ns.schema('target'), version, doc);
117
+ }).flat();
118
+ debug.log('sentimentStrip: Actions for ' + target, actions);
119
+ strings = actions.map(function (action) {
120
+ return emojiFromAction(action) || '';
121
+ });
122
+ return _context.abrupt("return", dom.createTextNode(strings.join(' ')));
123
+ case 8:
124
+ case "end":
125
+ return _context.stop();
104
126
  }
105
- res.textContent = emoji[theClass] || '*';
106
- strip.appendChild(res);
107
- });
108
- }
109
- refresh();
110
- strip.refresh = refresh;
111
- return strip;
127
+ }, _callee);
128
+ }));
129
+ return _sentimentStrip.apply(this, arguments);
130
+ }
131
+ function sentimentStripLinked(_x3, _x4) {
132
+ return _sentimentStripLinked.apply(this, arguments);
112
133
  }
113
134
  /**
114
135
  * Creates a message toolbar component
115
136
  */
116
- function messageToolbar(message, messageRow, userContext, channelObject) {
117
- function deleteMessage() {
118
- return _deleteMessage.apply(this, arguments);
119
- }
120
- function _deleteMessage() {
121
- _deleteMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
122
- var author, msg, area;
123
- return _regenerator["default"].wrap(function _callee2$(_context2) {
124
- while (1) switch (_context2.prev = _context2.next) {
125
- case 0:
126
- author = _solidLogic.store.any(message, ns.foaf('maker'));
127
- if (me) {
128
- _context2.next = 5;
129
- break;
137
+ function _sentimentStripLinked() {
138
+ _sentimentStripLinked = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(target, doc) {
139
+ var strip, refresh, _refresh;
140
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
141
+ while (1) switch (_context3.prev = _context3.next) {
142
+ case 0:
143
+ _refresh = function _refresh3() {
144
+ _refresh = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
145
+ var versions, actions, sentiments;
146
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
147
+ while (1) switch (_context2.prev = _context2.next) {
148
+ case 0:
149
+ strip.innerHTML = '';
150
+ if (!(0, _chatLogic.isDeleted)(target)) {
151
+ _context2.next = 3;
152
+ break;
153
+ }
154
+ return _context2.abrupt("return", strip);
155
+ case 3:
156
+ _context2.next = 5;
157
+ return (0, _chatLogic.allVersions)(target);
158
+ case 5:
159
+ versions = _context2.sent;
160
+ debug.log('sentimentStripLinked: Versions for ' + target, versions);
161
+ actions = versions.map(function (version) {
162
+ return _solidLogic.store.each(null, ns.schema('target'), version, doc);
163
+ }).flat();
164
+ debug.log('sentimentStripLinked: Actions for ' + target, actions);
165
+ if (!(actions.length === 0)) {
166
+ _context2.next = 11;
167
+ break;
168
+ }
169
+ return _context2.abrupt("return", strip);
170
+ case 11:
171
+ sentiments = actions.map(function (a) {
172
+ return [_solidLogic.store.any(a, ns.rdf('type'), null, doc), _solidLogic.store.any(a, ns.sioc('content'), null, doc), _solidLogic.store.any(a, ns.schema('agent'), null, doc)];
173
+ });
174
+ debug.log(' Actions sentiments ', sentiments);
175
+ sentiments.sort();
176
+ sentiments.forEach(function (ss) {
177
+ var _ss = (0, _slicedToArray2["default"])(ss, 3),
178
+ theClass = _ss[0],
179
+ content = _ss[1],
180
+ agent = _ss[2];
181
+ var res;
182
+ if (agent) {
183
+ res = dom.createElement('a');
184
+ res.setAttribute('href', agent.uri);
185
+ } else {
186
+ res = dom.createTextNode('');
187
+ }
188
+ res.textContent = content || emojiMap[theClass] || '⬜️';
189
+ strip.appendChild(res);
190
+ });
191
+ debug.log(' Actions strip ', strip);
192
+ case 16:
193
+ case "end":
194
+ return _context2.stop();
195
+ }
196
+ }, _callee2);
197
+ }));
198
+ return _refresh.apply(this, arguments);
199
+ };
200
+ refresh = function _refresh2() {
201
+ return _refresh.apply(this, arguments);
202
+ };
203
+ strip = dom.createElement('span');
204
+ refresh().then(debug.log('sentimentStripLinked: sentimentStripLinked async refreshed'));
205
+ strip.refresh = refresh;
206
+ return _context3.abrupt("return", strip);
207
+ case 6:
208
+ case "end":
209
+ return _context3.stop();
210
+ }
211
+ }, _callee3);
212
+ }));
213
+ return _sentimentStripLinked.apply(this, arguments);
214
+ }
215
+ function messageToolbar(_x5, _x6, _x7, _x8) {
216
+ return _messageToolbar.apply(this, arguments);
217
+ }
218
+ function _messageToolbar() {
219
+ _messageToolbar = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(message, messageRow, userContext, channelObject) {
220
+ var deleteMessage, _deleteMessage, editMessage, _editMessage, replyInThread, _replyInThread, div, closeToolbar, deleteThingThen, _deleteThingThen, me, sentimentButton, context1, cancelButton;
221
+ return _regenerator["default"].wrap(function _callee10$(_context10) {
222
+ while (1) switch (_context10.prev = _context10.next) {
223
+ case 0:
224
+ sentimentButton = function _sentimentButton(context, target, icon, actionClass, doc, mutuallyExclusive) {
225
+ function setColor() {
226
+ button.style.backgroundColor = action ? 'yellow' : 'white';
130
227
  }
131
- alert('You can\'t delete the message, you are not logged in.');
132
- _context2.next = 22;
133
- break;
134
- case 5:
135
- if (!me.sameTerm(author)) {
136
- _context2.next = 21;
137
- break;
228
+ var button = widgets.button(dom, icon, utils.label(actionClass), /*#__PURE__*/function () {
229
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(_event) {
230
+ var insertMe, dirty, i, a;
231
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
232
+ while (1) switch (_context4.prev = _context4.next) {
233
+ case 0:
234
+ if (!action) {
235
+ _context4.next = 7;
236
+ break;
237
+ }
238
+ _context4.next = 3;
239
+ return deleteThingThen(action);
240
+ case 3:
241
+ action = null;
242
+ setColor();
243
+ _context4.next = 25;
244
+ break;
245
+ case 7:
246
+ // no action
247
+ action = widgets.newThing(doc);
248
+ insertMe = [rdf.st(action, ns.schema('agent'), context.me, doc), rdf.st(action, ns.rdf('type'), actionClass, doc), rdf.st(action, ns.schema('target'), target, doc)];
249
+ _context4.next = 11;
250
+ return _solidLogic.store.updater.update([], insertMe);
251
+ case 11:
252
+ setColor();
253
+ if (!mutuallyExclusive) {
254
+ _context4.next = 25;
255
+ break;
256
+ }
257
+ // Delete incompative sentiments
258
+ dirty = false;
259
+ i = 0;
260
+ case 15:
261
+ if (!(i < mutuallyExclusive.length)) {
262
+ _context4.next = 24;
263
+ break;
264
+ }
265
+ a = existingAction(mutuallyExclusive[i]);
266
+ if (!a) {
267
+ _context4.next = 21;
268
+ break;
269
+ }
270
+ _context4.next = 20;
271
+ return deleteThingThen(a);
272
+ case 20:
273
+ // but how refresh? refreshTree the parent?
274
+ dirty = true;
275
+ case 21:
276
+ i++;
277
+ _context4.next = 15;
278
+ break;
279
+ case 24:
280
+ if (dirty) {
281
+ // widgets.refreshTree(button.parentNode) // requires them all to be immediate siblings
282
+ widgets.refreshTree(messageRow); // requires them all to be immediate siblings
283
+ }
284
+ case 25:
285
+ case "end":
286
+ return _context4.stop();
287
+ }
288
+ }, _callee4);
289
+ }));
290
+ return function (_x11) {
291
+ return _ref.apply(this, arguments);
292
+ };
293
+ }());
294
+ function existingAction(actionClass) {
295
+ var actions = _solidLogic.store.each(null, ns.schema('agent'), context.me, doc).filter(function (x) {
296
+ return _solidLogic.store.holds(x, ns.rdf('type'), actionClass, doc);
297
+ }).filter(function (x) {
298
+ return _solidLogic.store.holds(x, ns.schema('target'), target, doc);
299
+ });
300
+ return actions.length ? actions[0] : null;
138
301
  }
139
- _context2.prev = 6;
140
- _context2.next = 9;
141
- return channelObject.deleteMessage(message);
142
- case 9:
143
- _context2.next = 18;
144
- break;
145
- case 11:
146
- _context2.prev = 11;
147
- _context2.t0 = _context2["catch"](6);
148
- msg = 'Error deleting messaage ' + _context2.t0;
149
- debug.warn(msg);
150
- alert(msg);
151
- area = userContext.statusArea || messageRow.parentNode;
152
- area.appendChild(widgets.errorMessageBlock(dom, msg));
153
- case 18:
154
- messageRow.parentNode.removeChild(messageRow);
155
- _context2.next = 22;
156
- break;
157
- case 21:
158
- alert('You can\'t delete the message, you are not logged in as the author, ' + author);
159
- case 22:
160
- closeToolbar();
161
- case 23:
162
- case "end":
163
- return _context2.stop();
164
- }
165
- }, _callee2, null, [[6, 11]]);
166
- }));
167
- return _deleteMessage.apply(this, arguments);
168
- }
169
- function editMessage(_x) {
170
- return _editMessage.apply(this, arguments);
171
- } // alain TODO allow chat owner to fully delete message + sentiments and replacing messages
172
- function _editMessage() {
173
- _editMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(messageRow) {
174
- return _regenerator["default"].wrap(function _callee3$(_context3) {
175
- while (1) switch (_context3.prev = _context3.next) {
176
- case 0:
177
- if (me.value === _solidLogic.store.any(message, ns.foaf('maker')).value) {
178
- closeToolbar(); // edit is a one-off action
179
- (0, _message.switchToEditor)(messageRow, message, channelObject, userContext);
302
+ function refresh() {
303
+ action = existingAction(actionClass);
304
+ setColor();
180
305
  }
181
- case 1:
182
- case "end":
183
- return _context3.stop();
184
- }
185
- }, _callee3);
186
- }));
187
- return _editMessage.apply(this, arguments);
188
- }
189
- var div = dom.createElement('div');
190
- // is message deleted ?
191
- if ((0, _chatLogic.mostRecentVersion)(message).value === ns.schema('dateDeleted').value) return div;
192
- function closeToolbar() {
193
- div.parentElement.parentElement.removeChild(div.parentElement); // remive the TR
194
- }
195
- function deleteThingThen(_x2) {
196
- return _deleteThingThen.apply(this, arguments);
197
- } // Things only the original author can do
198
- function _deleteThingThen() {
199
- _deleteThingThen = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(x) {
200
- return _regenerator["default"].wrap(function _callee4$(_context4) {
201
- while (1) switch (_context4.prev = _context4.next) {
202
- case 0:
203
- _context4.next = 2;
204
- return _solidLogic.store.updater.update(_solidLogic.store.connectedStatements(x), []);
205
- case 2:
206
- case "end":
207
- return _context4.stop();
208
- }
209
- }, _callee4);
210
- }));
211
- return _deleteThingThen.apply(this, arguments);
212
- }
213
- var me = _solidLogic.authn.currentUser(); // If already logged on
214
- if (me && _solidLogic.store.holds(message, ns.foaf('maker'), me)) {
215
- // button to delete the message
216
- div.appendChild(widgets.deleteButtonWithCheck(dom, div, 'message', deleteMessage));
217
- // button to edit the message
218
- div.appendChild(widgets.button(dom, _iconBase.icons.iconBase + PENCIL_ICON, 'edit', function () {
219
- return editMessage(messageRow);
220
- }));
221
- } // if mine
222
- // Things anyone can do if they have a bookmark list async
223
- /*
224
- var bookmarkButton = await bookmarks.renderBookmarksButton(userContext)
225
- if (bookmarkButton) {
226
- div.appendChild(bookmarkButton)
227
- }
228
- */
229
- // Things anyone can do if they have a bookmark list
306
+ var action;
307
+ button.refresh = refresh; // If the file changes, refresh live
308
+ refresh();
309
+ return button;
310
+ };
311
+ _deleteThingThen = function _deleteThingThen3() {
312
+ _deleteThingThen = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(x) {
313
+ return _regenerator["default"].wrap(function _callee9$(_context9) {
314
+ while (1) switch (_context9.prev = _context9.next) {
315
+ case 0:
316
+ _context9.next = 2;
317
+ return _solidLogic.store.updater.update(_solidLogic.store.connectedStatements(x), []);
318
+ case 2:
319
+ case "end":
320
+ return _context9.stop();
321
+ }
322
+ }, _callee9);
323
+ }));
324
+ return _deleteThingThen.apply(this, arguments);
325
+ };
326
+ deleteThingThen = function _deleteThingThen2(_x10) {
327
+ return _deleteThingThen.apply(this, arguments);
328
+ };
329
+ closeToolbar = function _closeToolbar() {
330
+ div.parentElement.parentElement.removeChild(div.parentElement); // remive the TR
331
+ };
332
+ _replyInThread = function _replyInThread3() {
333
+ _replyInThread = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
334
+ var thread, options;
335
+ return _regenerator["default"].wrap(function _callee8$(_context8) {
336
+ while (1) switch (_context8.prev = _context8.next) {
337
+ case 0:
338
+ _context8.next = 2;
339
+ return channelObject.createThread(message);
340
+ case 2:
341
+ thread = _context8.sent;
342
+ options = userContext.chatOptions;
343
+ if (options) {
344
+ _context8.next = 6;
345
+ break;
346
+ }
347
+ throw new Error('replyInThread: missing options');
348
+ case 6:
349
+ options.showThread(thread, options);
350
+ closeToolbar(); // a one-off action
351
+ case 8:
352
+ case "end":
353
+ return _context8.stop();
354
+ }
355
+ }, _callee8);
356
+ }));
357
+ return _replyInThread.apply(this, arguments);
358
+ };
359
+ replyInThread = function _replyInThread2() {
360
+ return _replyInThread.apply(this, arguments);
361
+ };
362
+ _editMessage = function _editMessage3() {
363
+ _editMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(messageRow) {
364
+ return _regenerator["default"].wrap(function _callee7$(_context7) {
365
+ while (1) switch (_context7.prev = _context7.next) {
366
+ case 0:
367
+ if (!(me.value === _solidLogic.store.any(message, ns.foaf('maker')).value)) {
368
+ _context7.next = 4;
369
+ break;
370
+ }
371
+ closeToolbar(); // edit is a one-off action
372
+ _context7.next = 4;
373
+ return (0, _message.switchToEditor)(messageRow, message, channelObject, userContext);
374
+ case 4:
375
+ case "end":
376
+ return _context7.stop();
377
+ }
378
+ }, _callee7);
379
+ }));
380
+ return _editMessage.apply(this, arguments);
381
+ };
382
+ editMessage = function _editMessage2(_x9) {
383
+ return _editMessage.apply(this, arguments);
384
+ };
385
+ _deleteMessage = function _deleteMessage3() {
386
+ _deleteMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
387
+ var author, msg, area;
388
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
389
+ while (1) switch (_context6.prev = _context6.next) {
390
+ case 0:
391
+ author = _solidLogic.store.any(message, ns.foaf('maker'));
392
+ if (me) {
393
+ _context6.next = 5;
394
+ break;
395
+ }
396
+ alert('You can\'t delete the message, you are not logged in.');
397
+ _context6.next = 22;
398
+ break;
399
+ case 5:
400
+ if (!me.sameTerm(author)) {
401
+ _context6.next = 21;
402
+ break;
403
+ }
404
+ _context6.prev = 6;
405
+ _context6.next = 9;
406
+ return channelObject.deleteMessage(message);
407
+ case 9:
408
+ _context6.next = 18;
409
+ break;
410
+ case 11:
411
+ _context6.prev = 11;
412
+ _context6.t0 = _context6["catch"](6);
413
+ msg = 'Error deleting messaage ' + _context6.t0;
414
+ debug.warn(msg);
415
+ alert(msg);
416
+ area = userContext.statusArea || messageRow.parentNode;
417
+ area.appendChild(widgets.errorMessageBlock(dom, msg));
418
+ case 18:
419
+ messageRow.parentNode.removeChild(messageRow);
420
+ _context6.next = 22;
421
+ break;
422
+ case 21:
423
+ alert('You can\'t delete the message, you are not logged in as the author, ' + author);
424
+ case 22:
425
+ closeToolbar();
426
+ case 23:
427
+ case "end":
428
+ return _context6.stop();
429
+ }
430
+ }, _callee6, null, [[6, 11]]);
431
+ }));
432
+ return _deleteMessage.apply(this, arguments);
433
+ };
434
+ deleteMessage = function _deleteMessage2() {
435
+ return _deleteMessage.apply(this, arguments);
436
+ };
437
+ // alain: TODO allow chat owner to fully delete message + sentiments and replacing messages
438
+ div = dom.createElement('div'); // is message deleted ?
439
+ _context10.next = 13;
440
+ return (0, _chatLogic.mostRecentVersion)(message).value;
441
+ case 13:
442
+ _context10.t0 = _context10.sent;
443
+ _context10.t1 = ns.schema('dateDeleted').value;
444
+ if (!(_context10.t0 === _context10.t1)) {
445
+ _context10.next = 17;
446
+ break;
447
+ }
448
+ return _context10.abrupt("return", div);
449
+ case 17:
450
+ // Things only the original author can do
451
+ me = _solidLogic.authn.currentUser(); // If already logged on
452
+ if (me && _solidLogic.store.holds(message, ns.foaf('maker'), me)) {
453
+ // button to delete the message
454
+ div.appendChild(widgets.deleteButtonWithCheck(dom, div, 'message', deleteMessage));
455
+ // button to edit the message
456
+ div.appendChild(widgets.button(dom, _iconBase.icons.iconBase + PENCIL_ICON, 'edit', function () {
457
+ return editMessage(messageRow);
458
+ }));
459
+ } // if mine
460
+ // Things anyone can do if they have a bookmark list async
461
+ /*
462
+ var bookmarkButton = await bookmarks.renderBookmarksButton(userContext)
463
+ if (bookmarkButton) {
464
+ div.appendChild(bookmarkButton)
465
+ }
466
+ */
467
+ // Things anyone can do if they have a bookmark list
230
468
 
231
- (0, _bookmarks.renderBookmarksButton)(userContext).then(function (bookmarkButton) {
232
- if (bookmarkButton) div.appendChild(bookmarkButton);
233
- });
469
+ (0, _bookmarks.renderBookmarksButton)(userContext).then(function (bookmarkButton) {
470
+ if (bookmarkButton) div.appendChild(bookmarkButton);
471
+ });
234
472
 
235
- /** Button to allow user to express a sentiment (like, endorse, etc) about a target
236
- *
237
- * @param context {Object} - Provide dom and me
238
- * @param target {NamedNode} - The thing the user expresses an opnion about
239
- * @param icon {uristring} - The icon to be used for the button
240
- * @param actionClass {NamedNode} - The RDF class - typically a subclass of schema:Action
241
- * @param doc - {NamedNode} - the Solid document iunto which the data should be written
242
- * @param mutuallyExclusive {Array<NamedNode>} - Any RDF classes of sentimentswhich are mutiually exclusive
243
- */
244
- function sentimentButton(context, target, icon, actionClass, doc, mutuallyExclusive) {
245
- function setColor() {
246
- button.style.backgroundColor = action ? 'yellow' : 'white';
247
- }
248
- var button = widgets.button(dom, icon, utils.label(actionClass), /*#__PURE__*/function () {
249
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_event) {
250
- var insertMe, dirty, i, a;
251
- return _regenerator["default"].wrap(function _callee$(_context) {
252
- while (1) switch (_context.prev = _context.next) {
253
- case 0:
254
- if (!action) {
255
- _context.next = 7;
256
- break;
257
- }
258
- _context.next = 3;
259
- return deleteThingThen(action);
260
- case 3:
261
- action = null;
262
- setColor();
263
- _context.next = 25;
264
- break;
265
- case 7:
266
- // no action
267
- action = widgets.newThing(doc);
268
- insertMe = [rdf.st(action, ns.schema('agent'), context.me, doc), rdf.st(action, ns.rdf('type'), actionClass, doc), rdf.st(action, ns.schema('target'), target, doc)];
269
- _context.next = 11;
270
- return _solidLogic.store.updater.update([], insertMe);
271
- case 11:
272
- setColor();
273
- if (!mutuallyExclusive) {
274
- _context.next = 25;
275
- break;
276
- }
277
- // Delete incompative sentiments
278
- dirty = false;
279
- i = 0;
280
- case 15:
281
- if (!(i < mutuallyExclusive.length)) {
282
- _context.next = 24;
283
- break;
284
- }
285
- a = existingAction(mutuallyExclusive[i]);
286
- if (!a) {
287
- _context.next = 21;
288
- break;
289
- }
290
- _context.next = 20;
291
- return deleteThingThen(a);
292
- case 20:
293
- // but how refresh? refreshTree the parent?
294
- dirty = true;
295
- case 21:
296
- i++;
297
- _context.next = 15;
298
- break;
299
- case 24:
300
- if (dirty) {
301
- // widgets.refreshTree(button.parentNode) // requires them all to be immediate siblings
302
- widgets.refreshTree(messageRow); // requires them all to be immediate siblings
303
- }
304
- case 25:
305
- case "end":
306
- return _context.stop();
307
- }
308
- }, _callee);
309
- }));
310
- return function (_x3) {
311
- return _ref.apply(this, arguments);
312
- };
313
- }());
314
- function existingAction(actionClass) {
315
- var actions = _solidLogic.store.each(null, ns.schema('agent'), context.me, doc).filter(function (x) {
316
- return _solidLogic.store.holds(x, ns.rdf('type'), actionClass, doc);
317
- }).filter(function (x) {
318
- return _solidLogic.store.holds(x, ns.schema('target'), target, doc);
319
- });
320
- return actions.length ? actions[0] : null;
321
- }
322
- function refresh() {
323
- action = existingAction(actionClass);
324
- setColor();
325
- }
326
- var action;
327
- button.refresh = refresh; // If the file changes, refresh live
328
- refresh();
329
- return button;
330
- }
473
+ /** Button to allow user to express a sentiment (like, endorse, etc) about a target
474
+ *
475
+ * @param context {Object} - Provide dom and me
476
+ * @param target {NamedNode} - The thing the user expresses an opnion about
477
+ * @param icon {uristring} - The icon to be used for the button
478
+ * @param actionClass {NamedNode} - The RDF class - typically a subclass of schema:Action
479
+ * @param doc - {NamedNode} - the Solid document iunto which the data should be written
480
+ * @param mutuallyExclusive {Array<NamedNode>} - Any RDF classes of sentimentswhich are mutiually exclusive
481
+ */
331
482
 
332
- // THUMBS_UP_ICON
333
- // https://schema.org/AgreeAction
334
- me = _solidLogic.authn.currentUser(); // If already logged on
335
- // debug.log('Actions 3' + mostRecentVersion(message).value + ' ' + ns.schema('dateDeleted').value + ' ' + (mostRecentVersion(message).value !== ns.schema('dateDeleted').value))
483
+ // THUMBS_UP_ICON
484
+ // https://schema.org/AgreeAction
485
+ me = _solidLogic.authn.currentUser(); // If already logged on
486
+ _context10.t2 = me;
487
+ if (!_context10.t2) {
488
+ _context10.next = 28;
489
+ break;
490
+ }
491
+ _context10.next = 25;
492
+ return (0, _chatLogic.mostRecentVersion)(message).value;
493
+ case 25:
494
+ _context10.t3 = _context10.sent;
495
+ _context10.t4 = ns.schema('dateDeleted').value;
496
+ _context10.t2 = _context10.t3 !== _context10.t4;
497
+ case 28:
498
+ if (!_context10.t2) {
499
+ _context10.next = 32;
500
+ break;
501
+ }
502
+ context1 = {
503
+ me: me,
504
+ dom: dom,
505
+ div: div
506
+ };
507
+ div.appendChild(sentimentButton(context1, message,
508
+ // @@ TODO use widgets.sentimentButton
509
+ _iconBase.icons.iconBase + THUMBS_UP_ICON, ns.schema('AgreeAction'), message.doc(), [ns.schema('DisagreeAction')]));
510
+ // Thumbs down
511
+ div.appendChild(sentimentButton(context1, message, _iconBase.icons.iconBase + THUMBS_DOWN_ICON, ns.schema('DisagreeAction'), message.doc(), [ns.schema('AgreeAction')]));
512
+ case 32:
513
+ // Reply buttton
336
514
 
337
- if (me && (0, _chatLogic.mostRecentVersion)(message).value !== ns.schema('dateDeleted').value) {
338
- var context1 = {
339
- me: me,
340
- dom: dom,
341
- div: div
342
- };
343
- div.appendChild(sentimentButton(context1, message,
344
- // @@ TODO use widgets.sentimentButton
345
- _iconBase.icons.iconBase + THUMBS_UP_ICON, ns.schema('AgreeAction'), message.doc(), [ns.schema('DisagreeAction')]));
346
- // Thumbs down
347
- div.appendChild(sentimentButton(context1, message, _iconBase.icons.iconBase + THUMBS_DOWN_ICON, ns.schema('DisagreeAction'), message.doc(), [ns.schema('AgreeAction')]));
348
- }
349
- // X button to remove the tool UI itself
350
- var cancelButton = div.appendChild(widgets.cancelButton(dom));
351
- cancelButton.style["float"] = 'right';
352
- cancelButton.firstChild.style.opacity = '0.3';
353
- cancelButton.addEventListener('click', closeToolbar);
354
- return div;
515
+ if (_solidLogic.store.any(message, ns.dct('created'))) {
516
+ // Looks like a messsage? Bar can be used for other things
517
+ div.appendChild(widgets.button(dom, _iconBase.icons.iconBase + REPLY_ICON, 'Reply in thread', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
518
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
519
+ while (1) switch (_context5.prev = _context5.next) {
520
+ case 0:
521
+ _context5.next = 2;
522
+ return replyInThread();
523
+ case 2:
524
+ case "end":
525
+ return _context5.stop();
526
+ }
527
+ }, _callee5);
528
+ }))));
529
+ }
530
+ // X button to remove the tool UI itself
531
+ cancelButton = div.appendChild(widgets.cancelButton(dom));
532
+ cancelButton.style["float"] = 'right';
533
+ cancelButton.firstChild.style.opacity = '0.3';
534
+ cancelButton.addEventListener('click', closeToolbar);
535
+ return _context10.abrupt("return", div);
536
+ case 38:
537
+ case "end":
538
+ return _context10.stop();
539
+ }
540
+ }, _callee10);
541
+ }));
542
+ return _messageToolbar.apply(this, arguments);
355
543
  }
356
544
  //# sourceMappingURL=messageTools.js.map