mashlib 1.7.17 → 1.7.18-204bf279

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/dist/mashlib.js CHANGED
@@ -13779,7 +13779,7 @@ module.exports = {
13779
13779
  */
13780
13780
  // const DCT = $rdf.Namespace('http://purl.org/dc/terms/')
13781
13781
 
13782
- var preferencesFormText = "\n\n @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.\n @prefix solid: <http://www.w3.org/ns/solid/terms#>.\n @prefix ui: <http://www.w3.org/ns/ui#>.\n @prefix : <#>.\n\n :this\n <http://purl.org/dc/elements/1.1/title> \"Chat preferences\" ;\n a ui:Form ;\n ui:part :colorizeByAuthor, :expandImagesInline, :newestFirst, :inlineImageHeightEms;\n ui:parts ( :colorizeByAuthor :expandImagesInline :newestFirst :inlineImageHeightEms ).\n\n:colorizeByAuthor a ui:TristateField; ui:property solid:colorizeByAuthor;\n ui:label \"Color user input by user\".\n:expandImagesInline a ui:TristateField; ui:property solid:expandImagesInline;\n ui:label \"Expand image URLs inline\".\n:newestFirst a ui:TristateField; ui:property solid:newestFirst;\n ui:label \"Newest messages at the top\".\n\n:inlineImageHeightEms a ui:IntegerField; ui:property solid:inlineImageHeightEms;\n ui:label \"Inline image height (lines)\".\n\n";
13782
+ var preferencesFormText = "\n @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.\n @prefix solid: <http://www.w3.org/ns/solid/terms#>.\n @prefix ui: <http://www.w3.org/ns/ui#>.\n @prefix : <#>.\n\n :this\n <http://purl.org/dc/elements/1.1/title> \"Chat preferences\" ;\n a ui:Form ;\n ui:parts ( :colorizeByAuthor :expandImagesInline :newestFirst :inlineImageHeightEms\n :shiftEnterSendsMessage :authorDateOnLeft :showDeletedMessages).\n\n :colorizeByAuthor a ui:TristateField; ui:property solid:colorizeByAuthor;\n ui:label \"Color user input by user\".\n\n :expandImagesInline a ui:TristateField; ui:property solid:expandImagesInline;\n ui:label \"Expand image URLs inline\".\n\n :newestFirst a ui:TristateField; ui:property solid:newestFirst;\n ui:label \"Newest messages at the top\".\n\n :inlineImageHeightEms a ui:IntegerField; ui:property solid:inlineImageHeightEms;\n ui:label \"Inline image height (lines)\".\n\n :shiftEnterSendsMessage a ui:TristateField; ui:property solid:shiftEnterSendsMessage;\n ui:label \"Shift-Enter sends message\".\n\n :authorDateOnLeft a ui:TristateField; ui:property solid:authorDateOnLeft;\n ui:label \"Author & date of message on left\".\n\n :showDeletedMessages a ui:TristateField; ui:property solid:showDeletedMessages;\n ui:label \"Show placeholders for deleted messages\".\n";
13783
13783
  var preferencesForm = kb.sym('https://solid.github.io/solid-panes/longCharPane/preferencesForm.ttl#this');
13784
13784
  var preferencesFormDoc = preferencesForm.doc();
13785
13785
 
@@ -121963,7 +121963,7 @@ Object.defineProperty(exports, "__esModule", {
121963
121963
  });
121964
121964
  exports["default"] = void 0;
121965
121965
  var _default = {
121966
- buildTime: '2022-01-28T10:16:20Z',
121966
+ buildTime: '2022-01-29T08:00:13Z',
121967
121967
  commit: 'ad1ef0272c97b0830f9cb8d74ab8d42af173bcc1',
121968
121968
  npmInfo: {
121969
121969
  'solid-panes': '3.5.15',
@@ -127234,7 +127234,6 @@ var UI = {
127234
127234
  var $rdf = UI.rdf;
127235
127235
  var BOOK = $rdf.Namespace('http://www.w3.org/2002/01/bookmark#');
127236
127236
  var BOOKMARK_ICON = 'noun_45961.svg';
127237
- var kb = _logic.store;
127238
127237
  var label = utils.label;
127239
127238
  var dom = window.document || null;
127240
127239
  /** Create a resource if it really does not exist
@@ -127245,19 +127244,20 @@ var dom = window.document || null;
127245
127244
 
127246
127245
  function createIfNotExists(doc) {
127247
127246
  return new Promise(function (resolve, reject) {
127248
- kb.fetcher.load(doc).then(function (response) {
127249
- debug.log('createIfNotExists doc exists, all good ' + doc); // kb.fetcher.webOperation('HEAD', doc.uri).then(response => {
127247
+ _logic.store.fetcher.load(doc).then(function (response) {
127248
+ debug.log('createIfNotExists doc exists, all good ' + doc); // store.fetcher.webOperation('HEAD', doc.uri).then(response => {
127250
127249
 
127251
127250
  resolve(response);
127252
127251
  }, function (err) {
127253
127252
  if (err.response.status === 404) {
127254
127253
  debug.log('createIfNotExists doc does NOT exist, will create... ' + doc);
127255
- kb.fetcher.webOperation('PUT', doc.uri, {
127254
+
127255
+ _logic.store.fetcher.webOperation('PUT', doc.uri, {
127256
127256
  data: '',
127257
127257
  contentType: 'text/turtle'
127258
127258
  }).then(function (response) {
127259
127259
  // fetcher.requested[doc.uri] = 'done' // do not need to read ?? but no headers
127260
- delete kb.fetcher.requested[doc.uri]; // delete cached 404 error
127260
+ delete _logic.store.fetcher.requested[doc.uri]; // delete cached 404 error
127261
127261
 
127262
127262
  debug.log('createIfNotExists doc created ok ' + doc);
127263
127263
  resolve(response);
@@ -127276,13 +127276,14 @@ function createIfNotExists(doc) {
127276
127276
 
127277
127277
  function updatePromise(del, ins) {
127278
127278
  return new Promise(function (resolve, reject) {
127279
- kb.updater.update(del, ins, function (uri, ok, errorBody) {
127279
+ _logic.store.updater.update(del, ins, function (uri, ok, errorBody) {
127280
127280
  if (!ok) {
127281
127281
  reject(new Error(errorBody));
127282
127282
  } else {
127283
127283
  resolve();
127284
127284
  }
127285
127285
  }); // callback
127286
+
127286
127287
  }); // promise
127287
127288
  } // export findBookmarkDocument,
127288
127289
 
@@ -127411,8 +127412,8 @@ function _addBookmark() {
127411
127412
  throw new Error('Must be logged on to add Bookmark');
127412
127413
 
127413
127414
  case 4:
127414
- author = kb.any(target, ns.foaf('maker'));
127415
- title = label(author) + ': ' + kb.anyValue(target, ns.sioc('content')).slice(0, 80); // @@ add chat title too?
127415
+ author = _logic.store.any(target, ns.foaf('maker'));
127416
+ title = label(author) + ': ' + _logic.store.anyValue(target, ns.sioc('content')).slice(0, 80); // @@ add chat title too?
127416
127417
 
127417
127418
  bookmarkDoc = context.bookmarkDocument;
127418
127419
  bookmark = UI.widgets.newThing(bookmarkDoc, title);
@@ -127457,10 +127458,10 @@ function _toggleBookmark() {
127457
127458
  switch (_context3.prev = _context3.next) {
127458
127459
  case 0:
127459
127460
  _context3.next = 2;
127460
- return kb.fetcher.load(userContext.bookmarkDocument);
127461
+ return _logic.store.fetcher.load(userContext.bookmarkDocument);
127461
127462
 
127462
127463
  case 2:
127463
- bookmarks = kb.each(null, BOOK('recalls'), target, userContext.bookmarkDocument);
127464
+ bookmarks = _logic.store.each(null, BOOK('recalls'), target, userContext.bookmarkDocument);
127464
127465
 
127465
127466
  if (!bookmarks.length) {
127466
127467
  _context3.next = 24;
@@ -127485,7 +127486,7 @@ function _toggleBookmark() {
127485
127486
 
127486
127487
  _context3.prev = 8;
127487
127488
  _context3.next = 11;
127488
- return updatePromise(kb.connectedStatements(bookmarks[i]), []);
127489
+ return updatePromise(_logic.store.connectedStatements(bookmarks[i]), []);
127489
127490
 
127490
127491
  case 11:
127491
127492
  bookmarkButton.style.backgroundColor = 'white';
@@ -127547,10 +127548,10 @@ function _renderBookmarksButton() {
127547
127548
  switch (_context4.prev = _context4.next) {
127548
127549
  case 0:
127549
127550
  _context4.next = 2;
127550
- return kb.fetcher.load(userContext.bookmarkDocument);
127551
+ return _logic.store.fetcher.load(userContext.bookmarkDocument);
127551
127552
 
127552
127553
  case 2:
127553
- bookmarked = kb.any(null, BOOK('recalls'), bookmarkButton.target, userContext.bookmarkDocument);
127554
+ bookmarked = _logic.store.any(null, BOOK('recalls'), bookmarkButton.target, userContext.bookmarkDocument);
127554
127555
  bookmarkButton.style = UI.style.buttonStyle;
127555
127556
  if (bookmarked) bookmarkButton.style.backgroundColor = 'yellow';
127556
127557
 
@@ -127596,6 +127597,357 @@ function _renderBookmarksButton() {
127596
127597
 
127597
127598
  /***/ }),
127598
127599
 
127600
+ /***/ "./node_modules/solid-ui/lib/chat/chatLogic.js":
127601
+ /*!*****************************************************!*\
127602
+ !*** ./node_modules/solid-ui/lib/chat/chatLogic.js ***!
127603
+ \*****************************************************/
127604
+ /*! no static exports found */
127605
+ /***/ (function(module, exports, __webpack_require__) {
127606
+
127607
+ "use strict";
127608
+
127609
+
127610
+ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/solid-ui/node_modules/@babel/runtime/helpers/interopRequireDefault.js");
127611
+
127612
+ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/solid-ui/node_modules/@babel/runtime/helpers/typeof.js");
127613
+
127614
+ Object.defineProperty(exports, "__esModule", {
127615
+ value: true
127616
+ });
127617
+ exports.ChatChannel = void 0;
127618
+ exports._createIfNotExists = _createIfNotExists;
127619
+ exports.isDeleted = isDeleted;
127620
+ exports.isHidden = isHidden;
127621
+ exports.isReplaced = isReplaced;
127622
+ exports.mostRecentVersion = mostRecentVersion;
127623
+ exports.nick = nick;
127624
+ exports.originalVersion = originalVersion;
127625
+
127626
+ var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/solid-ui/node_modules/@babel/runtime/regenerator/index.js"));
127627
+
127628
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/solid-ui/node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
127629
+
127630
+ var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/solid-ui/node_modules/@babel/runtime/helpers/classCallCheck.js"));
127631
+
127632
+ var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/solid-ui/node_modules/@babel/runtime/helpers/createClass.js"));
127633
+
127634
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./node_modules/solid-ui/lib/debug.js"));
127635
+
127636
+ var _index = __webpack_require__(/*! ../authn/index */ "./node_modules/solid-ui/lib/authn/index.js");
127637
+
127638
+ var _dateFolder = __webpack_require__(/*! ./dateFolder */ "./node_modules/solid-ui/lib/chat/dateFolder.js");
127639
+
127640
+ var _logic = __webpack_require__(/*! ../logic */ "./node_modules/solid-ui/lib/logic.js");
127641
+
127642
+ var ns = _interopRequireWildcard(__webpack_require__(/*! ../ns */ "./node_modules/solid-ui/lib/ns.js"));
127643
+
127644
+ var $rdf = _interopRequireWildcard(__webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js"));
127645
+
127646
+ var utils = _interopRequireWildcard(__webpack_require__(/*! ../utils */ "./node_modules/solid-ui/lib/utils/index.js"));
127647
+
127648
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
127649
+
127650
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
127651
+
127652
+ /**
127653
+ * Contains the [[ChatChannel]] class and logic for Solid Chat
127654
+ * @packageDocumentation
127655
+ */
127656
+ // pull in first avoid cross-refs
127657
+
127658
+ /* The Solid logic for a 'LongChat'
127659
+ */
127660
+
127661
+ /**
127662
+ * Common code for a chat (discussion area of messages about something)
127663
+ * This version runs over a series of files for different time periods
127664
+ *
127665
+ * Parameters for the whole chat like its title are stored on
127666
+ * index.ttl#this and the chats messages are stored in YYYY/MM/DD/chat.ttl
127667
+ *
127668
+ */
127669
+ var ChatChannel = /*#__PURE__*/function () {
127670
+ function ChatChannel(channel, options) {
127671
+ (0, _classCallCheck2["default"])(this, ChatChannel);
127672
+ this.channel = channel;
127673
+ this.channelRoot = channel.doc();
127674
+ this.options = options;
127675
+ this.dateFolder = new _dateFolder.DateFolder(this.channelRoot, 'chat.ttl');
127676
+ this.div = null; // : HTMLElement
127677
+ }
127678
+ /* Store a new message in the web,
127679
+ */
127680
+
127681
+
127682
+ (0, _createClass2["default"])(ChatChannel, [{
127683
+ key: "createMessage",
127684
+ value: function () {
127685
+ var _createMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(text) {
127686
+ return _regenerator["default"].wrap(function _callee$(_context) {
127687
+ while (1) {
127688
+ switch (_context.prev = _context.next) {
127689
+ case 0:
127690
+ return _context.abrupt("return", this.updateMessage(text));
127691
+
127692
+ case 1:
127693
+ case "end":
127694
+ return _context.stop();
127695
+ }
127696
+ }
127697
+ }, _callee, this);
127698
+ }));
127699
+
127700
+ function createMessage(_x) {
127701
+ return _createMessage.apply(this, arguments);
127702
+ }
127703
+
127704
+ return createMessage;
127705
+ }()
127706
+ /* Store a new message in the web,
127707
+ as a replacement for an existing one.
127708
+ The old one iis left, and the two are linked
127709
+ */
127710
+
127711
+ }, {
127712
+ key: "updateMessage",
127713
+ value: function () {
127714
+ var _updateMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(text) {
127715
+ var oldMsg,
127716
+ deleteIt,
127717
+ sts,
127718
+ now,
127719
+ timestamp,
127720
+ dateStamp,
127721
+ chatDocument,
127722
+ message,
127723
+ me,
127724
+ msg,
127725
+ _args2 = arguments;
127726
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
127727
+ while (1) {
127728
+ switch (_context2.prev = _context2.next) {
127729
+ case 0:
127730
+ oldMsg = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : null;
127731
+ deleteIt = _args2.length > 2 ? _args2[2] : undefined;
127732
+ sts = [];
127733
+ now = new Date();
127734
+ timestamp = '' + now.getTime();
127735
+ dateStamp = $rdf.term(now);
127736
+ chatDocument = oldMsg ? oldMsg.doc() : this.dateFolder.leafDocumentFromDate(now);
127737
+ message = _logic.store.sym(chatDocument.uri + '#' + 'Msg' + timestamp); // const content = store.literal(text)
127738
+
127739
+ me = _index.authn.currentUser(); // If already logged on
127740
+
127741
+ if (oldMsg) {
127742
+ // edit message replaces old one
127743
+ sts.push($rdf.st(mostRecentVersion(oldMsg), ns.dct('isReplacedBy'), message, chatDocument));
127744
+
127745
+ if (deleteIt) {
127746
+ sts.push($rdf.st(message, ns.schema('dateDeleted'), dateStamp, chatDocument));
127747
+ }
127748
+ } else {
127749
+ // link new message to channel
127750
+ sts.push($rdf.st(this.channel, ns.wf('message'), message, chatDocument));
127751
+ }
127752
+
127753
+ sts.push($rdf.st(message, ns.sioc('content'), _logic.store.literal(text), chatDocument));
127754
+ sts.push($rdf.st(message, ns.dct('created'), dateStamp, chatDocument));
127755
+
127756
+ if (me) {
127757
+ sts.push($rdf.st(message, ns.foaf('maker'), me, chatDocument));
127758
+ }
127759
+
127760
+ _context2.prev = 13;
127761
+ _context2.next = 16;
127762
+ return _logic.store.updater.update([], sts);
127763
+
127764
+ case 16:
127765
+ _context2.next = 24;
127766
+ break;
127767
+
127768
+ case 18:
127769
+ _context2.prev = 18;
127770
+ _context2.t0 = _context2["catch"](13);
127771
+ msg = 'Error saving chat message: ' + _context2.t0;
127772
+ debug.warn(msg);
127773
+ alert(msg);
127774
+ throw new Error(msg);
127775
+
127776
+ case 24:
127777
+ return _context2.abrupt("return", message);
127778
+
127779
+ case 25:
127780
+ case "end":
127781
+ return _context2.stop();
127782
+ }
127783
+ }
127784
+ }, _callee2, this, [[13, 18]]);
127785
+ }));
127786
+
127787
+ function updateMessage(_x2) {
127788
+ return _updateMessage.apply(this, arguments);
127789
+ }
127790
+
127791
+ return updateMessage;
127792
+ }()
127793
+ /* Mark a message as deleted
127794
+ * Wee add a new version of the message,m witha deletion flag (deletion date)
127795
+ * so that the deletion can be revoked by adding another non-deleted update
127796
+ */
127797
+
127798
+ }, {
127799
+ key: "deleteMessage",
127800
+ value: function () {
127801
+ var _deleteMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(message) {
127802
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
127803
+ while (1) {
127804
+ switch (_context3.prev = _context3.next) {
127805
+ case 0:
127806
+ return _context3.abrupt("return", this.updateMessage('(message deleted)', message, true));
127807
+
127808
+ case 1:
127809
+ case "end":
127810
+ return _context3.stop();
127811
+ }
127812
+ }
127813
+ }, _callee3, this);
127814
+ }));
127815
+
127816
+ function deleteMessage(_x3) {
127817
+ return _deleteMessage.apply(this, arguments);
127818
+ }
127819
+
127820
+ return deleteMessage;
127821
+ }()
127822
+ }]);
127823
+ return ChatChannel;
127824
+ }(); // class ChatChannel
127825
+
127826
+
127827
+ exports.ChatChannel = ChatChannel;
127828
+
127829
+ function originalVersion(message) {
127830
+ var msg = message;
127831
+
127832
+ while (msg) {
127833
+ message = msg;
127834
+ msg = _logic.store.any(null, ns.dct('isReplacedBy'), message, message.doc());
127835
+ }
127836
+
127837
+ return message;
127838
+ }
127839
+
127840
+ function mostRecentVersion(message) {
127841
+ var msg = message;
127842
+
127843
+ while (msg) {
127844
+ message = msg;
127845
+ msg = _logic.store.any(message, ns.dct('isReplacedBy'), null, message.doc());
127846
+ }
127847
+
127848
+ return message;
127849
+ }
127850
+
127851
+ function isDeleted(message) {
127852
+ return _logic.store.holds(message, ns.schema('dateDeleted'), null, message.doc());
127853
+ }
127854
+
127855
+ function isReplaced(message) {
127856
+ return _logic.store.holds(message, ns.dct('isReplacedBy'), null, message.doc());
127857
+ }
127858
+
127859
+ function isHidden(message) {
127860
+ return this.isDeleted(message) || this.isReplaced(message);
127861
+ } // A Nickname for a person
127862
+
127863
+
127864
+ function nick(person) {
127865
+ var s = _logic.store.any(person, ns.foaf('nick'));
127866
+
127867
+ if (s) return '' + s.value;
127868
+ return '' + utils.label(person);
127869
+ }
127870
+
127871
+ function _createIfNotExists(_x4) {
127872
+ return _createIfNotExists2.apply(this, arguments);
127873
+ } // ends
127874
+
127875
+
127876
+ function _createIfNotExists2() {
127877
+ _createIfNotExists2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(doc) {
127878
+ var contentType,
127879
+ data,
127880
+ response,
127881
+ _args4 = arguments;
127882
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
127883
+ while (1) {
127884
+ switch (_context4.prev = _context4.next) {
127885
+ case 0:
127886
+ contentType = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : 'text/turtle';
127887
+ data = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : '';
127888
+ _context4.prev = 2;
127889
+ _context4.next = 5;
127890
+ return _logic.store.fetcher.load(doc);
127891
+
127892
+ case 5:
127893
+ response = _context4.sent;
127894
+ _context4.next = 28;
127895
+ break;
127896
+
127897
+ case 8:
127898
+ _context4.prev = 8;
127899
+ _context4.t0 = _context4["catch"](2);
127900
+
127901
+ if (!(_context4.t0.response.status === 404)) {
127902
+ _context4.next = 26;
127903
+ break;
127904
+ }
127905
+
127906
+ debug.log('createIfNotExists: doc does NOT exist, will create... ' + doc);
127907
+ _context4.prev = 12;
127908
+ _context4.next = 15;
127909
+ return _logic.store.fetcher.webOperation('PUT', doc.uri, {
127910
+ data: data,
127911
+ contentType: contentType
127912
+ });
127913
+
127914
+ case 15:
127915
+ response = _context4.sent;
127916
+ _context4.next = 22;
127917
+ break;
127918
+
127919
+ case 18:
127920
+ _context4.prev = 18;
127921
+ _context4.t1 = _context4["catch"](12);
127922
+ debug.log('createIfNotExists doc FAILED: ' + doc + ': ' + _context4.t1);
127923
+ throw _context4.t1;
127924
+
127925
+ case 22:
127926
+ delete _logic.store.fetcher.requested[doc.uri]; // delete cached 404 error
127927
+ // debug.log('createIfNotExists doc created ok ' + doc)
127928
+
127929
+ return _context4.abrupt("return", response);
127930
+
127931
+ case 26:
127932
+ debug.log('createIfNotExists doc load error NOT 404: ' + doc + ': ' + _context4.t0);
127933
+ throw _context4.t0;
127934
+
127935
+ case 28:
127936
+ return _context4.abrupt("return", response);
127937
+
127938
+ case 29:
127939
+ case "end":
127940
+ return _context4.stop();
127941
+ }
127942
+ }
127943
+ }, _callee4, null, [[2, 8], [12, 18]]);
127944
+ }));
127945
+ return _createIfNotExists2.apply(this, arguments);
127946
+ }
127947
+ //# sourceMappingURL=chatLogic.js.map
127948
+
127949
+ /***/ }),
127950
+
127599
127951
  /***/ "./node_modules/solid-ui/lib/chat/dateFolder.js":
127600
127952
  /*!******************************************************!*\
127601
127953
  !*** ./node_modules/solid-ui/lib/chat/dateFolder.js ***!
@@ -127637,14 +127989,14 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
127637
127989
 
127638
127990
  /**
127639
127991
  * Contains the [[DateFolder]] class
127640
- * @packageDocumentation
127992
+ * This tracks data stored in dated folders and sub-folders
127993
+ *
127641
127994
  */
127642
127995
  // pull in first avoid cross-refs
127643
- var kb = _logic.store;
127996
+
127644
127997
  /**
127645
127998
  * Track back through the YYYY/MM/DD tree to find the previous/next day
127646
127999
  */
127647
-
127648
128000
  var DateFolder = /*#__PURE__*/function () {
127649
128001
  function DateFolder(rootThing, leafFileName, membershipProperty) {
127650
128002
  (0, _classCallCheck2["default"])(this, DateFolder);
@@ -127668,7 +128020,7 @@ var DateFolder = /*#__PURE__*/function () {
127668
128020
  var path = isoDate.split('T')[0].replace(/-/g, '/'); // Like "2018/05/07"
127669
128021
 
127670
128022
  path = this.root.dir().uri + path + '/' + this.leafFileName;
127671
- return kb.sym(path);
128023
+ return _logic.store.sym(path);
127672
128024
  }
127673
128025
  /* Generate a date object from the leaf file name
127674
128026
  */
@@ -127730,12 +128082,12 @@ var DateFolder = /*#__PURE__*/function () {
127730
128082
  }
127731
128083
 
127732
128084
  _folder = siblings.pop();
127733
- leafDocument = kb.sym(_folder.uri + thisDateFolder.leafFileName);
128085
+ leafDocument = _logic.store.sym(_folder.uri + thisDateFolder.leafFileName);
127734
128086
  _context.next = 10;
127735
- return kb.fetcher.load(leafDocument);
128087
+ return _logic.store.fetcher.load(leafDocument);
127736
128088
 
127737
128089
  case 10:
127738
- if (!(kb.statementsMatching(null, ns.dct('created'), null, leafDocument).length > 0)) {
128090
+ if (!(_logic.store.statementsMatching(null, ns.dct('created'), null, leafDocument).length > 0)) {
127739
128091
  _context.next = 12;
127740
128092
  break;
127741
128093
  }
@@ -127779,10 +128131,10 @@ var DateFolder = /*#__PURE__*/function () {
127779
128131
  // debug.log(' previousPeriod level' + level + ' file ' + file)
127780
128132
  parent = file.dir();
127781
128133
  _context2.next = 7;
127782
- return kb.fetcher.load(parent);
128134
+ return _logic.store.fetcher.load(parent);
127783
128135
 
127784
128136
  case 7:
127785
- siblings = kb.each(parent, ns.ldp('contains'));
128137
+ siblings = _logic.store.each(parent, ns.ldp('contains'));
127786
128138
  siblings = siblings.filter(younger);
127787
128139
  _context2.next = 11;
127788
128140
  return lastNonEmpty(siblings);
@@ -127821,10 +128173,10 @@ var DateFolder = /*#__PURE__*/function () {
127821
128173
 
127822
128174
  case 21:
127823
128175
  _context2.next = 23;
127824
- return kb.fetcher.load(uncle);
128176
+ return _logic.store.fetcher.load(uncle);
127825
128177
 
127826
128178
  case 23:
127827
- cousins = kb.each(uncle, ns.ldp('contains'));
128179
+ cousins = _logic.store.each(uncle, ns.ldp('contains'));
127828
128180
  _context2.next = 26;
127829
128181
  return lastNonEmpty(cousins);
127830
128182
 
@@ -127860,7 +128212,7 @@ var DateFolder = /*#__PURE__*/function () {
127860
128212
  break;
127861
128213
  }
127862
128214
 
127863
- doc = kb.sym(found.uri + this.leafFileName);
128215
+ doc = _logic.store.sym(found.uri + this.leafFileName);
127864
128216
  return _context3.abrupt("return", this.dateFromLeafDocument(doc));
127865
128217
 
127866
128218
  case 10:
@@ -128031,152 +128383,53 @@ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_m
128031
128383
  Object.defineProperty(exports, "__esModule", {
128032
128384
  value: true
128033
128385
  });
128034
- exports.createIfNotExists = createIfNotExists;
128035
128386
  exports.desktopNotification = desktopNotification;
128036
128387
  exports.infiniteMessageArea = infiniteMessageArea;
128388
+ exports.insertMessageIntoTable = insertMessageIntoTable;
128037
128389
 
128038
128390
  var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/solid-ui/node_modules/@babel/runtime/regenerator/index.js"));
128039
128391
 
128040
128392
  var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/solid-ui/node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
128041
128393
 
128042
- var _index = __webpack_require__(/*! ../authn/index */ "./node_modules/solid-ui/lib/authn/index.js");
128043
-
128044
128394
  var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./node_modules/solid-ui/lib/debug.js"));
128045
128395
 
128046
128396
  var _iconBase = __webpack_require__(/*! ../iconBase */ "./node_modules/solid-ui/lib/iconBase.js");
128047
128397
 
128048
128398
  var _logic = __webpack_require__(/*! ../logic */ "./node_modules/solid-ui/lib/logic.js");
128049
128399
 
128050
- var _index2 = __webpack_require__(/*! ../media/index */ "./node_modules/solid-ui/lib/media/index.js");
128051
-
128052
128400
  var ns = _interopRequireWildcard(__webpack_require__(/*! ../ns */ "./node_modules/solid-ui/lib/ns.js"));
128053
128401
 
128054
- var pad = _interopRequireWildcard(__webpack_require__(/*! ../pad */ "./node_modules/solid-ui/lib/pad.js"));
128055
-
128056
- var _dateFolder = __webpack_require__(/*! ./dateFolder */ "./node_modules/solid-ui/lib/chat/dateFolder.js");
128402
+ var _chatLogic = __webpack_require__(/*! ./chatLogic */ "./node_modules/solid-ui/lib/chat/chatLogic.js");
128057
128403
 
128058
128404
  var _message = __webpack_require__(/*! ./message */ "./node_modules/solid-ui/lib/chat/message.js");
128059
128405
 
128060
- var _bookmarks = __webpack_require__(/*! ./bookmarks */ "./node_modules/solid-ui/lib/chat/bookmarks.js");
128061
-
128062
128406
  var $rdf = _interopRequireWildcard(__webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js"));
128063
128407
 
128064
- var style = _interopRequireWildcard(__webpack_require__(/*! ../style */ "./node_modules/solid-ui/lib/style.js"));
128065
-
128066
- var utils = _interopRequireWildcard(__webpack_require__(/*! ../utils */ "./node_modules/solid-ui/lib/utils/index.js"));
128067
-
128068
128408
  var widgets = _interopRequireWildcard(__webpack_require__(/*! ../widgets */ "./node_modules/solid-ui/lib/widgets/index.js"));
128069
128409
 
128070
128410
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
128071
128411
 
128072
128412
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
128073
128413
 
128074
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
128075
-
128076
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
128077
-
128078
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
128079
-
128080
- var UI = {
128081
- authn: _index.authn,
128082
- icons: _iconBase.icons,
128083
- ns: ns,
128084
- media: _index2.media,
128085
- pad: pad,
128086
- $rdf: $rdf,
128087
- store: _logic.store,
128088
- style: style,
128089
- utils: utils,
128090
- widgets: widgets
128091
- };
128092
- /* global alert */
128093
-
128094
- var SERVER_MKDIRP_BUG = false; // Set false timbl 2021-10-31 should be fixed by now
128095
-
128096
- function createIfNotExists(_x) {
128097
- return _createIfNotExists.apply(this, arguments);
128098
- }
128099
-
128100
- function _createIfNotExists() {
128101
- _createIfNotExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(doc) {
128102
- var contentType,
128103
- data,
128104
- fetcher,
128105
- response,
128106
- _args = arguments;
128107
- return _regenerator["default"].wrap(function _callee$(_context) {
128108
- while (1) {
128109
- switch (_context.prev = _context.next) {
128110
- case 0:
128111
- contentType = _args.length > 1 && _args[1] !== undefined ? _args[1] : 'text/turtle';
128112
- data = _args.length > 2 && _args[2] !== undefined ? _args[2] : '';
128113
- fetcher = UI.store.fetcher;
128114
- _context.prev = 3;
128115
- _context.next = 6;
128116
- return fetcher.load(doc);
128117
-
128118
- case 6:
128119
- response = _context.sent;
128120
- _context.next = 29;
128121
- break;
128122
-
128123
- case 9:
128124
- _context.prev = 9;
128125
- _context.t0 = _context["catch"](3);
128126
-
128127
- if (!(_context.t0.response.status === 404)) {
128128
- _context.next = 27;
128129
- break;
128130
- }
128131
-
128132
- debug.log('createIfNotExists: doc does NOT exist, will create... ' + doc);
128133
- _context.prev = 13;
128134
- _context.next = 16;
128135
- return fetcher.webOperation('PUT', doc.uri, {
128136
- data: data,
128137
- contentType: contentType
128138
- });
128139
-
128140
- case 16:
128141
- response = _context.sent;
128142
- _context.next = 23;
128143
- break;
128144
-
128145
- case 19:
128146
- _context.prev = 19;
128147
- _context.t1 = _context["catch"](13);
128148
- debug.log('createIfNotExists doc FAILED: ' + doc + ': ' + _context.t1);
128149
- throw _context.t1;
128150
-
128151
- case 23:
128152
- delete fetcher.requested[doc.uri]; // delete cached 404 error
128153
- // debug.log('createIfNotExists doc created ok ' + doc)
128154
-
128155
- return _context.abrupt("return", response);
128156
-
128157
- case 27:
128158
- debug.log('createIfNotExists doc load error NOT 404: ' + doc + ': ' + _context.t0);
128159
- throw _context.t0;
128160
-
128161
- case 29:
128162
- return _context.abrupt("return", response);
128163
-
128164
- case 30:
128165
- case "end":
128166
- return _context.stop();
128167
- }
128168
- }
128169
- }, _callee, null, [[3, 9], [13, 19]]);
128170
- }));
128171
- return _createIfNotExists.apply(this, arguments);
128172
- }
128173
-
128414
+ /**
128415
+ * Contains the [[infiniteMessageArea]] class
128416
+ * @packageDocumentation
128417
+ */
128418
+ // import { authn } from '../authn/index'
128419
+ // import { media } from '../media/index'
128420
+ // import * as pad from '../pad'
128421
+ // import { DateFolder } from './dateFolder'
128422
+ // import { findBookmarkDocument } from './bookmarks'
128423
+ // pull in first avoid cross-refs
128424
+ // import * as style from '../style'
128425
+ // import * as utils from '../utils'
128426
+ // const UI = { authn, icons, ns, media, pad, $rdf, store, style, utils, widgets }
128174
128427
  function desktopNotification(str) {
128175
128428
  // Let's check if the browser supports notifications
128176
128429
  if (!('Notification' in window)) {
128177
- debug.warn('This browser does not support desktop notification');
128430
+ debug.warn('This browser does no t support desktop notification');
128178
128431
  } else if (Notification.permission === 'granted') {
128179
- // Let's check whether notification permissions have already been granted
128432
+ // Let's check whether notificatio n permissions have already been granted
128180
128433
  // eslint-disable-next-line no-new
128181
128434
  new Notification(str);
128182
128435
  } else if (Notification.permission !== 'denied') {
@@ -128192,33 +128445,84 @@ function desktopNotification(str) {
128192
128445
  // want to be respectful there is no need to bother them any more.
128193
128446
 
128194
128447
  }
128448
+ /**
128449
+ * Renders a chat message inside a `messageTable`
128450
+ */
128451
+
128452
+
128453
+ function insertMessageIntoTable(channelObject, messageTable, message, fresh, options, userContext) {
128454
+ var messageRow = (0, _message.renderMessageRow)(channelObject, message, fresh, options, userContext); // const message = messageRow.AJAR_subject
128455
+
128456
+ if (options.selectedMessage && options.selectedMessage.sameTerm(message)) {
128457
+ messageRow.style.backgroundColor = 'yellow';
128458
+ options.selectedElement = messageRow;
128459
+ messageTable.selectedElement = messageRow;
128460
+ }
128461
+
128462
+ var done = false;
128463
+
128464
+ for (var ele = messageTable.firstChild;; ele = ele.nextSibling) {
128465
+ if (!ele) {
128466
+ // empty
128467
+ break;
128468
+ }
128469
+
128470
+ var newestFirst = options.newestfirst === true;
128471
+ var dateString = messageRow.AJAR_date;
128472
+
128473
+ if (dateString > ele.AJAR_date && newestFirst || dateString < ele.AJAR_date && !newestFirst) {
128474
+ messageTable.insertBefore(messageRow, ele);
128475
+ done = true;
128476
+ break;
128477
+ }
128478
+ }
128479
+
128480
+ if (!done) {
128481
+ messageTable.appendChild(messageRow);
128482
+ }
128483
+ }
128195
128484
  /**
128196
128485
  * Common code for a chat (discussion area of messages about something)
128197
128486
  * This version runs over a series of files for different time periods
128198
128487
  *
128199
128488
  * Parameters for the whole chat like its title are stored on
128200
128489
  * index.ttl#this and the chats messages are stored in YYYY/MM/DD/chat.ttl
128490
+ *
128491
+ * Use to import store as param 2, now ignores it and uses the UI main store
128492
+ *
128493
+ * Options include:
128494
+
128495
+ - shiftEnterSendsMessage: Use shift/enter to send message, Enter to add newline, instead of the reverse.
128496
+ - authorDateOnLeft: Display the author's anme and date of the message in the left column instead of first above the content
128497
+ - selectedMessage: Display one message highlighted with the chat around it
128498
+ - solo: By itelf on a webpage, so user scroll anywhere in the web page scan scroll the chat.
128499
+ - newestFirst: Arrange the chat messages chronologically newest at the top insted of at the bottom
128500
+ - infinite: Use infinite scroll
128501
+ - showDeletedMessages: Show messages which have been delted as "deleted message". Otherwise hide them.
128502
+ - expandImagesInline: If a URI by itself in a message looks like an image URI, replace it with the image
128503
+ - inlineImageHeightEms: The height (in ems) of images expaned from their URIs in the chat.
128504
+
128201
128505
  */
128202
128506
 
128203
128507
 
128204
- function infiniteMessageArea(_x2, _x3, _x4, _x5) {
128508
+ function infiniteMessageArea(_x, _x2, _x3, _x4) {
128205
128509
  return _infiniteMessageArea.apply(this, arguments);
128206
128510
  }
128207
128511
 
128208
128512
  function _infiniteMessageArea() {
128209
- _infiniteMessageArea = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee17(dom, kb, chatChannel, options) {
128210
- var ns, WF, DCT, newestFirst, dateFolder, messageBodyStyle, div, menuButton, statusArea, userContext, me, updater, newMessageForm, syncMessages, addMessage, insertPreviousMessages, _insertPreviousMessages, removePreviousMessages, createMessageTable, _createMessageTable, renderMessageTable, addNewTableIfNewDay, _addNewTableIfNewDay, appendCurrentMessages, _appendCurrentMessages, liveMessageTable, earliest, latest, lock, loadMoreWhereNeeded, _loadMoreWhereNeeded, loadInitialContent, _loadInitialContent;
128513
+ _infiniteMessageArea = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12(dom, wasStore, chatChannel, options) {
128514
+ var syncMessages, addMessage, insertPreviousMessages, _insertPreviousMessages, removePreviousMessages, createMessageTable, _createMessageTable, renderMessageTable, addNewChatDocumentIfNewDay, _addNewChatDocumentIfNewDay, appendCurrentMessages, _appendCurrentMessages, loadMoreWhereNeeded, _loadMoreWhereNeeded, loadInitialContent, _loadInitialContent, newestFirst, channelObject, dateFolder, div, statusArea, userContext, liveMessageTable, earliest, latest, lock;
128211
128515
 
128212
- return _regenerator["default"].wrap(function _callee17$(_context17) {
128516
+ return _regenerator["default"].wrap(function _callee12$(_context12) {
128213
128517
  while (1) {
128214
- switch (_context17.prev = _context17.next) {
128518
+ switch (_context12.prev = _context12.next) {
128215
128519
  case 0:
128216
128520
  _loadInitialContent = function _loadInitialContent3() {
128217
- _loadInitialContent = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee16() {
128521
+ _loadInitialContent = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
128218
128522
  var yank, fixScroll, live, selectedDocument, now, todayDocument, selectedMessageTable, selectedDate;
128219
- return _regenerator["default"].wrap(function _callee16$(_context16) {
128523
+ return _regenerator["default"].wrap(function _callee11$(_context11) {
128220
128524
  while (1) {
128221
- switch (_context16.prev = _context16.next) {
128525
+ switch (_context11.prev = _context11.next) {
128222
128526
  case 0:
128223
128527
  fixScroll = function _fixScroll() {
128224
128528
  if (options.selectedElement) {
@@ -128246,27 +128550,27 @@ function _infiniteMessageArea() {
128246
128550
  }
128247
128551
 
128248
128552
  if (!(options.selectedMessage && !live)) {
128249
- _context16.next = 15;
128553
+ _context11.next = 15;
128250
128554
  break;
128251
128555
  }
128252
128556
 
128253
128557
  selectedDate = dateFolder.dateFromLeafDocument(selectedDocument);
128254
- _context16.next = 7;
128558
+ _context11.next = 7;
128255
128559
  return createMessageTable(selectedDate, live);
128256
128560
 
128257
128561
  case 7:
128258
- selectedMessageTable = _context16.sent;
128562
+ selectedMessageTable = _context11.sent;
128259
128563
  div.appendChild(selectedMessageTable);
128260
128564
  earliest.messageTable = selectedMessageTable;
128261
128565
  latest.messageTable = selectedMessageTable;
128262
128566
  yank();
128263
128567
  setTimeout(yank, 1000); // @@ kludge - restore position distubed by other cHANGES
128264
128568
 
128265
- _context16.next = 19;
128569
+ _context11.next = 19;
128266
128570
  break;
128267
128571
 
128268
128572
  case 15:
128269
- _context16.next = 17;
128573
+ _context11.next = 17;
128270
128574
  return appendCurrentMessages();
128271
128575
 
128272
128576
  case 17:
@@ -128274,7 +128578,7 @@ function _infiniteMessageArea() {
128274
128578
  latest.messageTable = liveMessageTable;
128275
128579
 
128276
128580
  case 19:
128277
- _context16.next = 21;
128581
+ _context11.next = 21;
128278
128582
  return loadMoreWhereNeeded(null, fixScroll);
128279
128583
 
128280
128584
  case 21:
@@ -128286,10 +128590,10 @@ function _infiniteMessageArea() {
128286
128590
 
128287
128591
  case 23:
128288
128592
  case "end":
128289
- return _context16.stop();
128593
+ return _context11.stop();
128290
128594
  }
128291
128595
  }
128292
- }, _callee16);
128596
+ }, _callee11);
128293
128597
  }));
128294
128598
  return _loadInitialContent.apply(this, arguments);
128295
128599
  };
@@ -128299,18 +128603,18 @@ function _infiniteMessageArea() {
128299
128603
  };
128300
128604
 
128301
128605
  _loadMoreWhereNeeded = function _loadMoreWhereNeeded3() {
128302
- _loadMoreWhereNeeded = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee15(event, fixScroll) {
128606
+ _loadMoreWhereNeeded = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(event, fixScroll) {
128303
128607
  var freeze, magicZone, done, scrollBottom, scrollTop;
128304
- return _regenerator["default"].wrap(function _callee15$(_context15) {
128608
+ return _regenerator["default"].wrap(function _callee10$(_context10) {
128305
128609
  while (1) {
128306
- switch (_context15.prev = _context15.next) {
128610
+ switch (_context10.prev = _context10.next) {
128307
128611
  case 0:
128308
128612
  if (!lock) {
128309
- _context15.next = 2;
128613
+ _context10.next = 2;
128310
128614
  break;
128311
128615
  }
128312
128616
 
128313
- return _context15.abrupt("return");
128617
+ return _context10.abrupt("return");
128314
128618
 
128315
128619
  case 2:
128316
128620
  lock = true;
@@ -128320,12 +128624,12 @@ function _infiniteMessageArea() {
128320
128624
 
128321
128625
  case 5:
128322
128626
  if (!(div.scrollTop < magicZone && earliest.messageTable && !earliest.messageTable.initial && earliest.messageTable.extendBackwards)) {
128323
- _context15.next = 21;
128627
+ _context10.next = 21;
128324
128628
  break;
128325
128629
  }
128326
128630
 
128327
128631
  if (!(div.scrollHeight === 0)) {
128328
- _context15.next = 10;
128632
+ _context10.next = 10;
128329
128633
  break;
128330
128634
  }
128331
128635
 
@@ -128333,17 +128637,17 @@ function _infiniteMessageArea() {
128333
128637
  setTimeout(loadMoreWhereNeeded, 2000); // couple be less
128334
128638
 
128335
128639
  lock = false;
128336
- return _context15.abrupt("return");
128640
+ return _context10.abrupt("return");
128337
128641
 
128338
128642
  case 10:
128339
128643
  // console.log(' chat/loadMoreWhereNeeded: Going now')
128340
128644
  scrollBottom = div.scrollHeight - div.scrollTop;
128341
128645
  debug.log('infinite scroll: adding above: top ' + div.scrollTop);
128342
- _context15.next = 14;
128646
+ _context10.next = 14;
128343
128647
  return earliest.messageTable.extendBackwards();
128344
128648
 
128345
128649
  case 14:
128346
- done = _context15.sent;
128650
+ done = _context10.sent;
128347
128651
 
128348
128652
  if (freeze) {
128349
128653
  div.scrollTop = div.scrollHeight - scrollBottom;
@@ -128352,14 +128656,14 @@ function _infiniteMessageArea() {
128352
128656
  if (fixScroll) fixScroll();
128353
128657
 
128354
128658
  if (!done) {
128355
- _context15.next = 19;
128659
+ _context10.next = 19;
128356
128660
  break;
128357
128661
  }
128358
128662
 
128359
- return _context15.abrupt("break", 21);
128663
+ return _context10.abrupt("break", 21);
128360
128664
 
128361
128665
  case 19:
128362
- _context15.next = 5;
128666
+ _context10.next = 5;
128363
128667
  break;
128364
128668
 
128365
128669
  case 21:
@@ -128367,17 +128671,17 @@ function _infiniteMessageArea() {
128367
128671
  div.scrollHeight - div.scrollTop - div.clientHeight < magicZone && // we are scrolled right to the bottom
128368
128672
  latest.messageTable && !latest.messageTable["final"] && // there is more data to come
128369
128673
  latest.messageTable.extendForwards)) {
128370
- _context15.next = 33;
128674
+ _context10.next = 33;
128371
128675
  break;
128372
128676
  }
128373
128677
 
128374
128678
  scrollTop = div.scrollTop;
128375
128679
  debug.log('infinite scroll: adding below: bottom: ' + (div.scrollHeight - div.scrollTop - div.clientHeight));
128376
- _context15.next = 26;
128680
+ _context10.next = 26;
128377
128681
  return latest.messageTable.extendForwards();
128378
128682
 
128379
128683
  case 26:
128380
- done = _context15.sent;
128684
+ done = _context10.sent;
128381
128685
 
128382
128686
  // then add more data on the bottom
128383
128687
  if (freeze) {
@@ -128387,14 +128691,14 @@ function _infiniteMessageArea() {
128387
128691
  if (fixScroll) fixScroll();
128388
128692
 
128389
128693
  if (!done) {
128390
- _context15.next = 31;
128694
+ _context10.next = 31;
128391
128695
  break;
128392
128696
  }
128393
128697
 
128394
- return _context15.abrupt("break", 33);
128698
+ return _context10.abrupt("break", 33);
128395
128699
 
128396
128700
  case 31:
128397
- _context15.next = 21;
128701
+ _context10.next = 21;
128398
128702
  break;
128399
128703
 
128400
128704
  case 33:
@@ -128402,72 +128706,68 @@ function _infiniteMessageArea() {
128402
128706
 
128403
128707
  case 34:
128404
128708
  case "end":
128405
- return _context15.stop();
128709
+ return _context10.stop();
128406
128710
  }
128407
128711
  }
128408
- }, _callee15);
128712
+ }, _callee10);
128409
128713
  }));
128410
128714
  return _loadMoreWhereNeeded.apply(this, arguments);
128411
128715
  };
128412
128716
 
128413
- loadMoreWhereNeeded = function _loadMoreWhereNeeded2(_x18, _x19) {
128717
+ loadMoreWhereNeeded = function _loadMoreWhereNeeded2(_x10, _x11) {
128414
128718
  return _loadMoreWhereNeeded.apply(this, arguments);
128415
128719
  };
128416
128720
 
128417
128721
  _appendCurrentMessages = function _appendCurrentMessage2() {
128418
- _appendCurrentMessages = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee14() {
128722
+ _appendCurrentMessages = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
128419
128723
  var now, chatDocument, messageTable;
128420
- return _regenerator["default"].wrap(function _callee14$(_context14) {
128724
+ return _regenerator["default"].wrap(function _callee9$(_context9) {
128421
128725
  while (1) {
128422
- switch (_context14.prev = _context14.next) {
128726
+ switch (_context9.prev = _context9.next) {
128423
128727
  case 0:
128424
128728
  now = new Date();
128425
- chatDocument = dateFolder.leafDocumentFromDate(now);
128426
- /* Don't actually make the documemnt until a message is sent @@@@@ WHEN SERVER FIXED
128427
- * currently server won't patch to a file ina non-existent directory
128428
- */
128429
-
128430
- /*
128431
- if (SERVER_MKDIRP_BUG) {
128432
- try {
128433
- await createIfNotExists(chatDocument)
128434
- } catch (e) {
128435
- div.appendChild(UI.widgets.errorMessageBlock(
128436
- dom, 'Problem accessing chat file: ' + e))
128437
- return
128438
- }
128439
- }
128440
- */
128441
- /// ///////////////////////////////////////////////////////////
128729
+ chatDocument = dateFolder.leafDocumentFromDate(now); /// ///////////////////////////////////////////////////////////
128442
128730
 
128443
- _context14.next = 4;
128731
+ _context9.next = 4;
128444
128732
  return createMessageTable(now, true);
128445
128733
 
128446
128734
  case 4:
128447
- messageTable = _context14.sent;
128735
+ messageTable = _context9.sent;
128448
128736
  div.appendChild(messageTable);
128737
+ div.refresh = /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
128738
+ return _regenerator["default"].wrap(function _callee8$(_context8) {
128739
+ while (1) {
128740
+ switch (_context8.prev = _context8.next) {
128741
+ case 0:
128742
+ _context8.next = 2;
128743
+ return addNewChatDocumentIfNewDay(new Date());
128744
+
128745
+ case 2:
128746
+ syncMessages(chatChannel, messageTable); // @@ livemessagetable??
128747
+
128748
+ desktopNotification(chatChannel);
128749
+
128750
+ case 4:
128751
+ case "end":
128752
+ return _context8.stop();
128753
+ }
128754
+ }
128755
+ }, _callee8);
128756
+ })); // The short chat version the live update listening is done in the pane but we do it in the widget @@
128449
128757
 
128450
- div.refresh = function () {
128451
- // only the last messageTable is live
128452
- addNewTableIfNewDay(new Date()).then(function () {
128453
- syncMessages(chatChannel, messageTable);
128454
- desktopNotification(chatChannel);
128455
- });
128456
- }; // The short chat version fors live update in the pane but we do it in the widget
128457
-
128758
+ _logic.store.updater.addDownstreamChangeListener(chatDocument, div.refresh); // Live update
128458
128759
 
128459
- kb.updater.addDownstreamChangeListener(chatDocument, div.refresh); // Live update
128460
128760
 
128461
128761
  liveMessageTable = messageTable;
128462
128762
  latest.messageTable = liveMessageTable;
128463
- return _context14.abrupt("return", messageTable);
128763
+ return _context9.abrupt("return", messageTable);
128464
128764
 
128465
128765
  case 11:
128466
128766
  case "end":
128467
- return _context14.stop();
128767
+ return _context9.stop();
128468
128768
  }
128469
128769
  }
128470
- }, _callee14);
128770
+ }, _callee9);
128471
128771
  }));
128472
128772
  return _appendCurrentMessages.apply(this, arguments);
128473
128773
  };
@@ -128476,19 +128776,18 @@ function _infiniteMessageArea() {
128476
128776
  return _appendCurrentMessages.apply(this, arguments);
128477
128777
  };
128478
128778
 
128479
- _addNewTableIfNewDay = function _addNewTableIfNewDay3() {
128480
- _addNewTableIfNewDay = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13(now) {
128779
+ _addNewChatDocumentIfNewDay = function _addNewChatDocumentIf2() {
128780
+ _addNewChatDocumentIfNewDay = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
128481
128781
  var newChatDocument, oldChatDocument, sts;
128482
- return _regenerator["default"].wrap(function _callee13$(_context13) {
128782
+ return _regenerator["default"].wrap(function _callee7$(_context7) {
128483
128783
  while (1) {
128484
- switch (_context13.prev = _context13.next) {
128784
+ switch (_context7.prev = _context7.next) {
128485
128785
  case 0:
128486
- // let now = new Date()
128487
128786
  // @@ Remove listener from previous table as it is now static
128488
- newChatDocument = dateFolder.leafDocumentFromDate(now);
128787
+ newChatDocument = dateFolder.leafDocumentFromDate(new Date());
128489
128788
 
128490
128789
  if (newChatDocument.sameTerm(latest.messageTable.chatDocument)) {
128491
- _context13.next = 7;
128790
+ _context7.next = 7;
128492
128791
  break;
128493
128792
  }
128494
128793
 
@@ -128499,36 +128798,37 @@ function _infiniteMessageArea() {
128499
128798
  }
128500
128799
 
128501
128800
  oldChatDocument = latest.messageTable.chatDocument;
128502
- _context13.next = 6;
128801
+ _context7.next = 6;
128503
128802
  return appendCurrentMessages();
128504
128803
 
128505
128804
  case 6:
128506
128805
  // Adding a link in the document will ping listeners to add the new block too
128507
- if (!kb.holds(oldChatDocument, ns.rdfs('seeAlso'), newChatDocument, oldChatDocument)) {
128806
+ if (!_logic.store.holds(oldChatDocument, ns.rdfs('seeAlso'), newChatDocument, oldChatDocument)) {
128508
128807
  sts = [$rdf.st(oldChatDocument, ns.rdfs('seeAlso'), newChatDocument, oldChatDocument)];
128509
- updater.update([], sts, function (ok, body) {
128510
- if (!ok) {
128511
- alert('Unable to link old message block to new one.' + body);
128512
- }
128513
- });
128808
+
128809
+ try {
128810
+ _logic.store.updater.update([], sts);
128811
+ } catch (err) {
128812
+ alert('Unable to link old chat file to new one:' + err);
128813
+ }
128514
128814
  }
128515
128815
 
128516
128816
  case 7:
128517
128817
  case "end":
128518
- return _context13.stop();
128818
+ return _context7.stop();
128519
128819
  }
128520
128820
  }
128521
- }, _callee13);
128821
+ }, _callee7);
128522
128822
  }));
128523
- return _addNewTableIfNewDay.apply(this, arguments);
128823
+ return _addNewChatDocumentIfNewDay.apply(this, arguments);
128524
128824
  };
128525
128825
 
128526
- addNewTableIfNewDay = function _addNewTableIfNewDay2(_x17) {
128527
- return _addNewTableIfNewDay.apply(this, arguments);
128826
+ addNewChatDocumentIfNewDay = function _addNewChatDocumentIf() {
128827
+ return _addNewChatDocumentIfNewDay.apply(this, arguments);
128528
128828
  };
128529
128829
 
128530
128830
  renderMessageTable = function _renderMessageTable(date, live) {
128531
- var scrollBackButton;
128831
+ var scrollBackbutton;
128532
128832
  var scrollForwardButton; /// ///////////////// Scroll down adding more above
128533
128833
 
128534
128834
  function extendBackwards() {
@@ -128536,23 +128836,23 @@ function _infiniteMessageArea() {
128536
128836
  }
128537
128837
 
128538
128838
  function _extendBackwards() {
128539
- _extendBackwards = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
128839
+ _extendBackwards = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
128540
128840
  var done;
128541
- return _regenerator["default"].wrap(function _callee7$(_context7) {
128841
+ return _regenerator["default"].wrap(function _callee$(_context) {
128542
128842
  while (1) {
128543
- switch (_context7.prev = _context7.next) {
128843
+ switch (_context.prev = _context.next) {
128544
128844
  case 0:
128545
- _context7.next = 2;
128845
+ _context.next = 2;
128546
128846
  return insertPreviousMessages(true);
128547
128847
 
128548
128848
  case 2:
128549
- done = _context7.sent;
128849
+ done = _context.sent;
128550
128850
 
128551
128851
  if (done) {
128552
- if (scrollBackButton) {
128553
- scrollBackButton.firstChild.setAttribute('src', UI.icons.iconBase + 'noun_T-Block_1114655_000000.svg'); // T
128852
+ if (scrollBackbutton) {
128853
+ scrollBackbutton.firstChild.setAttribute('src', _iconBase.icons.iconBase + 'noun_T-Block_1114655_000000.svg'); // T
128554
128854
 
128555
- scrollBackButton.disabled = true;
128855
+ scrollBackbutton.disabled = true;
128556
128856
  }
128557
128857
 
128558
128858
  messageTable.initial = true;
@@ -128560,67 +128860,67 @@ function _infiniteMessageArea() {
128560
128860
  messageTable.extendedBack = true;
128561
128861
  }
128562
128862
 
128563
- setScrollBackButtonIcon();
128564
- return _context7.abrupt("return", done);
128863
+ setScrollBackbuttonIcon();
128864
+ return _context.abrupt("return", done);
128565
128865
 
128566
128866
  case 6:
128567
128867
  case "end":
128568
- return _context7.stop();
128868
+ return _context.stop();
128569
128869
  }
128570
128870
  }
128571
- }, _callee7);
128871
+ }, _callee);
128572
128872
  }));
128573
128873
  return _extendBackwards.apply(this, arguments);
128574
128874
  }
128575
128875
 
128576
- function setScrollBackButtonIcon() {
128577
- if (!scrollBackButton) {
128876
+ function setScrollBackbuttonIcon() {
128877
+ if (!scrollBackbutton) {
128578
128878
  return;
128579
128879
  }
128580
128880
 
128581
128881
  var sense = messageTable.extendedBack ? !newestFirst : newestFirst;
128582
128882
  var scrollBackIcon = messageTable.initial ? 'noun_T-Block_1114655_000000.svg' : getScrollbackIcon(sense);
128583
- scrollBackButton.firstChild.setAttribute('src', UI.icons.iconBase + scrollBackIcon);
128883
+ scrollBackbutton.firstChild.setAttribute('src', _iconBase.icons.iconBase + scrollBackIcon);
128584
128884
 
128585
128885
  function getScrollbackIcon(sense) {
128586
128886
  return sense ? 'noun_1369241.svg' : 'noun_1369237.svg';
128587
128887
  }
128588
128888
  }
128589
128889
 
128590
- function scrollBackButtonHandler(_x15) {
128591
- return _scrollBackButtonHandler.apply(this, arguments);
128890
+ function scrollBackbuttonHandler(_x8) {
128891
+ return _scrollBackbuttonHandler.apply(this, arguments);
128592
128892
  } /// ////////////// Scroll up adding more below
128593
128893
 
128594
128894
 
128595
- function _scrollBackButtonHandler() {
128596
- _scrollBackButtonHandler = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(_event) {
128597
- return _regenerator["default"].wrap(function _callee8$(_context8) {
128895
+ function _scrollBackbuttonHandler() {
128896
+ _scrollBackbuttonHandler = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(_event) {
128897
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
128598
128898
  while (1) {
128599
- switch (_context8.prev = _context8.next) {
128899
+ switch (_context2.prev = _context2.next) {
128600
128900
  case 0:
128601
128901
  if (!messageTable.extendedBack) {
128602
- _context8.next = 6;
128902
+ _context2.next = 6;
128603
128903
  break;
128604
128904
  }
128605
128905
 
128606
128906
  removePreviousMessages(true, messageTable);
128607
128907
  messageTable.extendedBack = false;
128608
- setScrollBackButtonIcon();
128609
- _context8.next = 8;
128908
+ setScrollBackbuttonIcon();
128909
+ _context2.next = 8;
128610
128910
  break;
128611
128911
 
128612
128912
  case 6:
128613
- _context8.next = 8;
128913
+ _context2.next = 8;
128614
128914
  return extendBackwards();
128615
128915
 
128616
128916
  case 8:
128617
128917
  case "end":
128618
- return _context8.stop();
128918
+ return _context2.stop();
128619
128919
  }
128620
128920
  }
128621
- }, _callee8);
128921
+ }, _callee2);
128622
128922
  }));
128623
- return _scrollBackButtonHandler.apply(this, arguments);
128923
+ return _scrollBackbuttonHandler.apply(this, arguments);
128624
128924
  }
128625
128925
 
128626
128926
  function extendForwards() {
@@ -128628,20 +128928,20 @@ function _infiniteMessageArea() {
128628
128928
  }
128629
128929
 
128630
128930
  function _extendForwards() {
128631
- _extendForwards = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
128931
+ _extendForwards = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
128632
128932
  var done;
128633
- return _regenerator["default"].wrap(function _callee9$(_context9) {
128933
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
128634
128934
  while (1) {
128635
- switch (_context9.prev = _context9.next) {
128935
+ switch (_context3.prev = _context3.next) {
128636
128936
  case 0:
128637
- _context9.next = 2;
128937
+ _context3.next = 2;
128638
128938
  return insertPreviousMessages(false);
128639
128939
 
128640
128940
  case 2:
128641
- done = _context9.sent;
128941
+ done = _context3.sent;
128642
128942
 
128643
128943
  if (done) {
128644
- scrollForwardButton.firstChild.setAttribute('src', UI.icons.iconBase + 'noun_T-Block_1114655_000000.svg');
128944
+ scrollForwardButton.firstChild.setAttribute('src', _iconBase.icons.iconBase + 'noun_T-Block_1114655_000000.svg');
128645
128945
  scrollForwardButton.disabled = true;
128646
128946
  messageTable["final"] = true;
128647
128947
  } else {
@@ -128649,14 +128949,14 @@ function _infiniteMessageArea() {
128649
128949
  }
128650
128950
 
128651
128951
  setScrollForwardButtonIcon();
128652
- return _context9.abrupt("return", done);
128952
+ return _context3.abrupt("return", done);
128653
128953
 
128654
128954
  case 6:
128655
128955
  case "end":
128656
- return _context9.stop();
128956
+ return _context3.stop();
128657
128957
  }
128658
128958
  }
128659
- }, _callee9);
128959
+ }, _callee3);
128660
128960
  }));
128661
128961
  return _extendForwards.apply(this, arguments);
128662
128962
  }
@@ -128665,37 +128965,48 @@ function _infiniteMessageArea() {
128665
128965
  var sense = messageTable.extendedForwards ? !newestFirst : newestFirst; // noun_T-Block_1114657_000000.svg
128666
128966
 
128667
128967
  var scrollForwardIcon = messageTable["final"] ? 'noun_T-Block_1114657_000000.svg' : getScrollForwardButtonIcon(sense);
128668
- scrollForwardButton.firstChild.setAttribute('src', UI.icons.iconBase + scrollForwardIcon);
128968
+ scrollForwardButton.firstChild.setAttribute('src', _iconBase.icons.iconBase + scrollForwardIcon);
128669
128969
 
128670
128970
  function getScrollForwardButtonIcon(sense) {
128671
128971
  return !sense ? 'noun_1369241.svg' : 'noun_1369237.svg';
128672
128972
  }
128673
128973
  }
128674
128974
 
128675
- function scrollForwardButtonHandler(_x16) {
128975
+ function scrollForwardButtonHandler(_x9) {
128676
128976
  return _scrollForwardButtonHandler.apply(this, arguments);
128677
128977
  } /// ///////////////////////
128678
128978
 
128979
+ /*
128980
+ options = options || {}
128981
+ options.authorDateOnLeft = true
128982
+ const newestFirst = options.newestFirst === '1' || options.newestFirst === true // hack for now
128983
+ const channelObject = new ChatChannel(chatChannel, options)
128984
+ const dateFolder = channelObject.dateFolder
128985
+ const div = dom.createElement('div')
128986
+ const statusArea = div.appendChild(dom.createElement('div'))
128987
+ const userContext = { dom, statusArea, div: statusArea } // logged on state, pointers to user's stuff
128988
+ */
128989
+
128679
128990
 
128680
128991
  function _scrollForwardButtonHandler() {
128681
- _scrollForwardButtonHandler = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(_event) {
128682
- return _regenerator["default"].wrap(function _callee10$(_context10) {
128992
+ _scrollForwardButtonHandler = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(_event) {
128993
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
128683
128994
  while (1) {
128684
- switch (_context10.prev = _context10.next) {
128995
+ switch (_context4.prev = _context4.next) {
128685
128996
  case 0:
128686
128997
  if (!messageTable.extendedForwards) {
128687
- _context10.next = 6;
128998
+ _context4.next = 6;
128688
128999
  break;
128689
129000
  }
128690
129001
 
128691
129002
  removePreviousMessages(false, messageTable);
128692
129003
  messageTable.extendedForwards = false;
128693
129004
  setScrollForwardButtonIcon();
128694
- _context10.next = 9;
129005
+ _context4.next = 9;
128695
129006
  break;
128696
129007
 
128697
129008
  case 6:
128698
- _context10.next = 8;
129009
+ _context4.next = 8;
128699
129010
  return extendForwards();
128700
129011
 
128701
129012
  case 8:
@@ -128704,10 +129015,10 @@ function _infiniteMessageArea() {
128704
129015
 
128705
129016
  case 9:
128706
129017
  case "end":
128707
- return _context10.stop();
129018
+ return _context4.stop();
128708
129019
  }
128709
129020
  }
128710
- }, _callee10);
129021
+ }, _callee4);
128711
129022
  }));
128712
129023
  return _scrollForwardButtonHandler.apply(this, arguments);
128713
129024
  }
@@ -128727,7 +129038,7 @@ function _infiniteMessageArea() {
128727
129038
  messageTable["final"] = true;
128728
129039
  liveMessageTable = messageTable;
128729
129040
  latest.messageTable = messageTable;
128730
- var tr = newMessageForm(messageTable);
129041
+ var tr = (0, _message.renderMessageEditor)(channelObject, messageTable, userContext, options);
128731
129042
 
128732
129043
  if (newestFirst) {
128733
129044
  messageTable.insertBefore(tr, messageTable.firstChild); // If newestFirst
@@ -128742,27 +129053,27 @@ function _infiniteMessageArea() {
128742
129053
 
128743
129054
 
128744
129055
  if (options.infinite) {
128745
- var scrollBackButtonTR = dom.createElement('tr');
128746
- var scrollBackButtonCell = scrollBackButtonTR.appendChild(dom.createElement('td')); // up traingles: noun_1369237.svg
129056
+ var scrollBackbuttonTR = dom.createElement('tr');
129057
+ var scrollBackbuttonCell = scrollBackbuttonTR.appendChild(dom.createElement('td')); // up traingles: noun_1369237.svg
128747
129058
  // down triangles: noun_1369241.svg
128748
129059
 
128749
129060
  var scrollBackIcon = newestFirst ? 'noun_1369241.svg' : 'noun_1369237.svg'; // down and up arrows respoctively
128750
129061
 
128751
- scrollBackButton = UI.widgets.button(dom, UI.icons.iconBase + scrollBackIcon, 'Previous messages ...');
128752
- scrollBackButtonCell.style = 'width:3em; height:3em;';
128753
- scrollBackButton.addEventListener('click', scrollBackButtonHandler, false);
129062
+ scrollBackbutton = widgets.button(dom, _iconBase.icons.iconBase + scrollBackIcon, 'Previous messages ...');
129063
+ scrollBackbuttonCell.style = 'width:3em; height:3em;';
129064
+ scrollBackbutton.addEventListener('click', scrollBackbuttonHandler, false);
128754
129065
  messageTable.extendedBack = false;
128755
- scrollBackButtonCell.appendChild(scrollBackButton);
128756
- setScrollBackButtonIcon();
128757
- var dateCell = scrollBackButtonTR.appendChild(dom.createElement('td'));
129066
+ scrollBackbuttonCell.appendChild(scrollBackbutton);
129067
+ setScrollBackbuttonIcon();
129068
+ var dateCell = scrollBackbuttonTR.appendChild(dom.createElement('td'));
128758
129069
  dateCell.style = 'text-align: center; vertical-align: middle; color: #888; font-style: italic;';
128759
- dateCell.textContent = UI.widgets.shortDate(date.toISOString(), true); // no time, only date
129070
+ dateCell.textContent = widgets.shortDate(date.toISOString(), true); // no time, only date
128760
129071
  // @@@@@@@@@@@ todo move this button to other end of message cell, o
128761
129072
 
128762
- var scrollForwardButtonCell = scrollBackButtonTR.appendChild(dom.createElement('td'));
129073
+ var scrollForwardButtonCell = scrollBackbuttonTR.appendChild(dom.createElement('td'));
128763
129074
  var scrollForwardIcon = newestFirst ? 'noun_1369241.svg' : 'noun_1369237.svg'; // down and up arrows respoctively
128764
129075
 
128765
- scrollForwardButton = UI.widgets.button(dom, UI.icons.iconBase + scrollForwardIcon, 'Later messages ...');
129076
+ scrollForwardButton = widgets.button(dom, _iconBase.icons.iconBase + scrollForwardIcon, 'Later messages ...');
128766
129077
  scrollForwardButtonCell.appendChild(scrollForwardButton);
128767
129078
  scrollForwardButtonCell.style = 'width:3em; height:3em;';
128768
129079
  scrollForwardButton.addEventListener('click', scrollForwardButtonHandler, false);
@@ -128772,13 +129083,13 @@ function _infiniteMessageArea() {
128772
129083
 
128773
129084
  if (!newestFirst) {
128774
129085
  // opposite end from the entry field
128775
- messageTable.insertBefore(scrollBackButtonTR, messageTable.firstChild); // If not newestFirst
129086
+ messageTable.insertBefore(scrollBackbuttonTR, messageTable.firstChild); // If not newestFirst
128776
129087
  } else {
128777
- messageTable.appendChild(scrollBackButtonTR); // newestFirst
129088
+ messageTable.appendChild(scrollBackbuttonTR); // newestFirst
128778
129089
  }
128779
129090
  }
128780
129091
 
128781
- var sts = kb.statementsMatching(null, WF('message'), null, chatDocument);
129092
+ var sts = _logic.store.statementsMatching(null, ns.wf('message'), null, chatDocument);
128782
129093
 
128783
129094
  if (!live && sts.length === 0) {// not todays
128784
129095
  // no need buttomns at the moment
@@ -128795,57 +129106,57 @@ function _infiniteMessageArea() {
128795
129106
  };
128796
129107
 
128797
129108
  _createMessageTable = function _createMessageTable3() {
128798
- _createMessageTable = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12(date, live) {
129109
+ _createMessageTable = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(date, live) {
128799
129110
  var chatDocument, messageTable, statusTR;
128800
- return _regenerator["default"].wrap(function _callee12$(_context12) {
129111
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
128801
129112
  while (1) {
128802
- switch (_context12.prev = _context12.next) {
129113
+ switch (_context6.prev = _context6.next) {
128803
129114
  case 0:
128804
129115
  debug.log(' createMessageTable for ' + date);
128805
129116
  chatDocument = dateFolder.leafDocumentFromDate(date);
128806
- _context12.prev = 2;
128807
- _context12.next = 5;
128808
- return kb.fetcher.load(chatDocument);
129117
+ _context6.prev = 2;
129118
+ _context6.next = 5;
129119
+ return _logic.store.fetcher.load(chatDocument);
128809
129120
 
128810
129121
  case 5:
128811
- _context12.next = 19;
129122
+ _context6.next = 19;
128812
129123
  break;
128813
129124
 
128814
129125
  case 7:
128815
- _context12.prev = 7;
128816
- _context12.t0 = _context12["catch"](2);
129126
+ _context6.prev = 7;
129127
+ _context6.t0 = _context6["catch"](2);
128817
129128
  messageTable = dom.createElement('table');
128818
129129
  statusTR = messageTable.appendChild(dom.createElement('tr')); // ### find status in exception
128819
129130
 
128820
- if (!(_context12.t0.response && _context12.t0.response.status && _context12.t0.response.status === 404)) {
128821
- _context12.next = 16;
129131
+ if (!(_context6.t0.response && _context6.t0.response.status && _context6.t0.response.status === 404)) {
129132
+ _context6.next = 16;
128822
129133
  break;
128823
129134
  }
128824
129135
 
128825
129136
  debug.log('Error 404 for chat file ' + chatDocument);
128826
- return _context12.abrupt("return", renderMessageTable(date, live));
129137
+ return _context6.abrupt("return", renderMessageTable(date, live));
128827
129138
 
128828
129139
  case 16:
128829
129140
  debug.log('*** Error NON 404 for chat file ' + chatDocument);
128830
- statusTR.appendChild(UI.widgets.errorMessageBlock(dom, _context12.t0, 'pink'));
129141
+ statusTR.appendChild(widgets.errorMessageBlock(dom, _context6.t0, 'pink'));
128831
129142
 
128832
129143
  case 18:
128833
- return _context12.abrupt("return", statusTR);
129144
+ return _context6.abrupt("return", statusTR);
128834
129145
 
128835
129146
  case 19:
128836
- return _context12.abrupt("return", renderMessageTable(date, live));
129147
+ return _context6.abrupt("return", renderMessageTable(date, live));
128837
129148
 
128838
129149
  case 20:
128839
129150
  case "end":
128840
- return _context12.stop();
129151
+ return _context6.stop();
128841
129152
  }
128842
129153
  }
128843
- }, _callee12, null, [[2, 7]]);
129154
+ }, _callee6, null, [[2, 7]]);
128844
129155
  }));
128845
129156
  return _createMessageTable.apply(this, arguments);
128846
129157
  };
128847
129158
 
128848
- createMessageTable = function _createMessageTable2(_x13, _x14) {
129159
+ createMessageTable = function _createMessageTable2(_x6, _x7) {
128849
129160
  return _createMessageTable.apply(this, arguments);
128850
129161
  };
128851
129162
 
@@ -128867,38 +129178,38 @@ function _infiniteMessageArea() {
128867
129178
  };
128868
129179
 
128869
129180
  _insertPreviousMessages = function _insertPreviousMessag2() {
128870
- _insertPreviousMessages = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee11(backwards) {
129181
+ _insertPreviousMessages = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(backwards) {
128871
129182
  var extremity, date, live, todayDoc, doc, newMessageTable;
128872
- return _regenerator["default"].wrap(function _callee11$(_context11) {
129183
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
128873
129184
  while (1) {
128874
- switch (_context11.prev = _context11.next) {
129185
+ switch (_context5.prev = _context5.next) {
128875
129186
  case 0:
128876
129187
  extremity = backwards ? earliest : latest;
128877
129188
  date = extremity.messageTable.date; // day in mssecs
128878
129189
 
128879
- _context11.next = 4;
129190
+ _context5.next = 4;
128880
129191
  return dateFolder.loadPrevious(date, backwards);
128881
129192
 
128882
129193
  case 4:
128883
- date = _context11.sent;
129194
+ date = _context5.sent;
128884
129195
  // backwards
128885
129196
  debug.log("insertPreviousMessages: from ".concat(backwards ? 'backwards' : 'forwards', " loadPrevious: ").concat(date));
128886
129197
 
128887
129198
  if (!(!date && !backwards && !liveMessageTable)) {
128888
- _context11.next = 9;
129199
+ _context5.next = 9;
128889
129200
  break;
128890
129201
  }
128891
129202
 
128892
- _context11.next = 9;
129203
+ _context5.next = 9;
128893
129204
  return appendCurrentMessages();
128894
129205
 
128895
129206
  case 9:
128896
129207
  if (date) {
128897
- _context11.next = 11;
129208
+ _context5.next = 11;
128898
129209
  break;
128899
129210
  }
128900
129211
 
128901
- return _context11.abrupt("return", true);
129212
+ return _context5.abrupt("return", true);
128902
129213
 
128903
129214
  case 11:
128904
129215
  // done
@@ -128910,11 +129221,11 @@ function _infiniteMessageArea() {
128910
129221
  live = doc.sameTerm(todayDoc); // Is this todays?
128911
129222
  }
128912
129223
 
128913
- _context11.next = 15;
129224
+ _context5.next = 15;
128914
129225
  return createMessageTable(date, live);
128915
129226
 
128916
129227
  case 15:
128917
- newMessageTable = _context11.sent;
129228
+ newMessageTable = _context5.sent;
128918
129229
  extremity.messageTable = newMessageTable; // move pointer to earliest
128919
129230
 
128920
129231
  if (backwards ? newestFirst : !newestFirst) {
@@ -128925,30 +129236,30 @@ function _infiniteMessageArea() {
128925
129236
  div.insertBefore(newMessageTable, div.firstChild);
128926
129237
  }
128927
129238
 
128928
- return _context11.abrupt("return", live);
129239
+ return _context5.abrupt("return", live);
128929
129240
 
128930
129241
  case 19:
128931
129242
  case "end":
128932
- return _context11.stop();
129243
+ return _context5.stop();
128933
129244
  }
128934
129245
  }
128935
- }, _callee11);
129246
+ }, _callee5);
128936
129247
  }));
128937
129248
  return _insertPreviousMessages.apply(this, arguments);
128938
129249
  };
128939
129250
 
128940
- insertPreviousMessages = function _insertPreviousMessag(_x12) {
129251
+ insertPreviousMessages = function _insertPreviousMessag(_x5) {
128941
129252
  return _insertPreviousMessages.apply(this, arguments);
128942
129253
  };
128943
129254
 
128944
129255
  addMessage = function _addMessage(message, messageTable) {
128945
- var bindings = {
128946
- '?msg': message,
128947
- '?creator': kb.any(message, ns.foaf('maker')),
128948
- '?date': kb.any(message, DCT('created')),
128949
- '?content': kb.any(message, ns.sioc('content'))
128950
- };
128951
- (0, _message.renderMessage)(messageTable, bindings, messageTable.fresh, options, userContext); // fresh from elsewhere
129256
+ var latest = (0, _chatLogic.mostRecentVersion)(message); // const content = store.any(latest, ns.sioc('content'))
129257
+
129258
+ if ((0, _chatLogic.isDeleted)(latest) && !options.showDeletedMessages) {
129259
+ return; // ignore deleted messaged -- @@ could also leave a placeholder
129260
+ }
129261
+
129262
+ insertMessageIntoTable(channelObject, messageTable, message, messageTable.fresh, options, userContext); // fresh from elsewhere
128952
129263
  };
128953
129264
 
128954
129265
  syncMessages = function _syncMessages(about, messageTable) {
@@ -128961,9 +129272,10 @@ function _infiniteMessageArea() {
128961
129272
  }
128962
129273
  }
128963
129274
 
128964
- var messages = kb.statementsMatching(about, ns.wf('message'), null, messageTable.chatDocument).map(function (st) {
129275
+ var messages = _logic.store.statementsMatching(about, ns.wf('message'), null, messageTable.chatDocument).map(function (st) {
128965
129276
  return st.object;
128966
129277
  });
129278
+
128967
129279
  var stored = {};
128968
129280
  messages.forEach(function (m) {
128969
129281
  stored[m.uri] = true;
@@ -128986,368 +129298,28 @@ function _infiniteMessageArea() {
128986
129298
  for (ele = messageTable.firstChild; ele; ele = ele.nextSibling) {
128987
129299
  if (ele.AJAR_subject) {
128988
129300
  // Refresh thumbs up etc
128989
- UI.widgets.refreshTree(ele); // Things inside may have changed too
129301
+ widgets.refreshTree(ele); // Things inside may have changed too
128990
129302
  }
128991
129303
  }
128992
129304
  };
128993
129305
 
128994
- newMessageForm = function _newMessageForm(messageTable) {
128995
- var form = dom.createElement('tr');
128996
- var lhs = dom.createElement('td');
128997
- var middle = dom.createElement('td');
128998
- var rhs = dom.createElement('td');
128999
- form.appendChild(lhs);
129000
- form.appendChild(middle);
129001
- form.appendChild(rhs);
129002
- form.AJAR_date = '9999-01-01T00:00:00Z'; // ISO format for field sort
129003
-
129004
- var field, sendButton;
129005
-
129006
- function sendMessage(_x6) {
129007
- return _sendMessage.apply(this, arguments);
129008
- } // sendMessage
129009
-
129010
-
129011
- function _sendMessage() {
129012
- _sendMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(text) {
129013
- var now, sts, timestamp, dateStamp, chatDocument, message, content, sendComplete;
129014
- return _regenerator["default"].wrap(function _callee6$(_context6) {
129015
- while (1) {
129016
- switch (_context6.prev = _context6.next) {
129017
- case 0:
129018
- sendComplete = function _sendComplete() {
129019
- var bindings = {
129020
- '?msg': message,
129021
- '?content': content,
129022
- '?date': dateStamp,
129023
- '?creator': me
129024
- };
129025
- (0, _message.renderMessage)(liveMessageTable, bindings, false, options, userContext); // not green
129026
-
129027
- if (!text) {
129028
- field.value = ''; // clear from out for reuse
129029
-
129030
- field.setAttribute('style', messageBodyStyle);
129031
- field.disabled = false;
129032
- field.scrollIntoView(newestFirst); // allign bottom (top)
129033
-
129034
- field.focus(); // Start typing next line immediately
129035
-
129036
- field.select();
129037
- }
129038
- };
129039
-
129040
- now = new Date();
129041
- _context6.next = 4;
129042
- return addNewTableIfNewDay(now);
129043
-
129044
- case 4:
129045
- if (!text) {
129046
- field.setAttribute('style', messageBodyStyle + 'color: #bbb;'); // pendingedit
129047
-
129048
- field.disabled = true;
129049
- }
129050
-
129051
- sts = [];
129052
- timestamp = '' + now.getTime();
129053
- dateStamp = $rdf.term(now);
129054
- chatDocument = dateFolder.leafDocumentFromDate(now);
129055
- message = kb.sym(chatDocument.uri + '#' + 'Msg' + timestamp);
129056
- content = kb.literal(text || field.value); // if (text) field.value = text No - don't destroy half-finsihed user input
129057
-
129058
- sts.push(new $rdf.Statement(chatChannel, ns.wf('message'), message, chatDocument));
129059
- sts.push(new $rdf.Statement(message, ns.sioc('content'), content, chatDocument));
129060
- sts.push(new $rdf.Statement(message, DCT('created'), dateStamp, chatDocument));
129061
-
129062
- if (me) {
129063
- sts.push(new $rdf.Statement(message, ns.foaf('maker'), me, chatDocument));
129064
- }
129065
-
129066
- if (!(SERVER_MKDIRP_BUG && (kb.fetcher.requested[chatDocument.uri] === undefined || kb.fetcher.requested[chatDocument.uri] === 404))) {
129067
- _context6.next = 19;
129068
- break;
129069
- }
129070
-
129071
- debug.log('@@@ SERVER_MKDIRP_BUG: Should only happen once: create chat file: ' + chatDocument);
129072
- _context6.next = 19;
129073
- return createIfNotExists(chatDocument);
129074
-
129075
- case 19:
129076
- _context6.prev = 19;
129077
- _context6.next = 22;
129078
- return updater.update([], sts);
129079
-
129080
- case 22:
129081
- _context6.next = 28;
129082
- break;
129083
-
129084
- case 24:
129085
- _context6.prev = 24;
129086
- _context6.t0 = _context6["catch"](19);
129087
- form.appendChild(UI.widgets.errorMessageBlock(dom, 'Error writing message: ' + _context6.t0));
129088
- return _context6.abrupt("return");
129089
-
129090
- case 28:
129091
- sendComplete();
129092
-
129093
- case 29:
129094
- case "end":
129095
- return _context6.stop();
129096
- }
129097
- }
129098
- }, _callee6, null, [[19, 24]]);
129099
- }));
129100
- return _sendMessage.apply(this, arguments);
129101
- }
129102
-
129103
- form.appendChild(dom.createElement('br')); // DRAG AND DROP
129104
-
129105
- function droppedFileHandler(files) {
129106
- var base = messageTable.chatDocument.dir().uri;
129107
- UI.widgets.uploadFiles(kb.fetcher, files, base + 'Files', base + 'Pictures', /*#__PURE__*/function () {
129108
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(theFile, destURI) {
129109
- return _regenerator["default"].wrap(function _callee2$(_context2) {
129110
- while (1) {
129111
- switch (_context2.prev = _context2.next) {
129112
- case 0:
129113
- _context2.next = 2;
129114
- return sendMessage(destURI);
129115
-
129116
- case 2:
129117
- case "end":
129118
- return _context2.stop();
129119
- }
129120
- }
129121
- }, _callee2);
129122
- }));
129123
-
129124
- return function (_x7, _x8) {
129125
- return _ref.apply(this, arguments);
129126
- };
129127
- }());
129128
- } // When a set of URIs are dropped on the field
129129
-
129130
-
129131
- var droppedURIHandler = /*#__PURE__*/function () {
129132
- var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(uris) {
129133
- var _iterator, _step, uri;
129134
-
129135
- return _regenerator["default"].wrap(function _callee3$(_context3) {
129136
- while (1) {
129137
- switch (_context3.prev = _context3.next) {
129138
- case 0:
129139
- _iterator = _createForOfIteratorHelper(uris);
129140
- _context3.prev = 1;
129141
-
129142
- _iterator.s();
129143
-
129144
- case 3:
129145
- if ((_step = _iterator.n()).done) {
129146
- _context3.next = 9;
129147
- break;
129148
- }
129149
-
129150
- uri = _step.value;
129151
- _context3.next = 7;
129152
- return sendMessage(uri);
129153
-
129154
- case 7:
129155
- _context3.next = 3;
129156
- break;
129157
-
129158
- case 9:
129159
- _context3.next = 14;
129160
- break;
129161
-
129162
- case 11:
129163
- _context3.prev = 11;
129164
- _context3.t0 = _context3["catch"](1);
129165
-
129166
- _iterator.e(_context3.t0);
129167
-
129168
- case 14:
129169
- _context3.prev = 14;
129170
-
129171
- _iterator.f();
129172
-
129173
- return _context3.finish(14);
129174
-
129175
- case 17:
129176
- case "end":
129177
- return _context3.stop();
129178
- }
129179
- }
129180
- }, _callee3, null, [[1, 11, 14, 17]]);
129181
- }));
129182
-
129183
- return function droppedURIHandler(_x9) {
129184
- return _ref2.apply(this, arguments);
129185
- };
129186
- }(); // When we are actually logged on
129187
-
129188
-
129189
- function turnOnInput() {
129190
- if (options.menuHandler && menuButton) {
129191
- var menuOptions = {
129192
- me: me,
129193
- dom: dom,
129194
- div: div,
129195
- newBase: messageTable.chatDocument.dir().uri
129196
- };
129197
- menuButton.addEventListener('click', function (event) {
129198
- options.menuHandler(event, chatChannel, menuOptions);
129199
- }, false);
129200
- } // Turn on message input
129201
-
129202
-
129203
- (0, _message.creatorAndDate)(lhs, me, '', null);
129204
- field = dom.createElement('textarea');
129205
- middle.innerHTML = '';
129206
- middle.appendChild(field);
129207
- field.rows = 3; // field.cols = 40
129208
-
129209
- field.setAttribute('style', messageBodyStyle + 'background-color: #eef;'); // Trap the Enter BEFORE it is used ti make a newline
129210
-
129211
- field.addEventListener('keydown', /*#__PURE__*/function () {
129212
- var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(e) {
129213
- return _regenerator["default"].wrap(function _callee4$(_context4) {
129214
- while (1) {
129215
- switch (_context4.prev = _context4.next) {
129216
- case 0:
129217
- if (!(e.keyCode === 13)) {
129218
- _context4.next = 4;
129219
- break;
129220
- }
129221
-
129222
- if (e.altKey) {
129223
- _context4.next = 4;
129224
- break;
129225
- }
129226
-
129227
- _context4.next = 4;
129228
- return sendMessage();
129229
-
129230
- case 4:
129231
- case "end":
129232
- return _context4.stop();
129233
- }
129234
- }
129235
- }, _callee4);
129236
- }));
129237
-
129238
- return function (_x10) {
129239
- return _ref3.apply(this, arguments);
129240
- };
129241
- }(), false);
129242
- UI.widgets.makeDropTarget(field, droppedURIHandler, droppedFileHandler);
129243
- rhs.innerHTML = '';
129244
- sendButton = UI.widgets.button(dom, UI.icons.iconBase + 'noun_383448.svg', 'Send');
129245
- sendButton.setAttribute('style', UI.style.buttonStyle + 'float: right;');
129246
- sendButton.addEventListener('click', function (_event) {
129247
- return sendMessage();
129248
- }, false);
129249
- rhs.appendChild(sendButton);
129250
- var chatDocument = dateFolder.leafDocumentFromDate(new Date());
129251
- var imageDoc;
129252
-
129253
- function getImageDoc() {
129254
- imageDoc = kb.sym(chatDocument.dir().uri + 'Image_' + Date.now() + '.png');
129255
- return imageDoc;
129256
- }
129257
-
129258
- function tookPicture(_x11) {
129259
- return _tookPicture.apply(this, arguments);
129260
- }
129261
-
129262
- function _tookPicture() {
129263
- _tookPicture = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(imageDoc) {
129264
- return _regenerator["default"].wrap(function _callee5$(_context5) {
129265
- while (1) {
129266
- switch (_context5.prev = _context5.next) {
129267
- case 0:
129268
- if (!imageDoc) {
129269
- _context5.next = 3;
129270
- break;
129271
- }
129272
-
129273
- _context5.next = 3;
129274
- return sendMessage(imageDoc.uri);
129275
-
129276
- case 3:
129277
- case "end":
129278
- return _context5.stop();
129279
- }
129280
- }
129281
- }, _callee5);
129282
- }));
129283
- return _tookPicture.apply(this, arguments);
129284
- }
129285
-
129286
- middle.appendChild(UI.media.cameraButton(dom, kb, getImageDoc, tookPicture));
129287
- UI.pad.recordParticipation(chatChannel, chatChannel.doc()); // participation =
129288
- } // turn on inpuut
129289
-
129290
-
129291
- var context = {
129292
- div: middle,
129293
- dom: dom
129294
- };
129295
- UI.authn.logIn(context).then(function (context) {
129296
- me = context.me;
129297
- turnOnInput();
129298
- Object.assign(context, userContext);
129299
- (0, _bookmarks.findBookmarkDocument)(context).then(function (context) {
129300
- debug.log('Bookmark file: ' + context.bookmarkDocument);
129301
- });
129302
- });
129303
- return form;
129304
- };
129305
-
129306
- kb = kb || UI.store;
129307
- ns = UI.ns;
129308
- WF = $rdf.Namespace('http://www.w3.org/2005/01/wf/flow#');
129309
- DCT = $rdf.Namespace('http://purl.org/dc/terms/'); // const POSIX = $rdf.Namespace('http://www.w3.org/ns/posix/stat#')
129310
-
129306
+ // Body of main function
129311
129307
  options = options || {};
129312
- newestFirst = options.newestFirst === '1' || options.newestFirst === true; // hack for now
129313
-
129314
- dateFolder = new _dateFolder.DateFolder(chatChannel, 'chat.ttl');
129315
- options.authorAboveContent = true; // var participation // An object tracking users use and prefs
129308
+ options.authorDateOnLeft = false; // @@ make a user optiosn
129316
129309
 
129317
- messageBodyStyle = UI.style.messageBodyStyle; // var messageBodyStyle = 'white-space: pre-wrap; width: 90%; font-size:100%; border: 0.07em solid #eee; padding: .2em 0.5em; margin: 0.1em 1em 0.1em 1em;'
129318
- // 'font-size: 100%; margin: 0.1em 1em 0.1em 1em; background-color: white; white-space: pre-wrap; padding: 0.1em;'
129310
+ newestFirst = options.newestFirst === '1' || options.newestFirst === true; // hack for now
129319
129311
 
129312
+ channelObject = new _chatLogic.ChatChannel(chatChannel, options);
129313
+ dateFolder = channelObject.dateFolder;
129320
129314
  div = dom.createElement('div');
129315
+ channelObject.div = div;
129321
129316
  statusArea = div.appendChild(dom.createElement('div'));
129322
129317
  userContext = {
129323
129318
  dom: dom,
129324
129319
  statusArea: statusArea,
129325
129320
  div: statusArea
129326
129321
  }; // logged on state, pointers to user's stuff
129327
-
129328
- updater = UI.store.updater;
129329
- /** Does a file exist on the web?
129330
- * @returns {Boolean}
129331
- */
129332
-
129333
- /*
129334
- async function documentExists (doc) {
129335
- try {
129336
- await kb.fetcher.load(doc)
129337
- } catch (err) {
129338
- if (err.response.status === 404) {
129339
- return false
129340
- } else {
129341
- debug.log('documentExists: doc load error NOT 404: ' + doc + ': ' + err)
129342
- throw err
129343
- }
129344
- }
129345
- return true
129346
- }
129347
- */
129348
-
129349
- /* Form for a new message
129350
- */
129322
+ // const messageTable = dom.createElement('table') // @@ check does this go in renderMessageTable
129351
129323
 
129352
129324
  earliest = {
129353
129325
  messageTable: null
@@ -129357,18 +129329,18 @@ function _infiniteMessageArea() {
129357
129329
  messageTable: null
129358
129330
  };
129359
129331
  lock = false;
129360
- _context17.next = 35;
129332
+ _context12.next = 30;
129361
129333
  return loadInitialContent();
129362
129334
 
129363
- case 35:
129364
- return _context17.abrupt("return", div);
129335
+ case 30:
129336
+ return _context12.abrupt("return", div);
129365
129337
 
129366
- case 36:
129338
+ case 31:
129367
129339
  case "end":
129368
- return _context17.stop();
129340
+ return _context12.stop();
129369
129341
  }
129370
129342
  }
129371
- }, _callee17);
129343
+ }, _callee12);
129372
129344
  }));
129373
129345
  return _infiniteMessageArea.apply(this, arguments);
129374
129346
  }
@@ -129386,6 +129358,8 @@ function _infiniteMessageArea() {
129386
129358
  "use strict";
129387
129359
 
129388
129360
 
129361
+ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/solid-ui/node_modules/@babel/runtime/helpers/interopRequireDefault.js");
129362
+
129389
129363
  var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/solid-ui/node_modules/@babel/runtime/helpers/typeof.js");
129390
129364
 
129391
129365
  Object.defineProperty(exports, "__esModule", {
@@ -129394,10 +129368,24 @@ Object.defineProperty(exports, "__esModule", {
129394
129368
  exports.creatorAndDate = creatorAndDate;
129395
129369
  exports.creatorAndDateHorizontal = creatorAndDateHorizontal;
129396
129370
  exports.elementForImageURI = elementForImageURI;
129397
- exports.renderMessage = renderMessage;
129371
+ exports.renderMessageEditor = renderMessageEditor;
129372
+ exports.renderMessageRow = renderMessageRow;
129373
+ exports.switchToEditor = switchToEditor;
129374
+
129375
+ var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/solid-ui/node_modules/@babel/runtime/regenerator/index.js"));
129376
+
129377
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/solid-ui/node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
129378
+
129379
+ var _infinite = __webpack_require__(/*! ./infinite */ "./node_modules/solid-ui/lib/chat/infinite.js");
129398
129380
 
129399
129381
  var _messageTools = __webpack_require__(/*! ./messageTools */ "./node_modules/solid-ui/lib/chat/messageTools.js");
129400
129382
 
129383
+ var _bookmarks = __webpack_require__(/*! ./bookmarks */ "./node_modules/solid-ui/lib/chat/bookmarks.js");
129384
+
129385
+ var _chatLogic = __webpack_require__(/*! ./chatLogic */ "./node_modules/solid-ui/lib/chat/chatLogic.js");
129386
+
129387
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./node_modules/solid-ui/lib/debug.js"));
129388
+
129401
129389
  var _index = __webpack_require__(/*! ../authn/index */ "./node_modules/solid-ui/lib/authn/index.js");
129402
129390
 
129403
129391
  var _iconBase = __webpack_require__(/*! ../iconBase */ "./node_modules/solid-ui/lib/iconBase.js");
@@ -129410,8 +129398,6 @@ var ns = _interopRequireWildcard(__webpack_require__(/*! ../ns */ "./node_module
129410
129398
 
129411
129399
  var pad = _interopRequireWildcard(__webpack_require__(/*! ../pad */ "./node_modules/solid-ui/lib/pad.js"));
129412
129400
 
129413
- var rdf = _interopRequireWildcard(__webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js"));
129414
-
129415
129401
  var style = _interopRequireWildcard(__webpack_require__(/*! ../style */ "./node_modules/solid-ui/lib/style.js"));
129416
129402
 
129417
129403
  var utils = _interopRequireWildcard(__webpack_require__(/*! ../utils */ "./node_modules/solid-ui/lib/utils/index.js"));
@@ -129422,31 +129408,17 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
129422
129408
 
129423
129409
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
129424
129410
 
129425
- /**
129426
- * Contains the [[renderMessage]] function,
129427
- * along with [[elementForImageURI]],
129428
- * [[creatorAndDate]], and [[creatorAndDateHorizontal]]
129429
- * @packageDocumentation
129430
- */
129411
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
129431
129412
 
129432
- /* global $rdf */
129433
- // pull in first avoid cross-refs
129434
- var UI = {
129435
- authn: _index.authn,
129436
- icons: _iconBase.icons,
129437
- ns: ns,
129438
- media: _index2.media,
129439
- pad: pad,
129440
- rdf: rdf,
129441
- store: _logic.store,
129442
- style: style,
129443
- utils: utils,
129444
- widgets: widgets
129445
- };
129446
- var dom = UI.dom || window.document; // const kb = UI.store
129413
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
129447
129414
 
129448
- var messageBodyStyle = UI.style.messageBodyStyle;
129449
- var label = UI.utils.label;
129415
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
129416
+
129417
+ // const UI = { authn, icons, ns, media, pad, rdf, store, style, utils, widgets }
129418
+ var dom = window.document; // const store = store
129419
+
129420
+ var messageBodyStyle = style.messageBodyStyle;
129421
+ var label = utils.label;
129450
129422
  /**
129451
129423
  * HTML component for an image
129452
129424
  */
@@ -129459,14 +129431,14 @@ function elementForImageURI(imageUri, options) {
129459
129431
  height = ('' + options.inlineImageHeightEms).trim();
129460
129432
  }
129461
129433
 
129462
- img.setAttribute('style', 'max-height: ' + height + 'em; border-radius: 1em; margin: 0.7em;'); // UI.widgets.makeDropTarget(img, handleURIsDroppedOnMugshot, droppedFileHandler)
129434
+ img.setAttribute('style', 'max-height: ' + height + 'em; border-radius: 1em; margin: 0.7em;'); // widgets.makeDropTarget(img, handleURIsDroppedOnMugshot, droppedFileHandler)
129463
129435
 
129464
129436
  if (imageUri) img.setAttribute('src', imageUri);
129465
129437
  var anchor = dom.createElement('a');
129466
129438
  anchor.setAttribute('href', imageUri);
129467
129439
  anchor.setAttribute('target', 'images');
129468
129440
  anchor.appendChild(img);
129469
- UI.widgets.makeDraggable(img, $rdf.sym(imageUri));
129441
+ widgets.makeDraggable(img, $rdf.sym(imageUri));
129470
129442
  return anchor;
129471
129443
  }
129472
129444
 
@@ -129476,7 +129448,7 @@ var anchor = function anchor(text, term) {
129476
129448
 
129477
129449
  if (term && term.uri) {
129478
129450
  a.setAttribute('href', term.uri);
129479
- a.addEventListener('click', UI.widgets.openHrefInOutlineMode, true);
129451
+ a.addEventListener('click', widgets.openHrefInOutlineMode, true);
129480
129452
  a.setAttribute('style', 'color: #3B5998; text-decoration: none; '); // font-weight: bold
129481
129453
  }
129482
129454
 
@@ -129485,7 +129457,8 @@ var anchor = function anchor(text, term) {
129485
129457
  };
129486
129458
 
129487
129459
  function nick(person) {
129488
- var s = UI.store.any(person, UI.ns.foaf('nick'));
129460
+ var s = _logic.store.any(person, ns.foaf('nick'));
129461
+
129489
129462
  if (s) return '' + s.value;
129490
129463
  return '' + label(person);
129491
129464
  }
@@ -129499,7 +129472,7 @@ function creatorAndDate(td1, creator, date, message) {
129499
129472
  var nickAnchor = td1.appendChild(anchor(nick(creator), creator));
129500
129473
 
129501
129474
  if (creator.uri) {
129502
- UI.store.fetcher.nowOrWhenFetched(creator.doc(), undefined, function (_ok, _body) {
129475
+ _logic.store.fetcher.nowOrWhenFetched(creator.doc(), undefined, function (_ok, _body) {
129503
129476
  nickAnchor.textContent = nick(creator);
129504
129477
  });
129505
129478
  }
@@ -129517,7 +129490,7 @@ function creatorAndDateHorizontal(td1, creator, date, message) {
129517
129490
  var nickAnchor = td1.appendChild(anchor(label(creator), creator));
129518
129491
 
129519
129492
  if (creator.uri) {
129520
- UI.store.fetcher.nowOrWhenFetched(creator.doc(), undefined, function (_ok, _body) {
129493
+ _logic.store.fetcher.nowOrWhenFetched(creator.doc(), undefined, function (_ok, _body) {
129521
129494
  nickAnchor.textContent = nick(creator);
129522
129495
  });
129523
129496
  }
@@ -129528,65 +129501,54 @@ function creatorAndDateHorizontal(td1, creator, date, message) {
129528
129501
  td1.appendChild(dom.createElement('br'));
129529
129502
  }
129530
129503
  /**
129531
- * Renders a chat message inside a `messageTable`
129504
+ * Renders a chat message, read-only mode
129532
129505
  */
129533
129506
 
129534
129507
 
129535
- function renderMessage(messageTable, bindings, fresh, options, userContext) {
129508
+ function renderMessageRow(channelObject, message, fresh, options, userContext) {
129536
129509
  var colorizeByAuthor = options.colorizeByAuthor === '1' || options.colorizeByAuthor === true;
129537
- var creator = bindings['?creator'];
129538
- var message = bindings['?msg'];
129539
- var date = bindings['?date'];
129540
- var content = bindings['?content'];
129541
- var dateString = date.value;
129542
- var messageRow = dom.createElement('tr');
129543
- messageRow.AJAR_date = dateString;
129544
- messageRow.AJAR_subject = message;
129545
129510
 
129546
- if (options.selectedMessage && options.selectedMessage.sameTerm(message)) {
129547
- messageRow.style.backgroundColor = 'yellow';
129548
- options.selectedElement = messageRow;
129549
- messageTable.selectedElement = messageRow;
129550
- }
129511
+ var creator = _logic.store.any(message, ns.foaf('maker'));
129551
129512
 
129552
- var done = false;
129513
+ var date = _logic.store.any(message, ns.dct('created'));
129553
129514
 
129554
- for (var ele = messageTable.firstChild;; ele = ele.nextSibling) {
129555
- if (!ele) {
129556
- // empty
129557
- break;
129558
- }
129515
+ var latestVersion = (0, _chatLogic.mostRecentVersion)(message);
129559
129516
 
129560
- var newestFirst = options.newestfirst === true;
129517
+ var content = _logic.store.any(latestVersion, ns.sioc('content'));
129561
129518
 
129562
- if (dateString > ele.AJAR_date && newestFirst || dateString < ele.AJAR_date && !newestFirst) {
129563
- messageTable.insertBefore(messageRow, ele);
129564
- done = true;
129565
- break;
129566
- }
129567
- }
129519
+ var originalMessage = (0, _chatLogic.originalVersion)(message);
129520
+ var edited = !message.sameTerm(originalMessage);
129521
+
129522
+ var sortDate = _logic.store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()); // In message
129568
129523
 
129569
- if (!done) {
129570
- messageTable.appendChild(messageRow);
129571
- }
129572
129524
 
129525
+ var messageRow = dom.createElement('tr');
129526
+ messageRow.AJAR_date = sortDate.value;
129527
+ messageRow.AJAR_subject = message;
129573
129528
  var td1 = dom.createElement('td');
129574
129529
  messageRow.appendChild(td1);
129575
129530
 
129576
- if (options.authorAboveContent) {
129531
+ if (!options.authorDateOnLeft) {
129577
129532
  var img = dom.createElement('img');
129578
129533
  img.setAttribute('style', 'max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;');
129579
- UI.widgets.setImage(img, creator);
129534
+ widgets.setImage(img, creator);
129580
129535
  td1.appendChild(img);
129581
129536
  } else {
129582
- creatorAndDate(td1, creator, UI.widgets.shortDate(dateString), message);
129537
+ creatorAndDate(td1, creator, widgets.shortDate(sortDate.value), message);
129538
+ }
129539
+
129540
+ var bothDates = widgets.shortDate(sortDate.value);
129541
+
129542
+ if (edited) {
129543
+ bothDates += ' ... ' + widgets.shortDate(date.value);
129583
129544
  } // Render the content ot the message itself
129584
129545
 
129585
129546
 
129586
129547
  var td2 = messageRow.appendChild(dom.createElement('td'));
129587
129548
 
129588
- if (options.authorAboveContent) {
129589
- creatorAndDateHorizontal(td2, creator, UI.widgets.shortDate(dateString), message);
129549
+ if (!options.authorDateOnLeft) {
129550
+ creatorAndDateHorizontal(td2, creator, bothDates, // widgets.shortDate(dateString)
129551
+ message);
129590
129552
  }
129591
129553
 
129592
129554
  var text = content.value.trim();
@@ -129616,7 +129578,7 @@ function renderMessage(messageTable, bindings, fresh, options, userContext) {
129616
129578
  }
129617
129579
 
129618
129580
  if (para) {
129619
- var bgcolor = colorizeByAuthor ? UI.pad.lightColorHash(creator) : getBgColor(fresh);
129581
+ var bgcolor = colorizeByAuthor ? pad.lightColorHash(creator) : getBgColor(fresh);
129620
129582
  para.setAttribute('style', messageBodyStyle + 'background-color: ' + bgcolor + ';');
129621
129583
  }
129622
129584
 
@@ -129635,7 +129597,7 @@ function renderMessage(messageTable, bindings, fresh, options, userContext) {
129635
129597
 
129636
129598
  var td3 = dom.createElement('td');
129637
129599
  messageRow.appendChild(td3);
129638
- var toolsButton = UI.widgets.button(dom, UI.icons.iconBase + 'noun_243787.svg', '...');
129600
+ var toolsButton = widgets.button(dom, _iconBase.icons.iconBase + 'noun_243787.svg', '...');
129639
129601
  td3.appendChild(toolsButton);
129640
129602
  toolsButton.addEventListener('click', function (_event) {
129641
129603
  if (messageRow.toolTR) {
@@ -129646,7 +129608,7 @@ function renderMessage(messageTable, bindings, fresh, options, userContext) {
129646
129608
  }
129647
129609
 
129648
129610
  var toolsTR = dom.createElement('tr');
129649
- var tools = (0, _messageTools.messageToolbar)(message, messageRow, userContext);
129611
+ var tools = (0, _messageTools.messageToolbar)(message, messageRow, userContext, channelObject);
129650
129612
  tools.style = 'border: 0.05em solid #888; border-radius: 0 0 0.7em 0.7em; border-top: 0; height:3.5em; background-color: #fff;'; // @@ fix
129651
129613
 
129652
129614
  if (messageRow.nextSibling) {
@@ -129665,6 +129627,390 @@ function renderMessage(messageTable, bindings, fresh, options, userContext) {
129665
129627
  });
129666
129628
  return messageRow;
129667
129629
  }
129630
+
129631
+ function switchToEditor(messageRow, message, channelObject, userContext) {
129632
+ var messageTable = messageRow.parentNode;
129633
+ var editRow = renderMessageEditor(channelObject, messageTable, userContext, channelObject.options, (0, _chatLogic.mostRecentVersion)(message));
129634
+ messageTable.insertBefore(editRow, messageRow);
129635
+ editRow.originalRow = messageRow;
129636
+ messageRow.style.visibility = 'hidden'; // Hide the original message. unhide if user cancels edit
129637
+ }
129638
+ /* Control for a new message -- or editing an old message ***************
129639
+ *
129640
+ */
129641
+
129642
+
129643
+ function renderMessageEditor(channelObject, messageTable, userContext, options, originalMessage) {
129644
+ function revertEditing(messageEditor) {
129645
+ messageEditor.originalRow.style.visibility = 'visible'; // restore read-only version
129646
+
129647
+ messageEditor.parentNode.removeChild(messageEditor);
129648
+ }
129649
+
129650
+ function handleFieldInput(_x) {
129651
+ return _handleFieldInput.apply(this, arguments);
129652
+ }
129653
+
129654
+ function _handleFieldInput() {
129655
+ _handleFieldInput = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(_event) {
129656
+ return _regenerator["default"].wrap(function _callee5$(_context6) {
129657
+ while (1) {
129658
+ switch (_context6.prev = _context6.next) {
129659
+ case 0:
129660
+ _context6.next = 2;
129661
+ return sendMessage(field.value, true);
129662
+
129663
+ case 2:
129664
+ case "end":
129665
+ return _context6.stop();
129666
+ }
129667
+ }
129668
+ }, _callee5);
129669
+ }));
129670
+ return _handleFieldInput.apply(this, arguments);
129671
+ }
129672
+
129673
+ function sendMessage(_x2, _x3) {
129674
+ return _sendMessage.apply(this, arguments);
129675
+ } // sendMessage
129676
+ // DRAG AND DROP
129677
+
129678
+
129679
+ function _sendMessage() {
129680
+ _sendMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(text, fromMainField) {
129681
+ var sendComplete, message, statusArea;
129682
+ return _regenerator["default"].wrap(function _callee6$(_context7) {
129683
+ while (1) {
129684
+ switch (_context7.prev = _context7.next) {
129685
+ case 0:
129686
+ sendComplete = function _sendComplete(message, _text2) {
129687
+ // const dateStamp = store.any(message, ns.dct('created'), null, message.doc())
129688
+ // const content = $rdf.literal(text2)
129689
+ (0, _infinite.insertMessageIntoTable)(channelObject, messageTable, message, false, options, userContext); // not green
129690
+
129691
+ if (originalMessage) {
129692
+ // editing another message
129693
+ var oldRow = messageEditor.originalRow; // oldRow.style.display = '' // restore read-only version, re-attack
129694
+
129695
+ if (oldRow.parentNode) {
129696
+ oldRow.parentNode.removeChild(oldRow); // No longer needed old version
129697
+ } else {
129698
+ debug.warn('No parentNode on old message ' + oldRow.textContent);
129699
+ oldRow.style.backgroundColor = '#fee';
129700
+ oldRow.style.visibility = 'hidden'; // @@ FIX THIS AND REMOVE FROM DOM INSTEAD
129701
+ }
129702
+
129703
+ messageEditor.parentNode.removeChild(messageEditor); // no longer need editor
129704
+ } else {
129705
+ if (fromMainField) {
129706
+ field.value = ''; // clear from out for reuse
129707
+
129708
+ field.setAttribute('style', messageBodyStyle);
129709
+ field.disabled = false;
129710
+ field.scrollIntoView(options.newestFirst); // allign bottom (top)
129711
+
129712
+ field.focus(); // Start typing next line immediately
129713
+
129714
+ field.select();
129715
+ }
129716
+ } // await channelObject.div.refresh() // Add new day if nec @@ add back
129717
+
129718
+ };
129719
+
129720
+ // const me = authn.currentUser() // Must be logged on or wuld have got login button
129721
+ if (fromMainField) {
129722
+ field.setAttribute('style', messageBodyStyle + 'color: #bbb;'); // pendingedit
129723
+
129724
+ field.disabled = true;
129725
+ }
129726
+
129727
+ _context7.prev = 2;
129728
+ _context7.next = 5;
129729
+ return channelObject.updateMessage(text, originalMessage);
129730
+
129731
+ case 5:
129732
+ message = _context7.sent;
129733
+ _context7.next = 13;
129734
+ break;
129735
+
129736
+ case 8:
129737
+ _context7.prev = 8;
129738
+ _context7.t0 = _context7["catch"](2);
129739
+ statusArea = userContext.statusArea || messageEditor;
129740
+ statusArea.appendChild(widgets.errorMessageBlock(dom, 'Error writing message: ' + _context7.t0));
129741
+ return _context7.abrupt("return");
129742
+
129743
+ case 13:
129744
+ sendComplete(message, text);
129745
+
129746
+ case 14:
129747
+ case "end":
129748
+ return _context7.stop();
129749
+ }
129750
+ }
129751
+ }, _callee6, null, [[2, 8]]);
129752
+ }));
129753
+ return _sendMessage.apply(this, arguments);
129754
+ }
129755
+
129756
+ function droppedFileHandler(files) {
129757
+ var base = messageTable.chatDocument.dir().uri;
129758
+ widgets.uploadFiles(_logic.store.fetcher, files, base + 'Files', base + 'Pictures', /*#__PURE__*/function () {
129759
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(theFile, destURI) {
129760
+ return _regenerator["default"].wrap(function _callee$(_context2) {
129761
+ while (1) {
129762
+ switch (_context2.prev = _context2.next) {
129763
+ case 0:
129764
+ _context2.next = 2;
129765
+ return sendMessage(destURI);
129766
+
129767
+ case 2:
129768
+ case "end":
129769
+ return _context2.stop();
129770
+ }
129771
+ }
129772
+ }, _callee);
129773
+ }));
129774
+
129775
+ return function (_x4, _x5) {
129776
+ return _ref.apply(this, arguments);
129777
+ };
129778
+ }());
129779
+ } // When a set of URIs are dropped on the field
129780
+
129781
+
129782
+ var droppedURIHandler = /*#__PURE__*/function () {
129783
+ var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(uris) {
129784
+ var _iterator, _step, uri;
129785
+
129786
+ return _regenerator["default"].wrap(function _callee2$(_context3) {
129787
+ while (1) {
129788
+ switch (_context3.prev = _context3.next) {
129789
+ case 0:
129790
+ _iterator = _createForOfIteratorHelper(uris);
129791
+ _context3.prev = 1;
129792
+
129793
+ _iterator.s();
129794
+
129795
+ case 3:
129796
+ if ((_step = _iterator.n()).done) {
129797
+ _context3.next = 9;
129798
+ break;
129799
+ }
129800
+
129801
+ uri = _step.value;
129802
+ _context3.next = 7;
129803
+ return sendMessage(uri);
129804
+
129805
+ case 7:
129806
+ _context3.next = 3;
129807
+ break;
129808
+
129809
+ case 9:
129810
+ _context3.next = 14;
129811
+ break;
129812
+
129813
+ case 11:
129814
+ _context3.prev = 11;
129815
+ _context3.t0 = _context3["catch"](1);
129816
+
129817
+ _iterator.e(_context3.t0);
129818
+
129819
+ case 14:
129820
+ _context3.prev = 14;
129821
+
129822
+ _iterator.f();
129823
+
129824
+ return _context3.finish(14);
129825
+
129826
+ case 17:
129827
+ case "end":
129828
+ return _context3.stop();
129829
+ }
129830
+ }
129831
+ }, _callee2, null, [[1, 11, 14, 17]]);
129832
+ }));
129833
+
129834
+ return function droppedURIHandler(_x6) {
129835
+ return _ref2.apply(this, arguments);
129836
+ };
129837
+ }(); // When we are actually logged on
129838
+
129839
+
129840
+ function turnOnInput() {
129841
+ function getImageDoc() {
129842
+ imageDoc = $rdf.sym(chatDocument.dir().uri + 'Image_' + Date.now() + '.png');
129843
+ return imageDoc;
129844
+ }
129845
+
129846
+ function tookPicture(_x7) {
129847
+ return _tookPicture.apply(this, arguments);
129848
+ } // Body of turnOnInput
129849
+
129850
+
129851
+ function _tookPicture() {
129852
+ _tookPicture = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(imageDoc) {
129853
+ return _regenerator["default"].wrap(function _callee4$(_context5) {
129854
+ while (1) {
129855
+ switch (_context5.prev = _context5.next) {
129856
+ case 0:
129857
+ if (!imageDoc) {
129858
+ _context5.next = 3;
129859
+ break;
129860
+ }
129861
+
129862
+ _context5.next = 3;
129863
+ return sendMessage(imageDoc.uri);
129864
+
129865
+ case 3:
129866
+ case "end":
129867
+ return _context5.stop();
129868
+ }
129869
+ }
129870
+ }, _callee4);
129871
+ }));
129872
+ return _tookPicture.apply(this, arguments);
129873
+ }
129874
+
129875
+ var menuButton;
129876
+
129877
+ if (options.menuHandler) {
129878
+ var _menuButton = widgets.button(dom, _iconBase.icons.iconBase + 'noun_243787.svg', 'More');
129879
+
129880
+ _menuButton.setAttribute('style', style.buttonStyle + 'float: right;'); // menuButton.addEventListener('click', _event => sendMessage(), false) (done in turnoninput)
129881
+
129882
+
129883
+ rhs.appendChild(_menuButton);
129884
+ }
129885
+
129886
+ if (options.menuHandler && menuButton) {
129887
+ var _me = _index.authn.currentUser();
129888
+
129889
+ var menuOptions = {
129890
+ me: _me,
129891
+ dom: dom,
129892
+ div: null,
129893
+ // @@ was: div
129894
+ newBase: messageTable.chatDocument.dir().uri
129895
+ };
129896
+ menuButton.addEventListener('click', function (event) {
129897
+ options.menuHandler(event, channelObject.chatChannel, menuOptions);
129898
+ }, false);
129899
+ }
129900
+
129901
+ var me = _index.authn.currentUser(); // If already logged on
129902
+
129903
+
129904
+ creatorAndDate(lhs, me, '', null);
129905
+ field = dom.createElement('textarea');
129906
+ middle.innerHTML = '';
129907
+ middle.appendChild(field);
129908
+ field.rows = 3;
129909
+
129910
+ if (originalMessage) {
129911
+ field.value = _logic.store.anyValue(originalMessage, ns.sioc('content'), null, originalMessage.doc());
129912
+ } // field.cols = 40
129913
+
129914
+
129915
+ field.setAttribute('style', messageBodyStyle + 'background-color: #eef;'); // Trap the Enter BEFORE it is used ti make a newline
129916
+
129917
+ field.addEventListener('keydown', /*#__PURE__*/function () {
129918
+ var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(e) {
129919
+ return _regenerator["default"].wrap(function _callee3$(_context4) {
129920
+ while (1) {
129921
+ switch (_context4.prev = _context4.next) {
129922
+ case 0:
129923
+ if (!(e.code === 'Enter')) {
129924
+ _context4.next = 4;
129925
+ break;
129926
+ }
129927
+
129928
+ if (!(!e.shiftKey && !options.shiftEnterSendsMessage || e.shiftKey && options.shiftEnterSendsMessage)) {
129929
+ _context4.next = 4;
129930
+ break;
129931
+ }
129932
+
129933
+ _context4.next = 4;
129934
+ return handleFieldInput(e);
129935
+
129936
+ case 4:
129937
+ case "end":
129938
+ return _context4.stop();
129939
+ }
129940
+ }
129941
+ }, _callee3);
129942
+ }));
129943
+
129944
+ return function (_x8) {
129945
+ return _ref3.apply(this, arguments);
129946
+ };
129947
+ }(), false);
129948
+ widgets.makeDropTarget(field, droppedURIHandler, droppedFileHandler);
129949
+ rhs.innerHTML = '';
129950
+ sendButton = widgets.button(dom, sendIcon, 'Send');
129951
+ sendButton.style["float"] = 'right';
129952
+ sendButton.addEventListener('click', function (_event) {
129953
+ return handleFieldInput();
129954
+ }, false);
129955
+ rhs.appendChild(sendButton);
129956
+
129957
+ if (originalMessage) {
129958
+ // Are we editing another message?
129959
+ var cancelButton = rhs.appendChild(widgets.cancelButton(dom));
129960
+ cancelButton.style["float"] = 'left'; // cancelButton.firstChild.style.opacity = '0.3' // moved to buttons
129961
+
129962
+ cancelButton.addEventListener('click', function (_event) {
129963
+ return revertEditing(messageEditor);
129964
+ }, false);
129965
+ rhs.appendChild(cancelButton);
129966
+ }
129967
+
129968
+ var chatDocument = channelObject.dateFolder.leafDocumentFromDate(new Date());
129969
+ var imageDoc;
129970
+ middle.appendChild(_index2.media.cameraButton(dom, _logic.store, getImageDoc, tookPicture));
129971
+ pad.recordParticipation(channelObject.channel, channelObject.channel.doc()); // participation =
129972
+ } // turn on inpuut
129973
+ // Body of renderMessageEditor
129974
+
129975
+
129976
+ var sortDate, sendIcon;
129977
+
129978
+ if (originalMessage) {
129979
+ sortDate = _logic.store.anyValue(originalMessage, ns.dct('created'), null, originalMessage.doc()); // text = store.anyValue(originalMessage, ns.sioc('content'), null, originalMessage.doc())
129980
+
129981
+ sendIcon = _iconBase.icons.iconBase + 'noun_1180158.svg'; // Green check
129982
+ // cancelIcon = icons.iconBase + 'noun_1180156.svg' // Black cross
129983
+ } else {
129984
+ sendIcon = _iconBase.icons.iconBase + 'noun_383448.svg';
129985
+ sortDate = '9999-01-01T00:00:00Z'; // ISO format for field sort
129986
+ // text = ''
129987
+ }
129988
+
129989
+ var messageEditor = dom.createElement('tr');
129990
+ var lhs = dom.createElement('td');
129991
+ var middle = dom.createElement('td');
129992
+ var rhs = dom.createElement('td');
129993
+ messageEditor.appendChild(lhs);
129994
+ messageEditor.appendChild(middle);
129995
+ messageEditor.appendChild(rhs);
129996
+ messageEditor.AJAR_date = sortDate; // messageEditor.appendChild(dom.createElement('br'))
129997
+
129998
+ var field, sendButton;
129999
+ var context = {
130000
+ div: middle,
130001
+ dom: dom
130002
+ };
130003
+
130004
+ _index.authn.logIn(context).then(function (context) {
130005
+ // me = context.me
130006
+ turnOnInput();
130007
+ Object.assign(context, userContext);
130008
+ (0, _bookmarks.findBookmarkDocument)(context).then(function (_context) {// console.log('Bookmark file: ' + context.bookmarkDocument)
130009
+ });
130010
+ });
130011
+
130012
+ return messageEditor;
130013
+ } // renderMessageEditor
129668
130014
  //# sourceMappingURL=message.js.map
129669
130015
 
129670
130016
  /***/ }),
@@ -129696,28 +130042,28 @@ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/r
129696
130042
 
129697
130043
  var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "./node_modules/solid-ui/node_modules/@babel/runtime/helpers/slicedToArray.js"));
129698
130044
 
130045
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./node_modules/solid-ui/lib/debug.js"));
130046
+
129699
130047
  var _index = __webpack_require__(/*! ../authn/index */ "./node_modules/solid-ui/lib/authn/index.js");
129700
130048
 
129701
130049
  var _iconBase = __webpack_require__(/*! ../iconBase */ "./node_modules/solid-ui/lib/iconBase.js");
129702
130050
 
129703
130051
  var _logic = __webpack_require__(/*! ../logic */ "./node_modules/solid-ui/lib/logic.js");
129704
130052
 
129705
- var _index2 = __webpack_require__(/*! ../media/index */ "./node_modules/solid-ui/lib/media/index.js");
129706
-
129707
130053
  var ns = _interopRequireWildcard(__webpack_require__(/*! ../ns */ "./node_modules/solid-ui/lib/ns.js"));
129708
130054
 
129709
- var pad = _interopRequireWildcard(__webpack_require__(/*! ../pad */ "./node_modules/solid-ui/lib/pad.js"));
129710
-
129711
130055
  var rdf = _interopRequireWildcard(__webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js"));
129712
130056
 
129713
- var style = _interopRequireWildcard(__webpack_require__(/*! ../style */ "./node_modules/solid-ui/lib/style.js"));
129714
-
129715
130057
  var utils = _interopRequireWildcard(__webpack_require__(/*! ../utils */ "./node_modules/solid-ui/lib/utils/index.js"));
129716
130058
 
129717
130059
  var widgets = _interopRequireWildcard(__webpack_require__(/*! ../widgets */ "./node_modules/solid-ui/lib/widgets/index.js"));
129718
130060
 
129719
130061
  var _bookmarks = __webpack_require__(/*! ./bookmarks */ "./node_modules/solid-ui/lib/chat/bookmarks.js");
129720
130062
 
130063
+ var _chatLogic = __webpack_require__(/*! ./chatLogic */ "./node_modules/solid-ui/lib/chat/chatLogic.js");
130064
+
130065
+ var _message = __webpack_require__(/*! ./message */ "./node_modules/solid-ui/lib/chat/message.js");
130066
+
129721
130067
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
129722
130068
 
129723
130069
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -129731,52 +130077,29 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
129731
130077
  * If you made it originally: edit, delete, attach
129732
130078
  * @packageDocumentation
129733
130079
  */
129734
-
129735
- /* global $rdf */
130080
+ // import { media } from '../media/index'
130081
+ // import * as pad from '../pad'
129736
130082
  // pull in first avoid cross-refs
129737
- var UI = {
129738
- authn: _index.authn,
129739
- icons: _iconBase.icons,
129740
- ns: ns,
129741
- media: _index2.media,
129742
- pad: pad,
129743
- rdf: rdf,
129744
- store: _logic.store,
129745
- style: style,
129746
- utils: utils,
129747
- widgets: widgets
129748
- };
129749
- var dom = window.document;
129750
- var kb = _logic.store; // const label = UI.utils.label
129751
- // THE UNUSED ICONS are here as reminders for possible future functionality
130083
+ // import * as style from '../style'
130084
+ // import { infiniteMessageArea } from './infinite.js'
130085
+ // import { renderMessage, creatorAndDate } from './message'
130086
+ // import * as debug from '../debug'
130087
+ var dom = window.document; // THE UNUSED ICONS are here as reminders for possible future functionality
129752
130088
  // const BOOKMARK_ICON = 'noun_45961.svg'
129753
130089
  // const HEART_ICON = 'noun_130259.svg' -> Add this to my (private) favorites
129754
130090
  // const MENU_ICON = 'noun_897914.svg'
129755
130091
  // const PAPERCLIP_ICON = 'noun_25830.svg' -> add attachments to this message
129756
130092
  // const PIN_ICON = 'noun_562340.svg' -> pin this message permanently in the chat UI
129757
- // const PENCIL_ICON = 'noun_253504.svg'
130093
+
130094
+ var PENCIL_ICON = 'noun_253504.svg'; // edit a message
129758
130095
  // const SPANNER_ICON = 'noun_344563.svg' -> settings
129759
130096
 
129760
130097
  var THUMBS_UP_ICON = 'noun_1384132.svg';
129761
- var THUMBS_DOWN_ICON = 'noun_1384135.svg'; // module.export = { messageTools, sentimentStripLinked, sentimentStrip }
129762
- // @@@@ use the one in rdflib.js when it is avaiable and delete this
129763
-
129764
- function updatePromise(del, ins) {
129765
- return new Promise(function (resolve, reject) {
129766
- kb.updater.update(del, ins, function (uri, ok, errorBody) {
129767
- if (!ok) {
129768
- reject(new Error(errorBody));
129769
- } else {
129770
- resolve();
129771
- }
129772
- }); // callback
129773
- }); // promise
129774
- }
130098
+ var THUMBS_DOWN_ICON = 'noun_1384135.svg';
129775
130099
  /**
129776
130100
  * Emoji in Unicode
129777
130101
  */
129778
130102
 
129779
-
129780
130103
  var emoji = {};
129781
130104
  emoji[ns.schema('AgreeAction')] = '👍';
129782
130105
  emoji[ns.schema('DisagreeAction')] = '👎';
@@ -129787,9 +130110,11 @@ emoji[ns.schema('LikeAction')] = '❤️';
129787
130110
  */
129788
130111
 
129789
130112
  function sentimentStrip(target, doc) {
129790
- var actions = kb.each(null, ns.schema('target'), target, doc);
130113
+ // alain seems not used
130114
+ var latest = (0, _chatLogic.mostRecentVersion)(target);
130115
+ var actions = _logic.store.holds(latest, ns.schema('dateDeleted').value, null, latest.doc()) ? _logic.store.each(null, ns.schema('target'), target, doc) : [];
129791
130116
  var sentiments = actions.map(function (a) {
129792
- return kb.any(a, ns.rdf('type'), null, doc);
130117
+ return _logic.store.any(a, ns.rdf('type'), null, doc);
129793
130118
  });
129794
130119
  sentiments.sort();
129795
130120
  var strings = sentiments.map(function (x) {
@@ -129810,9 +130135,9 @@ function sentimentStripLinked(target, doc) {
129810
130135
 
129811
130136
  function refresh() {
129812
130137
  strip.innerHTML = '';
129813
- var actions = kb.each(null, ns.schema('target'), target, doc);
130138
+ var actions = (0, _chatLogic.mostRecentVersion)(target).uri !== ns.schema('dateDeleted').uri ? _logic.store.each(null, ns.schema('target'), target, doc) : [];
129814
130139
  var sentiments = actions.map(function (a) {
129815
- return [kb.any(a, ns.rdf('type'), null, doc), kb.any(a, ns.schema('agent'), null, doc)];
130140
+ return [_logic.store.any(a, ns.rdf('type'), null, doc), _logic.store.any(a, ns.schema('agent'), null, doc)];
129816
130141
  });
129817
130142
  sentiments.sort();
129818
130143
  sentiments.forEach(function (ss) {
@@ -129843,60 +130168,142 @@ function sentimentStripLinked(target, doc) {
129843
130168
  */
129844
130169
 
129845
130170
 
129846
- function messageToolbar(message, messageRow, userContext) {
129847
- var div = dom.createElement('div');
130171
+ function messageToolbar(message, messageRow, userContext, channelObject) {
130172
+ function deleteMessage() {
130173
+ return _deleteMessage.apply(this, arguments);
130174
+ }
129848
130175
 
129849
- function closeToolbar() {
129850
- div.parentElement.parentElement.removeChild(div.parentElement); // remive the TR
130176
+ function _deleteMessage() {
130177
+ _deleteMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
130178
+ var author, msg, area;
130179
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
130180
+ while (1) {
130181
+ switch (_context2.prev = _context2.next) {
130182
+ case 0:
130183
+ author = _logic.store.any(message, ns.foaf('maker'));
130184
+
130185
+ if (me) {
130186
+ _context2.next = 5;
130187
+ break;
130188
+ }
130189
+
130190
+ alert('You can\'t delete the message, you are not logged in.');
130191
+ _context2.next = 22;
130192
+ break;
130193
+
130194
+ case 5:
130195
+ if (!me.sameTerm(author)) {
130196
+ _context2.next = 21;
130197
+ break;
130198
+ }
130199
+
130200
+ _context2.prev = 6;
130201
+ _context2.next = 9;
130202
+ return channelObject.deleteMessage(message);
130203
+
130204
+ case 9:
130205
+ _context2.next = 18;
130206
+ break;
130207
+
130208
+ case 11:
130209
+ _context2.prev = 11;
130210
+ _context2.t0 = _context2["catch"](6);
130211
+ msg = 'Error deleting messaage ' + _context2.t0;
130212
+ debug.warn(msg);
130213
+ alert(msg);
130214
+ area = userContext.statusArea || messageRow.parentNode;
130215
+ area.appendChild(widgets.errorMessageBlock(dom, msg));
130216
+
130217
+ case 18:
130218
+ messageRow.parentNode.removeChild(messageRow);
130219
+ _context2.next = 22;
130220
+ break;
130221
+
130222
+ case 21:
130223
+ alert('You can\'t delete the message, you are not logged in as the author, ' + author);
130224
+
130225
+ case 22:
130226
+ closeToolbar();
130227
+
130228
+ case 23:
130229
+ case "end":
130230
+ return _context2.stop();
130231
+ }
130232
+ }
130233
+ }, _callee2, null, [[6, 11]]);
130234
+ }));
130235
+ return _deleteMessage.apply(this, arguments);
129851
130236
  }
129852
130237
 
129853
- function deleteThingThen(_x) {
129854
- return _deleteThingThen.apply(this, arguments);
129855
- } // Things only the original author can do
130238
+ function editMessage(_x) {
130239
+ return _editMessage.apply(this, arguments);
130240
+ } // alain TODO allow chat owner to fully delete message + sentiments and replacing messages
129856
130241
 
129857
130242
 
129858
- function _deleteThingThen() {
129859
- _deleteThingThen = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(x) {
130243
+ function _editMessage() {
130244
+ _editMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(messageRow) {
129860
130245
  return _regenerator["default"].wrap(function _callee3$(_context3) {
129861
130246
  while (1) {
129862
130247
  switch (_context3.prev = _context3.next) {
129863
130248
  case 0:
129864
- _context3.next = 2;
129865
- return updatePromise(kb.connectedStatements(x), []);
130249
+ if (me.value === _logic.store.any(message, ns.foaf('maker')).value) {
130250
+ closeToolbar(); // edit is a one-off action
129866
130251
 
129867
- case 2:
130252
+ (0, _message.switchToEditor)(messageRow, message, channelObject, userContext);
130253
+ }
130254
+
130255
+ case 1:
129868
130256
  case "end":
129869
130257
  return _context3.stop();
129870
130258
  }
129871
130259
  }
129872
130260
  }, _callee3);
129873
130261
  }));
129874
- return _deleteThingThen.apply(this, arguments);
130262
+ return _editMessage.apply(this, arguments);
129875
130263
  }
129876
130264
 
129877
- var me = UI.authn.currentUser(); // If already logged on
130265
+ var div = dom.createElement('div'); // is message deleted ?
129878
130266
 
129879
- if (me && kb.holds(message, ns.foaf('maker'), me)) {
129880
- // button to delete the message
129881
- var deleteButton = UI.widgets.deleteButtonWithCheck(dom, div, 'message', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
129882
- return _regenerator["default"].wrap(function _callee$(_context) {
130267
+ if ((0, _chatLogic.mostRecentVersion)(message).value === ns.schema('dateDeleted').value) return div;
130268
+
130269
+ function closeToolbar() {
130270
+ div.parentElement.parentElement.removeChild(div.parentElement); // remive the TR
130271
+ }
130272
+
130273
+ function deleteThingThen(_x2) {
130274
+ return _deleteThingThen.apply(this, arguments);
130275
+ } // Things only the original author can do
130276
+
130277
+
130278
+ function _deleteThingThen() {
130279
+ _deleteThingThen = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(x) {
130280
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
129883
130281
  while (1) {
129884
- switch (_context.prev = _context.next) {
130282
+ switch (_context4.prev = _context4.next) {
129885
130283
  case 0:
129886
- _context.next = 2;
129887
- return kb.updater.update(kb.connectedStatements[message], []);
130284
+ _context4.next = 2;
130285
+ return _logic.store.updater.update(_logic.store.connectedStatements(x), []);
129888
130286
 
129889
130287
  case 2:
129890
- closeToolbar();
129891
-
129892
- case 3:
129893
130288
  case "end":
129894
- return _context.stop();
130289
+ return _context4.stop();
129895
130290
  }
129896
130291
  }
129897
- }, _callee);
129898
- })));
129899
- div.appendChild(deleteButton);
130292
+ }, _callee4);
130293
+ }));
130294
+ return _deleteThingThen.apply(this, arguments);
130295
+ }
130296
+
130297
+ var me = _index.authn.currentUser(); // If already logged on
130298
+
130299
+
130300
+ if (me && _logic.store.holds(message, ns.foaf('maker'), me)) {
130301
+ // button to delete the message
130302
+ div.appendChild(widgets.deleteButtonWithCheck(dom, div, 'message', deleteMessage)); // button to edit the message
130303
+
130304
+ div.appendChild(widgets.button(dom, _iconBase.icons.iconBase + PENCIL_ICON, 'edit', function () {
130305
+ return editMessage(messageRow);
130306
+ }));
129900
130307
  } // if mine
129901
130308
  // Things anyone can do if they have a bookmark list async
129902
130309
 
@@ -129927,39 +130334,39 @@ function messageToolbar(message, messageRow, userContext) {
129927
130334
  button.style.backgroundColor = action ? 'yellow' : 'white';
129928
130335
  }
129929
130336
 
129930
- var button = UI.widgets.button(dom, icon, UI.utils.label(actionClass), /*#__PURE__*/function () {
129931
- var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(_event) {
130337
+ var button = widgets.button(dom, icon, utils.label(actionClass), /*#__PURE__*/function () {
130338
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_event) {
129932
130339
  var insertMe, dirty, i, a;
129933
- return _regenerator["default"].wrap(function _callee2$(_context2) {
130340
+ return _regenerator["default"].wrap(function _callee$(_context) {
129934
130341
  while (1) {
129935
- switch (_context2.prev = _context2.next) {
130342
+ switch (_context.prev = _context.next) {
129936
130343
  case 0:
129937
130344
  if (!action) {
129938
- _context2.next = 7;
130345
+ _context.next = 7;
129939
130346
  break;
129940
130347
  }
129941
130348
 
129942
- _context2.next = 3;
130349
+ _context.next = 3;
129943
130350
  return deleteThingThen(action);
129944
130351
 
129945
130352
  case 3:
129946
130353
  action = null;
129947
130354
  setColor();
129948
- _context2.next = 25;
130355
+ _context.next = 25;
129949
130356
  break;
129950
130357
 
129951
130358
  case 7:
129952
130359
  // no action
129953
- action = UI.widgets.newThing(doc);
129954
- 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)];
129955
- _context2.next = 11;
129956
- return updatePromise([], insertMe);
130360
+ action = widgets.newThing(doc);
130361
+ 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)];
130362
+ _context.next = 11;
130363
+ return _logic.store.updater.update([], insertMe);
129957
130364
 
129958
130365
  case 11:
129959
130366
  setColor();
129960
130367
 
129961
130368
  if (!mutuallyExclusive) {
129962
- _context2.next = 25;
130369
+ _context.next = 25;
129963
130370
  break;
129964
130371
  }
129965
130372
 
@@ -129969,18 +130376,18 @@ function messageToolbar(message, messageRow, userContext) {
129969
130376
 
129970
130377
  case 15:
129971
130378
  if (!(i < mutuallyExclusive.length)) {
129972
- _context2.next = 24;
130379
+ _context.next = 24;
129973
130380
  break;
129974
130381
  }
129975
130382
 
129976
130383
  a = existingAction(mutuallyExclusive[i]);
129977
130384
 
129978
130385
  if (!a) {
129979
- _context2.next = 21;
130386
+ _context.next = 21;
129980
130387
  break;
129981
130388
  }
129982
130389
 
129983
- _context2.next = 20;
130390
+ _context.next = 20;
129984
130391
  return deleteThingThen(a);
129985
130392
 
129986
130393
  case 20:
@@ -129989,34 +130396,35 @@ function messageToolbar(message, messageRow, userContext) {
129989
130396
 
129990
130397
  case 21:
129991
130398
  i++;
129992
- _context2.next = 15;
130399
+ _context.next = 15;
129993
130400
  break;
129994
130401
 
129995
130402
  case 24:
129996
130403
  if (dirty) {
129997
- // UI.widgets.refreshTree(button.parentNode) // requires them all to be immediate siblings
129998
- UI.widgets.refreshTree(messageRow); // requires them all to be immediate siblings
130404
+ // widgets.refreshTree(button.parentNode) // requires them all to be immediate siblings
130405
+ widgets.refreshTree(messageRow); // requires them all to be immediate siblings
129999
130406
  }
130000
130407
 
130001
130408
  case 25:
130002
130409
  case "end":
130003
- return _context2.stop();
130410
+ return _context.stop();
130004
130411
  }
130005
130412
  }
130006
- }, _callee2);
130413
+ }, _callee);
130007
130414
  }));
130008
130415
 
130009
- return function (_x2) {
130010
- return _ref2.apply(this, arguments);
130416
+ return function (_x3) {
130417
+ return _ref.apply(this, arguments);
130011
130418
  };
130012
130419
  }());
130013
130420
 
130014
130421
  function existingAction(actionClass) {
130015
- var actions = kb.each(null, ns.schema('agent'), context.me, doc).filter(function (x) {
130016
- return kb.holds(x, ns.rdf('type'), actionClass, doc);
130422
+ var actions = _logic.store.each(null, ns.schema('agent'), context.me, doc).filter(function (x) {
130423
+ return _logic.store.holds(x, ns.rdf('type'), actionClass, doc);
130017
130424
  }).filter(function (x) {
130018
- return kb.holds(x, ns.schema('target'), target, doc);
130425
+ return _logic.store.holds(x, ns.schema('target'), target, doc);
130019
130426
  });
130427
+
130020
130428
  return actions.length ? actions[0] : null;
130021
130429
  }
130022
130430
 
@@ -130034,23 +130442,23 @@ function messageToolbar(message, messageRow, userContext) {
130034
130442
  // https://schema.org/AgreeAction
130035
130443
 
130036
130444
 
130037
- me = UI.authn.currentUser(); // If already logged on
130445
+ me = _index.authn.currentUser(); // If already logged on
130446
+ // debug.log('Actions 3' + mostRecentVersion(message).value + ' ' + ns.schema('dateDeleted').value + ' ' + (mostRecentVersion(message).value !== ns.schema('dateDeleted').value))
130038
130447
 
130039
- if (me) {
130040
- // Things you mnust be logged in for
130448
+ if (me && (0, _chatLogic.mostRecentVersion)(message).value !== ns.schema('dateDeleted').value) {
130041
130449
  var context1 = {
130042
130450
  me: me,
130043
130451
  dom: dom,
130044
130452
  div: div
130045
130453
  };
130046
- div.appendChild(sentimentButton(context1, message, // @@ TODO use UI.widgets.sentimentButton
130047
- UI.icons.iconBase + THUMBS_UP_ICON, ns.schema('AgreeAction'), message.doc(), [ns.schema('DisagreeAction')])); // Thumbs down
130454
+ div.appendChild(sentimentButton(context1, message, // @@ TODO use widgets.sentimentButton
130455
+ _iconBase.icons.iconBase + THUMBS_UP_ICON, ns.schema('AgreeAction'), message.doc(), [ns.schema('DisagreeAction')])); // Thumbs down
130048
130456
 
130049
- div.appendChild(sentimentButton(context1, message, UI.icons.iconBase + THUMBS_DOWN_ICON, ns.schema('DisagreeAction'), message.doc(), [ns.schema('AgreeAction')]));
130457
+ div.appendChild(sentimentButton(context1, message, _iconBase.icons.iconBase + THUMBS_DOWN_ICON, ns.schema('DisagreeAction'), message.doc(), [ns.schema('AgreeAction')]));
130050
130458
  } // X button to remove the tool UI itself
130051
130459
 
130052
130460
 
130053
- var cancelButton = div.appendChild(UI.widgets.cancelButton(dom));
130461
+ var cancelButton = div.appendChild(widgets.cancelButton(dom));
130054
130462
  cancelButton.style["float"] = 'right';
130055
130463
  cancelButton.firstChild.style.opacity = '0.3';
130056
130464
  cancelButton.addEventListener('click', closeToolbar);
@@ -137683,10 +138091,10 @@ Object.defineProperty(exports, "__esModule", {
137683
138091
  });
137684
138092
  exports["default"] = void 0;
137685
138093
  var _default = {
137686
- buildTime: '2022-01-27T19:22:56Z',
137687
- commit: 'fb2b21e1e0c28c850c52cb27596b0bd4d509a104',
138094
+ buildTime: '2022-01-28T22:55:43Z',
138095
+ commit: '9d83fb1702a1835b5d82fb97bc51b3cb98285373',
137688
138096
  npmInfo: {
137689
- 'solid-ui': '2.4.15',
138097
+ 'solid-ui': '2.4.16',
137690
138098
  npm: '6.14.15',
137691
138099
  ares: '1.18.1',
137692
138100
  brotli: '1.0.9',
@@ -138405,7 +138813,14 @@ function button(dom, iconURI, text, handler) {
138405
138813
 
138406
138814
 
138407
138815
  function cancelButton(dom, handler) {
138408
- return button(dom, cancelIconURI, 'Cancel', handler);
138816
+ var b = button(dom, cancelIconURI, 'Cancel', handler);
138817
+
138818
+ if (b.firstChild) {
138819
+ // sigh for tsc
138820
+ b.firstChild.style.opacity = '0.3'; // Black X is too harsh: current language is grey X
138821
+ }
138822
+
138823
+ return b;
138409
138824
  }
138410
138825
  /* Make a continue button
138411
138826
  *
@@ -148644,25 +149059,25 @@ __webpack_require__.r(__webpack_exports__);
148644
149059
  "use strict";
148645
149060
  __webpack_require__.r(__webpack_exports__);
148646
149061
  /* harmony default export */ __webpack_exports__["default"] = ({
148647
- buildTime: '2022-01-28T10:38:24Z',
148648
- commit: '276e51de4e74a2af05c93703391d461c3bdc82f2',
149062
+ buildTime: '2022-01-29T08:33:53Z',
149063
+ commit: '204bf279ab2b15a81bb328b56940aac00cec94b1',
148649
149064
  npmInfo: {
148650
- mashlib: '1.7.17',
148651
- npm: '6.14.13',
148652
- ares: '1.17.1',
149065
+ mashlib: '1.7.18',
149066
+ npm: '6.14.15',
149067
+ ares: '1.18.1',
148653
149068
  brotli: '1.0.9',
148654
149069
  cldr: '39.0',
148655
149070
  icu: '69.1',
148656
- llhttp: '2.1.3',
149071
+ llhttp: '2.1.4',
148657
149072
  modules: '83',
148658
149073
  napi: '8',
148659
149074
  nghttp2: '1.42.0',
148660
- node: '14.17.3',
148661
- openssl: '1.1.1k',
149075
+ node: '14.18.3',
149076
+ openssl: '1.1.1l',
148662
149077
  tz: '2021a',
148663
149078
  unicode: '13.0',
148664
- uv: '1.41.0',
148665
- v8: '8.4.371.23-node.67',
149079
+ uv: '1.42.0',
149080
+ v8: '8.4.371.23-node.85',
148666
149081
  zlib: '1.2.11'
148667
149082
  }
148668
149083
  });