solid-ui 2.4.28-e3ba3633 → 2.4.28-e5cde855

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