solid-ui 2.4.15 → 2.4.16-9d83fb17

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.
@@ -5284,7 +5284,6 @@ var UI = {
5284
5284
  var $rdf = UI.rdf;
5285
5285
  var BOOK = $rdf.Namespace('http://www.w3.org/2002/01/bookmark#');
5286
5286
  var BOOKMARK_ICON = 'noun_45961.svg';
5287
- var kb = _logic.store;
5288
5287
  var label = utils.label;
5289
5288
  var dom = window.document || null;
5290
5289
  /** Create a resource if it really does not exist
@@ -5295,19 +5294,20 @@ var dom = window.document || null;
5295
5294
 
5296
5295
  function createIfNotExists(doc) {
5297
5296
  return new Promise(function (resolve, reject) {
5298
- kb.fetcher.load(doc).then(function (response) {
5299
- debug.log('createIfNotExists doc exists, all good ' + doc); // kb.fetcher.webOperation('HEAD', doc.uri).then(response => {
5297
+ _logic.store.fetcher.load(doc).then(function (response) {
5298
+ debug.log('createIfNotExists doc exists, all good ' + doc); // store.fetcher.webOperation('HEAD', doc.uri).then(response => {
5300
5299
 
5301
5300
  resolve(response);
5302
5301
  }, function (err) {
5303
5302
  if (err.response.status === 404) {
5304
5303
  debug.log('createIfNotExists doc does NOT exist, will create... ' + doc);
5305
- kb.fetcher.webOperation('PUT', doc.uri, {
5304
+
5305
+ _logic.store.fetcher.webOperation('PUT', doc.uri, {
5306
5306
  data: '',
5307
5307
  contentType: 'text/turtle'
5308
5308
  }).then(function (response) {
5309
5309
  // fetcher.requested[doc.uri] = 'done' // do not need to read ?? but no headers
5310
- delete kb.fetcher.requested[doc.uri]; // delete cached 404 error
5310
+ delete _logic.store.fetcher.requested[doc.uri]; // delete cached 404 error
5311
5311
 
5312
5312
  debug.log('createIfNotExists doc created ok ' + doc);
5313
5313
  resolve(response);
@@ -5326,13 +5326,14 @@ function createIfNotExists(doc) {
5326
5326
 
5327
5327
  function updatePromise(del, ins) {
5328
5328
  return new Promise(function (resolve, reject) {
5329
- kb.updater.update(del, ins, function (uri, ok, errorBody) {
5329
+ _logic.store.updater.update(del, ins, function (uri, ok, errorBody) {
5330
5330
  if (!ok) {
5331
5331
  reject(new Error(errorBody));
5332
5332
  } else {
5333
5333
  resolve();
5334
5334
  }
5335
5335
  }); // callback
5336
+
5336
5337
  }); // promise
5337
5338
  } // export findBookmarkDocument,
5338
5339
 
@@ -5461,8 +5462,8 @@ function _addBookmark() {
5461
5462
  throw new Error('Must be logged on to add Bookmark');
5462
5463
 
5463
5464
  case 4:
5464
- author = kb.any(target, ns.foaf('maker'));
5465
- title = label(author) + ': ' + kb.anyValue(target, ns.sioc('content')).slice(0, 80); // @@ add chat title too?
5465
+ author = _logic.store.any(target, ns.foaf('maker'));
5466
+ title = label(author) + ': ' + _logic.store.anyValue(target, ns.sioc('content')).slice(0, 80); // @@ add chat title too?
5466
5467
 
5467
5468
  bookmarkDoc = context.bookmarkDocument;
5468
5469
  bookmark = UI.widgets.newThing(bookmarkDoc, title);
@@ -5507,10 +5508,10 @@ function _toggleBookmark() {
5507
5508
  switch (_context3.prev = _context3.next) {
5508
5509
  case 0:
5509
5510
  _context3.next = 2;
5510
- return kb.fetcher.load(userContext.bookmarkDocument);
5511
+ return _logic.store.fetcher.load(userContext.bookmarkDocument);
5511
5512
 
5512
5513
  case 2:
5513
- bookmarks = kb.each(null, BOOK('recalls'), target, userContext.bookmarkDocument);
5514
+ bookmarks = _logic.store.each(null, BOOK('recalls'), target, userContext.bookmarkDocument);
5514
5515
 
5515
5516
  if (!bookmarks.length) {
5516
5517
  _context3.next = 24;
@@ -5535,7 +5536,7 @@ function _toggleBookmark() {
5535
5536
 
5536
5537
  _context3.prev = 8;
5537
5538
  _context3.next = 11;
5538
- return updatePromise(kb.connectedStatements(bookmarks[i]), []);
5539
+ return updatePromise(_logic.store.connectedStatements(bookmarks[i]), []);
5539
5540
 
5540
5541
  case 11:
5541
5542
  bookmarkButton.style.backgroundColor = 'white';
@@ -5597,10 +5598,10 @@ function _renderBookmarksButton() {
5597
5598
  switch (_context4.prev = _context4.next) {
5598
5599
  case 0:
5599
5600
  _context4.next = 2;
5600
- return kb.fetcher.load(userContext.bookmarkDocument);
5601
+ return _logic.store.fetcher.load(userContext.bookmarkDocument);
5601
5602
 
5602
5603
  case 2:
5603
- bookmarked = kb.any(null, BOOK('recalls'), bookmarkButton.target, userContext.bookmarkDocument);
5604
+ bookmarked = _logic.store.any(null, BOOK('recalls'), bookmarkButton.target, userContext.bookmarkDocument);
5604
5605
  bookmarkButton.style = UI.style.buttonStyle;
5605
5606
  if (bookmarked) bookmarkButton.style.backgroundColor = 'yellow';
5606
5607
 
@@ -5646,6 +5647,357 @@ function _renderBookmarksButton() {
5646
5647
 
5647
5648
  /***/ }),
5648
5649
 
5650
+ /***/ "./lib/chat/chatLogic.js":
5651
+ /*!*******************************!*\
5652
+ !*** ./lib/chat/chatLogic.js ***!
5653
+ \*******************************/
5654
+ /*! no static exports found */
5655
+ /***/ (function(module, exports, __webpack_require__) {
5656
+
5657
+ "use strict";
5658
+
5659
+
5660
+ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
5661
+
5662
+ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
5663
+
5664
+ Object.defineProperty(exports, "__esModule", {
5665
+ value: true
5666
+ });
5667
+ exports.ChatChannel = void 0;
5668
+ exports._createIfNotExists = _createIfNotExists;
5669
+ exports.isDeleted = isDeleted;
5670
+ exports.isHidden = isHidden;
5671
+ exports.isReplaced = isReplaced;
5672
+ exports.mostRecentVersion = mostRecentVersion;
5673
+ exports.nick = nick;
5674
+ exports.originalVersion = originalVersion;
5675
+
5676
+ var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
5677
+
5678
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
5679
+
5680
+ var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/@babel/runtime/helpers/classCallCheck.js"));
5681
+
5682
+ var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/@babel/runtime/helpers/createClass.js"));
5683
+
5684
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./lib/debug.js"));
5685
+
5686
+ var _index = __webpack_require__(/*! ../authn/index */ "./lib/authn/index.js");
5687
+
5688
+ var _dateFolder = __webpack_require__(/*! ./dateFolder */ "./lib/chat/dateFolder.js");
5689
+
5690
+ var _logic = __webpack_require__(/*! ../logic */ "./lib/logic.js");
5691
+
5692
+ var ns = _interopRequireWildcard(__webpack_require__(/*! ../ns */ "./lib/ns.js"));
5693
+
5694
+ var $rdf = _interopRequireWildcard(__webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js"));
5695
+
5696
+ var utils = _interopRequireWildcard(__webpack_require__(/*! ../utils */ "./lib/utils/index.js"));
5697
+
5698
+ 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); }
5699
+
5700
+ 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; }
5701
+
5702
+ /**
5703
+ * Contains the [[ChatChannel]] class and logic for Solid Chat
5704
+ * @packageDocumentation
5705
+ */
5706
+ // pull in first avoid cross-refs
5707
+
5708
+ /* The Solid logic for a 'LongChat'
5709
+ */
5710
+
5711
+ /**
5712
+ * Common code for a chat (discussion area of messages about something)
5713
+ * This version runs over a series of files for different time periods
5714
+ *
5715
+ * Parameters for the whole chat like its title are stored on
5716
+ * index.ttl#this and the chats messages are stored in YYYY/MM/DD/chat.ttl
5717
+ *
5718
+ */
5719
+ var ChatChannel = /*#__PURE__*/function () {
5720
+ function ChatChannel(channel, options) {
5721
+ (0, _classCallCheck2["default"])(this, ChatChannel);
5722
+ this.channel = channel;
5723
+ this.channelRoot = channel.doc();
5724
+ this.options = options;
5725
+ this.dateFolder = new _dateFolder.DateFolder(this.channelRoot, 'chat.ttl');
5726
+ this.div = null; // : HTMLElement
5727
+ }
5728
+ /* Store a new message in the web,
5729
+ */
5730
+
5731
+
5732
+ (0, _createClass2["default"])(ChatChannel, [{
5733
+ key: "createMessage",
5734
+ value: function () {
5735
+ var _createMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(text) {
5736
+ return _regenerator["default"].wrap(function _callee$(_context) {
5737
+ while (1) {
5738
+ switch (_context.prev = _context.next) {
5739
+ case 0:
5740
+ return _context.abrupt("return", this.updateMessage(text));
5741
+
5742
+ case 1:
5743
+ case "end":
5744
+ return _context.stop();
5745
+ }
5746
+ }
5747
+ }, _callee, this);
5748
+ }));
5749
+
5750
+ function createMessage(_x) {
5751
+ return _createMessage.apply(this, arguments);
5752
+ }
5753
+
5754
+ return createMessage;
5755
+ }()
5756
+ /* Store a new message in the web,
5757
+ as a replacement for an existing one.
5758
+ The old one iis left, and the two are linked
5759
+ */
5760
+
5761
+ }, {
5762
+ key: "updateMessage",
5763
+ value: function () {
5764
+ var _updateMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(text) {
5765
+ var oldMsg,
5766
+ deleteIt,
5767
+ sts,
5768
+ now,
5769
+ timestamp,
5770
+ dateStamp,
5771
+ chatDocument,
5772
+ message,
5773
+ me,
5774
+ msg,
5775
+ _args2 = arguments;
5776
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
5777
+ while (1) {
5778
+ switch (_context2.prev = _context2.next) {
5779
+ case 0:
5780
+ oldMsg = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : null;
5781
+ deleteIt = _args2.length > 2 ? _args2[2] : undefined;
5782
+ sts = [];
5783
+ now = new Date();
5784
+ timestamp = '' + now.getTime();
5785
+ dateStamp = $rdf.term(now);
5786
+ chatDocument = oldMsg ? oldMsg.doc() : this.dateFolder.leafDocumentFromDate(now);
5787
+ message = _logic.store.sym(chatDocument.uri + '#' + 'Msg' + timestamp); // const content = store.literal(text)
5788
+
5789
+ me = _index.authn.currentUser(); // If already logged on
5790
+
5791
+ if (oldMsg) {
5792
+ // edit message replaces old one
5793
+ sts.push($rdf.st(mostRecentVersion(oldMsg), ns.dct('isReplacedBy'), message, chatDocument));
5794
+
5795
+ if (deleteIt) {
5796
+ sts.push($rdf.st(message, ns.schema('dateDeleted'), dateStamp, chatDocument));
5797
+ }
5798
+ } else {
5799
+ // link new message to channel
5800
+ sts.push($rdf.st(this.channel, ns.wf('message'), message, chatDocument));
5801
+ }
5802
+
5803
+ sts.push($rdf.st(message, ns.sioc('content'), _logic.store.literal(text), chatDocument));
5804
+ sts.push($rdf.st(message, ns.dct('created'), dateStamp, chatDocument));
5805
+
5806
+ if (me) {
5807
+ sts.push($rdf.st(message, ns.foaf('maker'), me, chatDocument));
5808
+ }
5809
+
5810
+ _context2.prev = 13;
5811
+ _context2.next = 16;
5812
+ return _logic.store.updater.update([], sts);
5813
+
5814
+ case 16:
5815
+ _context2.next = 24;
5816
+ break;
5817
+
5818
+ case 18:
5819
+ _context2.prev = 18;
5820
+ _context2.t0 = _context2["catch"](13);
5821
+ msg = 'Error saving chat message: ' + _context2.t0;
5822
+ debug.warn(msg);
5823
+ alert(msg);
5824
+ throw new Error(msg);
5825
+
5826
+ case 24:
5827
+ return _context2.abrupt("return", message);
5828
+
5829
+ case 25:
5830
+ case "end":
5831
+ return _context2.stop();
5832
+ }
5833
+ }
5834
+ }, _callee2, this, [[13, 18]]);
5835
+ }));
5836
+
5837
+ function updateMessage(_x2) {
5838
+ return _updateMessage.apply(this, arguments);
5839
+ }
5840
+
5841
+ return updateMessage;
5842
+ }()
5843
+ /* Mark a message as deleted
5844
+ * Wee add a new version of the message,m witha deletion flag (deletion date)
5845
+ * so that the deletion can be revoked by adding another non-deleted update
5846
+ */
5847
+
5848
+ }, {
5849
+ key: "deleteMessage",
5850
+ value: function () {
5851
+ var _deleteMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(message) {
5852
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
5853
+ while (1) {
5854
+ switch (_context3.prev = _context3.next) {
5855
+ case 0:
5856
+ return _context3.abrupt("return", this.updateMessage('(message deleted)', message, true));
5857
+
5858
+ case 1:
5859
+ case "end":
5860
+ return _context3.stop();
5861
+ }
5862
+ }
5863
+ }, _callee3, this);
5864
+ }));
5865
+
5866
+ function deleteMessage(_x3) {
5867
+ return _deleteMessage.apply(this, arguments);
5868
+ }
5869
+
5870
+ return deleteMessage;
5871
+ }()
5872
+ }]);
5873
+ return ChatChannel;
5874
+ }(); // class ChatChannel
5875
+
5876
+
5877
+ exports.ChatChannel = ChatChannel;
5878
+
5879
+ function originalVersion(message) {
5880
+ var msg = message;
5881
+
5882
+ while (msg) {
5883
+ message = msg;
5884
+ msg = _logic.store.any(null, ns.dct('isReplacedBy'), message, message.doc());
5885
+ }
5886
+
5887
+ return message;
5888
+ }
5889
+
5890
+ function mostRecentVersion(message) {
5891
+ var msg = message;
5892
+
5893
+ while (msg) {
5894
+ message = msg;
5895
+ msg = _logic.store.any(message, ns.dct('isReplacedBy'), null, message.doc());
5896
+ }
5897
+
5898
+ return message;
5899
+ }
5900
+
5901
+ function isDeleted(message) {
5902
+ return _logic.store.holds(message, ns.schema('dateDeleted'), null, message.doc());
5903
+ }
5904
+
5905
+ function isReplaced(message) {
5906
+ return _logic.store.holds(message, ns.dct('isReplacedBy'), null, message.doc());
5907
+ }
5908
+
5909
+ function isHidden(message) {
5910
+ return this.isDeleted(message) || this.isReplaced(message);
5911
+ } // A Nickname for a person
5912
+
5913
+
5914
+ function nick(person) {
5915
+ var s = _logic.store.any(person, ns.foaf('nick'));
5916
+
5917
+ if (s) return '' + s.value;
5918
+ return '' + utils.label(person);
5919
+ }
5920
+
5921
+ function _createIfNotExists(_x4) {
5922
+ return _createIfNotExists2.apply(this, arguments);
5923
+ } // ends
5924
+
5925
+
5926
+ function _createIfNotExists2() {
5927
+ _createIfNotExists2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(doc) {
5928
+ var contentType,
5929
+ data,
5930
+ response,
5931
+ _args4 = arguments;
5932
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
5933
+ while (1) {
5934
+ switch (_context4.prev = _context4.next) {
5935
+ case 0:
5936
+ contentType = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : 'text/turtle';
5937
+ data = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : '';
5938
+ _context4.prev = 2;
5939
+ _context4.next = 5;
5940
+ return _logic.store.fetcher.load(doc);
5941
+
5942
+ case 5:
5943
+ response = _context4.sent;
5944
+ _context4.next = 28;
5945
+ break;
5946
+
5947
+ case 8:
5948
+ _context4.prev = 8;
5949
+ _context4.t0 = _context4["catch"](2);
5950
+
5951
+ if (!(_context4.t0.response.status === 404)) {
5952
+ _context4.next = 26;
5953
+ break;
5954
+ }
5955
+
5956
+ debug.log('createIfNotExists: doc does NOT exist, will create... ' + doc);
5957
+ _context4.prev = 12;
5958
+ _context4.next = 15;
5959
+ return _logic.store.fetcher.webOperation('PUT', doc.uri, {
5960
+ data: data,
5961
+ contentType: contentType
5962
+ });
5963
+
5964
+ case 15:
5965
+ response = _context4.sent;
5966
+ _context4.next = 22;
5967
+ break;
5968
+
5969
+ case 18:
5970
+ _context4.prev = 18;
5971
+ _context4.t1 = _context4["catch"](12);
5972
+ debug.log('createIfNotExists doc FAILED: ' + doc + ': ' + _context4.t1);
5973
+ throw _context4.t1;
5974
+
5975
+ case 22:
5976
+ delete _logic.store.fetcher.requested[doc.uri]; // delete cached 404 error
5977
+ // debug.log('createIfNotExists doc created ok ' + doc)
5978
+
5979
+ return _context4.abrupt("return", response);
5980
+
5981
+ case 26:
5982
+ debug.log('createIfNotExists doc load error NOT 404: ' + doc + ': ' + _context4.t0);
5983
+ throw _context4.t0;
5984
+
5985
+ case 28:
5986
+ return _context4.abrupt("return", response);
5987
+
5988
+ case 29:
5989
+ case "end":
5990
+ return _context4.stop();
5991
+ }
5992
+ }
5993
+ }, _callee4, null, [[2, 8], [12, 18]]);
5994
+ }));
5995
+ return _createIfNotExists2.apply(this, arguments);
5996
+ }
5997
+ //# sourceMappingURL=chatLogic.js.map
5998
+
5999
+ /***/ }),
6000
+
5649
6001
  /***/ "./lib/chat/dateFolder.js":
5650
6002
  /*!********************************!*\
5651
6003
  !*** ./lib/chat/dateFolder.js ***!
@@ -5687,14 +6039,14 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
5687
6039
 
5688
6040
  /**
5689
6041
  * Contains the [[DateFolder]] class
5690
- * @packageDocumentation
6042
+ * This tracks data stored in dated folders and sub-folders
6043
+ *
5691
6044
  */
5692
6045
  // pull in first avoid cross-refs
5693
- var kb = _logic.store;
6046
+
5694
6047
  /**
5695
6048
  * Track back through the YYYY/MM/DD tree to find the previous/next day
5696
6049
  */
5697
-
5698
6050
  var DateFolder = /*#__PURE__*/function () {
5699
6051
  function DateFolder(rootThing, leafFileName, membershipProperty) {
5700
6052
  (0, _classCallCheck2["default"])(this, DateFolder);
@@ -5718,7 +6070,7 @@ var DateFolder = /*#__PURE__*/function () {
5718
6070
  var path = isoDate.split('T')[0].replace(/-/g, '/'); // Like "2018/05/07"
5719
6071
 
5720
6072
  path = this.root.dir().uri + path + '/' + this.leafFileName;
5721
- return kb.sym(path);
6073
+ return _logic.store.sym(path);
5722
6074
  }
5723
6075
  /* Generate a date object from the leaf file name
5724
6076
  */
@@ -5780,12 +6132,12 @@ var DateFolder = /*#__PURE__*/function () {
5780
6132
  }
5781
6133
 
5782
6134
  _folder = siblings.pop();
5783
- leafDocument = kb.sym(_folder.uri + thisDateFolder.leafFileName);
6135
+ leafDocument = _logic.store.sym(_folder.uri + thisDateFolder.leafFileName);
5784
6136
  _context.next = 10;
5785
- return kb.fetcher.load(leafDocument);
6137
+ return _logic.store.fetcher.load(leafDocument);
5786
6138
 
5787
6139
  case 10:
5788
- if (!(kb.statementsMatching(null, ns.dct('created'), null, leafDocument).length > 0)) {
6140
+ if (!(_logic.store.statementsMatching(null, ns.dct('created'), null, leafDocument).length > 0)) {
5789
6141
  _context.next = 12;
5790
6142
  break;
5791
6143
  }
@@ -5829,10 +6181,10 @@ var DateFolder = /*#__PURE__*/function () {
5829
6181
  // debug.log(' previousPeriod level' + level + ' file ' + file)
5830
6182
  parent = file.dir();
5831
6183
  _context2.next = 7;
5832
- return kb.fetcher.load(parent);
6184
+ return _logic.store.fetcher.load(parent);
5833
6185
 
5834
6186
  case 7:
5835
- siblings = kb.each(parent, ns.ldp('contains'));
6187
+ siblings = _logic.store.each(parent, ns.ldp('contains'));
5836
6188
  siblings = siblings.filter(younger);
5837
6189
  _context2.next = 11;
5838
6190
  return lastNonEmpty(siblings);
@@ -5871,10 +6223,10 @@ var DateFolder = /*#__PURE__*/function () {
5871
6223
 
5872
6224
  case 21:
5873
6225
  _context2.next = 23;
5874
- return kb.fetcher.load(uncle);
6226
+ return _logic.store.fetcher.load(uncle);
5875
6227
 
5876
6228
  case 23:
5877
- cousins = kb.each(uncle, ns.ldp('contains'));
6229
+ cousins = _logic.store.each(uncle, ns.ldp('contains'));
5878
6230
  _context2.next = 26;
5879
6231
  return lastNonEmpty(cousins);
5880
6232
 
@@ -5910,7 +6262,7 @@ var DateFolder = /*#__PURE__*/function () {
5910
6262
  break;
5911
6263
  }
5912
6264
 
5913
- doc = kb.sym(found.uri + this.leafFileName);
6265
+ doc = _logic.store.sym(found.uri + this.leafFileName);
5914
6266
  return _context3.abrupt("return", this.dateFromLeafDocument(doc));
5915
6267
 
5916
6268
  case 10:
@@ -6081,166 +6433,103 @@ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_m
6081
6433
  Object.defineProperty(exports, "__esModule", {
6082
6434
  value: true
6083
6435
  });
6084
- exports.createIfNotExists = createIfNotExists;
6085
6436
  exports.desktopNotification = desktopNotification;
6086
6437
  exports.infiniteMessageArea = infiniteMessageArea;
6438
+ exports.insertMessageIntoTable = insertMessageIntoTable;
6087
6439
 
6088
6440
  var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
6089
6441
 
6090
6442
  var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
6091
6443
 
6092
- var _index = __webpack_require__(/*! ../authn/index */ "./lib/authn/index.js");
6093
-
6094
6444
  var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./lib/debug.js"));
6095
6445
 
6096
6446
  var _iconBase = __webpack_require__(/*! ../iconBase */ "./lib/iconBase.js");
6097
6447
 
6098
6448
  var _logic = __webpack_require__(/*! ../logic */ "./lib/logic.js");
6099
6449
 
6100
- var _index2 = __webpack_require__(/*! ../media/index */ "./lib/media/index.js");
6101
-
6102
6450
  var ns = _interopRequireWildcard(__webpack_require__(/*! ../ns */ "./lib/ns.js"));
6103
6451
 
6104
- var pad = _interopRequireWildcard(__webpack_require__(/*! ../pad */ "./lib/pad.js"));
6105
-
6106
- var _dateFolder = __webpack_require__(/*! ./dateFolder */ "./lib/chat/dateFolder.js");
6452
+ var _chatLogic = __webpack_require__(/*! ./chatLogic */ "./lib/chat/chatLogic.js");
6107
6453
 
6108
6454
  var _message = __webpack_require__(/*! ./message */ "./lib/chat/message.js");
6109
6455
 
6110
- var _bookmarks = __webpack_require__(/*! ./bookmarks */ "./lib/chat/bookmarks.js");
6111
-
6112
6456
  var $rdf = _interopRequireWildcard(__webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js"));
6113
6457
 
6114
- var style = _interopRequireWildcard(__webpack_require__(/*! ../style */ "./lib/style.js"));
6115
-
6116
- var utils = _interopRequireWildcard(__webpack_require__(/*! ../utils */ "./lib/utils/index.js"));
6117
-
6118
6458
  var widgets = _interopRequireWildcard(__webpack_require__(/*! ../widgets */ "./lib/widgets/index.js"));
6119
6459
 
6120
6460
  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); }
6121
6461
 
6122
6462
  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; }
6123
6463
 
6124
- 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; } } }; }
6125
-
6126
- 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); }
6464
+ /**
6465
+ * Contains the [[infiniteMessageArea]] class
6466
+ * @packageDocumentation
6467
+ */
6468
+ // import { authn } from '../authn/index'
6469
+ // import { media } from '../media/index'
6470
+ // import * as pad from '../pad'
6471
+ // import { DateFolder } from './dateFolder'
6472
+ // import { findBookmarkDocument } from './bookmarks'
6473
+ // pull in first avoid cross-refs
6474
+ // import * as style from '../style'
6475
+ // import * as utils from '../utils'
6476
+ // const UI = { authn, icons, ns, media, pad, $rdf, store, style, utils, widgets }
6477
+ function desktopNotification(str) {
6478
+ // Let's check if the browser supports notifications
6479
+ if (!('Notification' in window)) {
6480
+ debug.warn('This browser does no t support desktop notification');
6481
+ } else if (Notification.permission === 'granted') {
6482
+ // Let's check whether notificatio n permissions have already been granted
6483
+ // eslint-disable-next-line no-new
6484
+ new Notification(str);
6485
+ } else if (Notification.permission !== 'denied') {
6486
+ // Otherwise, we need to ask the user for permission
6487
+ Notification.requestPermission().then(function (permission) {
6488
+ // If the user accepts, let's create a notification
6489
+ if (permission === 'granted') {
6490
+ // eslint-disable-next-line no-new
6491
+ new Notification(str);
6492
+ }
6493
+ });
6494
+ } // At last, if the user has denied notifications, and you
6495
+ // want to be respectful there is no need to bother them any more.
6127
6496
 
6128
- 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; }
6129
-
6130
- var UI = {
6131
- authn: _index.authn,
6132
- icons: _iconBase.icons,
6133
- ns: ns,
6134
- media: _index2.media,
6135
- pad: pad,
6136
- $rdf: $rdf,
6137
- store: _logic.store,
6138
- style: style,
6139
- utils: utils,
6140
- widgets: widgets
6141
- };
6142
- /* global alert */
6143
-
6144
- var SERVER_MKDIRP_BUG = false; // Set false timbl 2021-10-31 should be fixed by now
6145
-
6146
- function createIfNotExists(_x) {
6147
- return _createIfNotExists.apply(this, arguments);
6148
6497
  }
6498
+ /**
6499
+ * Renders a chat message inside a `messageTable`
6500
+ */
6149
6501
 
6150
- function _createIfNotExists() {
6151
- _createIfNotExists = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(doc) {
6152
- var contentType,
6153
- data,
6154
- fetcher,
6155
- response,
6156
- _args = arguments;
6157
- return _regenerator["default"].wrap(function _callee$(_context) {
6158
- while (1) {
6159
- switch (_context.prev = _context.next) {
6160
- case 0:
6161
- contentType = _args.length > 1 && _args[1] !== undefined ? _args[1] : 'text/turtle';
6162
- data = _args.length > 2 && _args[2] !== undefined ? _args[2] : '';
6163
- fetcher = UI.store.fetcher;
6164
- _context.prev = 3;
6165
- _context.next = 6;
6166
- return fetcher.load(doc);
6167
-
6168
- case 6:
6169
- response = _context.sent;
6170
- _context.next = 29;
6171
- break;
6172
-
6173
- case 9:
6174
- _context.prev = 9;
6175
- _context.t0 = _context["catch"](3);
6176
-
6177
- if (!(_context.t0.response.status === 404)) {
6178
- _context.next = 27;
6179
- break;
6180
- }
6181
-
6182
- debug.log('createIfNotExists: doc does NOT exist, will create... ' + doc);
6183
- _context.prev = 13;
6184
- _context.next = 16;
6185
- return fetcher.webOperation('PUT', doc.uri, {
6186
- data: data,
6187
- contentType: contentType
6188
- });
6189
-
6190
- case 16:
6191
- response = _context.sent;
6192
- _context.next = 23;
6193
- break;
6194
-
6195
- case 19:
6196
- _context.prev = 19;
6197
- _context.t1 = _context["catch"](13);
6198
- debug.log('createIfNotExists doc FAILED: ' + doc + ': ' + _context.t1);
6199
- throw _context.t1;
6200
6502
 
6201
- case 23:
6202
- delete fetcher.requested[doc.uri]; // delete cached 404 error
6203
- // debug.log('createIfNotExists doc created ok ' + doc)
6503
+ function insertMessageIntoTable(channelObject, messageTable, message, fresh, options, userContext) {
6504
+ var messageRow = (0, _message.renderMessageRow)(channelObject, message, fresh, options, userContext); // const message = messageRow.AJAR_subject
6204
6505
 
6205
- return _context.abrupt("return", response);
6506
+ if (options.selectedMessage && options.selectedMessage.sameTerm(message)) {
6507
+ messageRow.style.backgroundColor = 'yellow';
6508
+ options.selectedElement = messageRow;
6509
+ messageTable.selectedElement = messageRow;
6510
+ }
6206
6511
 
6207
- case 27:
6208
- debug.log('createIfNotExists doc load error NOT 404: ' + doc + ': ' + _context.t0);
6209
- throw _context.t0;
6512
+ var done = false;
6210
6513
 
6211
- case 29:
6212
- return _context.abrupt("return", response);
6514
+ for (var ele = messageTable.firstChild;; ele = ele.nextSibling) {
6515
+ if (!ele) {
6516
+ // empty
6517
+ break;
6518
+ }
6213
6519
 
6214
- case 30:
6215
- case "end":
6216
- return _context.stop();
6217
- }
6218
- }
6219
- }, _callee, null, [[3, 9], [13, 19]]);
6220
- }));
6221
- return _createIfNotExists.apply(this, arguments);
6222
- }
6520
+ var newestFirst = options.newestfirst === true;
6521
+ var dateString = messageRow.AJAR_date;
6223
6522
 
6224
- function desktopNotification(str) {
6225
- // Let's check if the browser supports notifications
6226
- if (!('Notification' in window)) {
6227
- debug.warn('This browser does not support desktop notification');
6228
- } else if (Notification.permission === 'granted') {
6229
- // Let's check whether notification permissions have already been granted
6230
- // eslint-disable-next-line no-new
6231
- new Notification(str);
6232
- } else if (Notification.permission !== 'denied') {
6233
- // Otherwise, we need to ask the user for permission
6234
- Notification.requestPermission().then(function (permission) {
6235
- // If the user accepts, let's create a notification
6236
- if (permission === 'granted') {
6237
- // eslint-disable-next-line no-new
6238
- new Notification(str);
6239
- }
6240
- });
6241
- } // At last, if the user has denied notifications, and you
6242
- // want to be respectful there is no need to bother them any more.
6523
+ if (dateString > ele.AJAR_date && newestFirst || dateString < ele.AJAR_date && !newestFirst) {
6524
+ messageTable.insertBefore(messageRow, ele);
6525
+ done = true;
6526
+ break;
6527
+ }
6528
+ }
6243
6529
 
6530
+ if (!done) {
6531
+ messageTable.appendChild(messageRow);
6532
+ }
6244
6533
  }
6245
6534
  /**
6246
6535
  * Common code for a chat (discussion area of messages about something)
@@ -6248,27 +6537,42 @@ function desktopNotification(str) {
6248
6537
  *
6249
6538
  * Parameters for the whole chat like its title are stored on
6250
6539
  * index.ttl#this and the chats messages are stored in YYYY/MM/DD/chat.ttl
6540
+ *
6541
+ * Use to import store as param 2, now ignores it and uses the UI main store
6542
+ *
6543
+ * Options include:
6544
+
6545
+ - shiftEnterSendsMessage: Use shift/enter to send message, Enter to add newline, instead of the reverse.
6546
+ - authorDateOnLeft: Display the author's anme and date of the message in the left column instead of first above the content
6547
+ - selectedMessage: Display one message highlighted with the chat around it
6548
+ - solo: By itelf on a webpage, so user scroll anywhere in the web page scan scroll the chat.
6549
+ - newestFirst: Arrange the chat messages chronologically newest at the top insted of at the bottom
6550
+ - infinite: Use infinite scroll
6551
+ - showDeletedMessages: Show messages which have been delted as "deleted message". Otherwise hide them.
6552
+ - expandImagesInline: If a URI by itself in a message looks like an image URI, replace it with the image
6553
+ - inlineImageHeightEms: The height (in ems) of images expaned from their URIs in the chat.
6554
+
6251
6555
  */
6252
6556
 
6253
6557
 
6254
- function infiniteMessageArea(_x2, _x3, _x4, _x5) {
6558
+ function infiniteMessageArea(_x, _x2, _x3, _x4) {
6255
6559
  return _infiniteMessageArea.apply(this, arguments);
6256
6560
  }
6257
6561
 
6258
6562
  function _infiniteMessageArea() {
6259
- _infiniteMessageArea = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee17(dom, kb, chatChannel, options) {
6260
- 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;
6563
+ _infiniteMessageArea = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12(dom, wasStore, chatChannel, options) {
6564
+ 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;
6261
6565
 
6262
- return _regenerator["default"].wrap(function _callee17$(_context17) {
6566
+ return _regenerator["default"].wrap(function _callee12$(_context12) {
6263
6567
  while (1) {
6264
- switch (_context17.prev = _context17.next) {
6568
+ switch (_context12.prev = _context12.next) {
6265
6569
  case 0:
6266
6570
  _loadInitialContent = function _loadInitialContent3() {
6267
- _loadInitialContent = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee16() {
6571
+ _loadInitialContent = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee11() {
6268
6572
  var yank, fixScroll, live, selectedDocument, now, todayDocument, selectedMessageTable, selectedDate;
6269
- return _regenerator["default"].wrap(function _callee16$(_context16) {
6573
+ return _regenerator["default"].wrap(function _callee11$(_context11) {
6270
6574
  while (1) {
6271
- switch (_context16.prev = _context16.next) {
6575
+ switch (_context11.prev = _context11.next) {
6272
6576
  case 0:
6273
6577
  fixScroll = function _fixScroll() {
6274
6578
  if (options.selectedElement) {
@@ -6296,27 +6600,27 @@ function _infiniteMessageArea() {
6296
6600
  }
6297
6601
 
6298
6602
  if (!(options.selectedMessage && !live)) {
6299
- _context16.next = 15;
6603
+ _context11.next = 15;
6300
6604
  break;
6301
6605
  }
6302
6606
 
6303
6607
  selectedDate = dateFolder.dateFromLeafDocument(selectedDocument);
6304
- _context16.next = 7;
6608
+ _context11.next = 7;
6305
6609
  return createMessageTable(selectedDate, live);
6306
6610
 
6307
6611
  case 7:
6308
- selectedMessageTable = _context16.sent;
6612
+ selectedMessageTable = _context11.sent;
6309
6613
  div.appendChild(selectedMessageTable);
6310
6614
  earliest.messageTable = selectedMessageTable;
6311
6615
  latest.messageTable = selectedMessageTable;
6312
6616
  yank();
6313
6617
  setTimeout(yank, 1000); // @@ kludge - restore position distubed by other cHANGES
6314
6618
 
6315
- _context16.next = 19;
6619
+ _context11.next = 19;
6316
6620
  break;
6317
6621
 
6318
6622
  case 15:
6319
- _context16.next = 17;
6623
+ _context11.next = 17;
6320
6624
  return appendCurrentMessages();
6321
6625
 
6322
6626
  case 17:
@@ -6324,7 +6628,7 @@ function _infiniteMessageArea() {
6324
6628
  latest.messageTable = liveMessageTable;
6325
6629
 
6326
6630
  case 19:
6327
- _context16.next = 21;
6631
+ _context11.next = 21;
6328
6632
  return loadMoreWhereNeeded(null, fixScroll);
6329
6633
 
6330
6634
  case 21:
@@ -6336,10 +6640,10 @@ function _infiniteMessageArea() {
6336
6640
 
6337
6641
  case 23:
6338
6642
  case "end":
6339
- return _context16.stop();
6643
+ return _context11.stop();
6340
6644
  }
6341
6645
  }
6342
- }, _callee16);
6646
+ }, _callee11);
6343
6647
  }));
6344
6648
  return _loadInitialContent.apply(this, arguments);
6345
6649
  };
@@ -6349,18 +6653,18 @@ function _infiniteMessageArea() {
6349
6653
  };
6350
6654
 
6351
6655
  _loadMoreWhereNeeded = function _loadMoreWhereNeeded3() {
6352
- _loadMoreWhereNeeded = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee15(event, fixScroll) {
6656
+ _loadMoreWhereNeeded = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(event, fixScroll) {
6353
6657
  var freeze, magicZone, done, scrollBottom, scrollTop;
6354
- return _regenerator["default"].wrap(function _callee15$(_context15) {
6658
+ return _regenerator["default"].wrap(function _callee10$(_context10) {
6355
6659
  while (1) {
6356
- switch (_context15.prev = _context15.next) {
6660
+ switch (_context10.prev = _context10.next) {
6357
6661
  case 0:
6358
6662
  if (!lock) {
6359
- _context15.next = 2;
6663
+ _context10.next = 2;
6360
6664
  break;
6361
6665
  }
6362
6666
 
6363
- return _context15.abrupt("return");
6667
+ return _context10.abrupt("return");
6364
6668
 
6365
6669
  case 2:
6366
6670
  lock = true;
@@ -6370,12 +6674,12 @@ function _infiniteMessageArea() {
6370
6674
 
6371
6675
  case 5:
6372
6676
  if (!(div.scrollTop < magicZone && earliest.messageTable && !earliest.messageTable.initial && earliest.messageTable.extendBackwards)) {
6373
- _context15.next = 21;
6677
+ _context10.next = 21;
6374
6678
  break;
6375
6679
  }
6376
6680
 
6377
6681
  if (!(div.scrollHeight === 0)) {
6378
- _context15.next = 10;
6682
+ _context10.next = 10;
6379
6683
  break;
6380
6684
  }
6381
6685
 
@@ -6383,17 +6687,17 @@ function _infiniteMessageArea() {
6383
6687
  setTimeout(loadMoreWhereNeeded, 2000); // couple be less
6384
6688
 
6385
6689
  lock = false;
6386
- return _context15.abrupt("return");
6690
+ return _context10.abrupt("return");
6387
6691
 
6388
6692
  case 10:
6389
6693
  // console.log(' chat/loadMoreWhereNeeded: Going now')
6390
6694
  scrollBottom = div.scrollHeight - div.scrollTop;
6391
6695
  debug.log('infinite scroll: adding above: top ' + div.scrollTop);
6392
- _context15.next = 14;
6696
+ _context10.next = 14;
6393
6697
  return earliest.messageTable.extendBackwards();
6394
6698
 
6395
6699
  case 14:
6396
- done = _context15.sent;
6700
+ done = _context10.sent;
6397
6701
 
6398
6702
  if (freeze) {
6399
6703
  div.scrollTop = div.scrollHeight - scrollBottom;
@@ -6402,14 +6706,14 @@ function _infiniteMessageArea() {
6402
6706
  if (fixScroll) fixScroll();
6403
6707
 
6404
6708
  if (!done) {
6405
- _context15.next = 19;
6709
+ _context10.next = 19;
6406
6710
  break;
6407
6711
  }
6408
6712
 
6409
- return _context15.abrupt("break", 21);
6713
+ return _context10.abrupt("break", 21);
6410
6714
 
6411
6715
  case 19:
6412
- _context15.next = 5;
6716
+ _context10.next = 5;
6413
6717
  break;
6414
6718
 
6415
6719
  case 21:
@@ -6417,17 +6721,17 @@ function _infiniteMessageArea() {
6417
6721
  div.scrollHeight - div.scrollTop - div.clientHeight < magicZone && // we are scrolled right to the bottom
6418
6722
  latest.messageTable && !latest.messageTable["final"] && // there is more data to come
6419
6723
  latest.messageTable.extendForwards)) {
6420
- _context15.next = 33;
6724
+ _context10.next = 33;
6421
6725
  break;
6422
6726
  }
6423
6727
 
6424
6728
  scrollTop = div.scrollTop;
6425
6729
  debug.log('infinite scroll: adding below: bottom: ' + (div.scrollHeight - div.scrollTop - div.clientHeight));
6426
- _context15.next = 26;
6730
+ _context10.next = 26;
6427
6731
  return latest.messageTable.extendForwards();
6428
6732
 
6429
6733
  case 26:
6430
- done = _context15.sent;
6734
+ done = _context10.sent;
6431
6735
 
6432
6736
  // then add more data on the bottom
6433
6737
  if (freeze) {
@@ -6437,14 +6741,14 @@ function _infiniteMessageArea() {
6437
6741
  if (fixScroll) fixScroll();
6438
6742
 
6439
6743
  if (!done) {
6440
- _context15.next = 31;
6744
+ _context10.next = 31;
6441
6745
  break;
6442
6746
  }
6443
6747
 
6444
- return _context15.abrupt("break", 33);
6748
+ return _context10.abrupt("break", 33);
6445
6749
 
6446
6750
  case 31:
6447
- _context15.next = 21;
6751
+ _context10.next = 21;
6448
6752
  break;
6449
6753
 
6450
6754
  case 33:
@@ -6452,72 +6756,68 @@ function _infiniteMessageArea() {
6452
6756
 
6453
6757
  case 34:
6454
6758
  case "end":
6455
- return _context15.stop();
6759
+ return _context10.stop();
6456
6760
  }
6457
6761
  }
6458
- }, _callee15);
6762
+ }, _callee10);
6459
6763
  }));
6460
6764
  return _loadMoreWhereNeeded.apply(this, arguments);
6461
6765
  };
6462
6766
 
6463
- loadMoreWhereNeeded = function _loadMoreWhereNeeded2(_x18, _x19) {
6767
+ loadMoreWhereNeeded = function _loadMoreWhereNeeded2(_x10, _x11) {
6464
6768
  return _loadMoreWhereNeeded.apply(this, arguments);
6465
6769
  };
6466
6770
 
6467
6771
  _appendCurrentMessages = function _appendCurrentMessage2() {
6468
- _appendCurrentMessages = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee14() {
6772
+ _appendCurrentMessages = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
6469
6773
  var now, chatDocument, messageTable;
6470
- return _regenerator["default"].wrap(function _callee14$(_context14) {
6774
+ return _regenerator["default"].wrap(function _callee9$(_context9) {
6471
6775
  while (1) {
6472
- switch (_context14.prev = _context14.next) {
6776
+ switch (_context9.prev = _context9.next) {
6473
6777
  case 0:
6474
6778
  now = new Date();
6475
- chatDocument = dateFolder.leafDocumentFromDate(now);
6476
- /* Don't actually make the documemnt until a message is sent @@@@@ WHEN SERVER FIXED
6477
- * currently server won't patch to a file ina non-existent directory
6478
- */
6479
-
6480
- /*
6481
- if (SERVER_MKDIRP_BUG) {
6482
- try {
6483
- await createIfNotExists(chatDocument)
6484
- } catch (e) {
6485
- div.appendChild(UI.widgets.errorMessageBlock(
6486
- dom, 'Problem accessing chat file: ' + e))
6487
- return
6488
- }
6489
- }
6490
- */
6491
- /// ///////////////////////////////////////////////////////////
6779
+ chatDocument = dateFolder.leafDocumentFromDate(now); /// ///////////////////////////////////////////////////////////
6492
6780
 
6493
- _context14.next = 4;
6781
+ _context9.next = 4;
6494
6782
  return createMessageTable(now, true);
6495
6783
 
6496
6784
  case 4:
6497
- messageTable = _context14.sent;
6785
+ messageTable = _context9.sent;
6498
6786
  div.appendChild(messageTable);
6787
+ div.refresh = /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
6788
+ return _regenerator["default"].wrap(function _callee8$(_context8) {
6789
+ while (1) {
6790
+ switch (_context8.prev = _context8.next) {
6791
+ case 0:
6792
+ _context8.next = 2;
6793
+ return addNewChatDocumentIfNewDay(new Date());
6794
+
6795
+ case 2:
6796
+ syncMessages(chatChannel, messageTable); // @@ livemessagetable??
6797
+
6798
+ desktopNotification(chatChannel);
6799
+
6800
+ case 4:
6801
+ case "end":
6802
+ return _context8.stop();
6803
+ }
6804
+ }
6805
+ }, _callee8);
6806
+ })); // The short chat version the live update listening is done in the pane but we do it in the widget @@
6499
6807
 
6500
- div.refresh = function () {
6501
- // only the last messageTable is live
6502
- addNewTableIfNewDay(new Date()).then(function () {
6503
- syncMessages(chatChannel, messageTable);
6504
- desktopNotification(chatChannel);
6505
- });
6506
- }; // The short chat version fors live update in the pane but we do it in the widget
6507
-
6808
+ _logic.store.updater.addDownstreamChangeListener(chatDocument, div.refresh); // Live update
6508
6809
 
6509
- kb.updater.addDownstreamChangeListener(chatDocument, div.refresh); // Live update
6510
6810
 
6511
6811
  liveMessageTable = messageTable;
6512
6812
  latest.messageTable = liveMessageTable;
6513
- return _context14.abrupt("return", messageTable);
6813
+ return _context9.abrupt("return", messageTable);
6514
6814
 
6515
6815
  case 11:
6516
6816
  case "end":
6517
- return _context14.stop();
6817
+ return _context9.stop();
6518
6818
  }
6519
6819
  }
6520
- }, _callee14);
6820
+ }, _callee9);
6521
6821
  }));
6522
6822
  return _appendCurrentMessages.apply(this, arguments);
6523
6823
  };
@@ -6526,19 +6826,18 @@ function _infiniteMessageArea() {
6526
6826
  return _appendCurrentMessages.apply(this, arguments);
6527
6827
  };
6528
6828
 
6529
- _addNewTableIfNewDay = function _addNewTableIfNewDay3() {
6530
- _addNewTableIfNewDay = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13(now) {
6829
+ _addNewChatDocumentIfNewDay = function _addNewChatDocumentIf2() {
6830
+ _addNewChatDocumentIfNewDay = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
6531
6831
  var newChatDocument, oldChatDocument, sts;
6532
- return _regenerator["default"].wrap(function _callee13$(_context13) {
6832
+ return _regenerator["default"].wrap(function _callee7$(_context7) {
6533
6833
  while (1) {
6534
- switch (_context13.prev = _context13.next) {
6834
+ switch (_context7.prev = _context7.next) {
6535
6835
  case 0:
6536
- // let now = new Date()
6537
6836
  // @@ Remove listener from previous table as it is now static
6538
- newChatDocument = dateFolder.leafDocumentFromDate(now);
6837
+ newChatDocument = dateFolder.leafDocumentFromDate(new Date());
6539
6838
 
6540
6839
  if (newChatDocument.sameTerm(latest.messageTable.chatDocument)) {
6541
- _context13.next = 7;
6840
+ _context7.next = 7;
6542
6841
  break;
6543
6842
  }
6544
6843
 
@@ -6549,36 +6848,37 @@ function _infiniteMessageArea() {
6549
6848
  }
6550
6849
 
6551
6850
  oldChatDocument = latest.messageTable.chatDocument;
6552
- _context13.next = 6;
6851
+ _context7.next = 6;
6553
6852
  return appendCurrentMessages();
6554
6853
 
6555
6854
  case 6:
6556
6855
  // Adding a link in the document will ping listeners to add the new block too
6557
- if (!kb.holds(oldChatDocument, ns.rdfs('seeAlso'), newChatDocument, oldChatDocument)) {
6856
+ if (!_logic.store.holds(oldChatDocument, ns.rdfs('seeAlso'), newChatDocument, oldChatDocument)) {
6558
6857
  sts = [$rdf.st(oldChatDocument, ns.rdfs('seeAlso'), newChatDocument, oldChatDocument)];
6559
- updater.update([], sts, function (ok, body) {
6560
- if (!ok) {
6561
- alert('Unable to link old message block to new one.' + body);
6562
- }
6563
- });
6858
+
6859
+ try {
6860
+ _logic.store.updater.update([], sts);
6861
+ } catch (err) {
6862
+ alert('Unable to link old chat file to new one:' + err);
6863
+ }
6564
6864
  }
6565
6865
 
6566
6866
  case 7:
6567
6867
  case "end":
6568
- return _context13.stop();
6868
+ return _context7.stop();
6569
6869
  }
6570
6870
  }
6571
- }, _callee13);
6871
+ }, _callee7);
6572
6872
  }));
6573
- return _addNewTableIfNewDay.apply(this, arguments);
6873
+ return _addNewChatDocumentIfNewDay.apply(this, arguments);
6574
6874
  };
6575
6875
 
6576
- addNewTableIfNewDay = function _addNewTableIfNewDay2(_x17) {
6577
- return _addNewTableIfNewDay.apply(this, arguments);
6876
+ addNewChatDocumentIfNewDay = function _addNewChatDocumentIf() {
6877
+ return _addNewChatDocumentIfNewDay.apply(this, arguments);
6578
6878
  };
6579
6879
 
6580
6880
  renderMessageTable = function _renderMessageTable(date, live) {
6581
- var scrollBackButton;
6881
+ var scrollBackbutton;
6582
6882
  var scrollForwardButton; /// ///////////////// Scroll down adding more above
6583
6883
 
6584
6884
  function extendBackwards() {
@@ -6586,23 +6886,23 @@ function _infiniteMessageArea() {
6586
6886
  }
6587
6887
 
6588
6888
  function _extendBackwards() {
6589
- _extendBackwards = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7() {
6889
+ _extendBackwards = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
6590
6890
  var done;
6591
- return _regenerator["default"].wrap(function _callee7$(_context7) {
6891
+ return _regenerator["default"].wrap(function _callee$(_context) {
6592
6892
  while (1) {
6593
- switch (_context7.prev = _context7.next) {
6893
+ switch (_context.prev = _context.next) {
6594
6894
  case 0:
6595
- _context7.next = 2;
6895
+ _context.next = 2;
6596
6896
  return insertPreviousMessages(true);
6597
6897
 
6598
6898
  case 2:
6599
- done = _context7.sent;
6899
+ done = _context.sent;
6600
6900
 
6601
6901
  if (done) {
6602
- if (scrollBackButton) {
6603
- scrollBackButton.firstChild.setAttribute('src', UI.icons.iconBase + 'noun_T-Block_1114655_000000.svg'); // T
6902
+ if (scrollBackbutton) {
6903
+ scrollBackbutton.firstChild.setAttribute('src', _iconBase.icons.iconBase + 'noun_T-Block_1114655_000000.svg'); // T
6604
6904
 
6605
- scrollBackButton.disabled = true;
6905
+ scrollBackbutton.disabled = true;
6606
6906
  }
6607
6907
 
6608
6908
  messageTable.initial = true;
@@ -6610,67 +6910,67 @@ function _infiniteMessageArea() {
6610
6910
  messageTable.extendedBack = true;
6611
6911
  }
6612
6912
 
6613
- setScrollBackButtonIcon();
6614
- return _context7.abrupt("return", done);
6913
+ setScrollBackbuttonIcon();
6914
+ return _context.abrupt("return", done);
6615
6915
 
6616
6916
  case 6:
6617
6917
  case "end":
6618
- return _context7.stop();
6918
+ return _context.stop();
6619
6919
  }
6620
6920
  }
6621
- }, _callee7);
6921
+ }, _callee);
6622
6922
  }));
6623
6923
  return _extendBackwards.apply(this, arguments);
6624
6924
  }
6625
6925
 
6626
- function setScrollBackButtonIcon() {
6627
- if (!scrollBackButton) {
6926
+ function setScrollBackbuttonIcon() {
6927
+ if (!scrollBackbutton) {
6628
6928
  return;
6629
6929
  }
6630
6930
 
6631
6931
  var sense = messageTable.extendedBack ? !newestFirst : newestFirst;
6632
6932
  var scrollBackIcon = messageTable.initial ? 'noun_T-Block_1114655_000000.svg' : getScrollbackIcon(sense);
6633
- scrollBackButton.firstChild.setAttribute('src', UI.icons.iconBase + scrollBackIcon);
6933
+ scrollBackbutton.firstChild.setAttribute('src', _iconBase.icons.iconBase + scrollBackIcon);
6634
6934
 
6635
6935
  function getScrollbackIcon(sense) {
6636
6936
  return sense ? 'noun_1369241.svg' : 'noun_1369237.svg';
6637
6937
  }
6638
6938
  }
6639
6939
 
6640
- function scrollBackButtonHandler(_x15) {
6641
- return _scrollBackButtonHandler.apply(this, arguments);
6940
+ function scrollBackbuttonHandler(_x8) {
6941
+ return _scrollBackbuttonHandler.apply(this, arguments);
6642
6942
  } /// ////////////// Scroll up adding more below
6643
6943
 
6644
6944
 
6645
- function _scrollBackButtonHandler() {
6646
- _scrollBackButtonHandler = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(_event) {
6647
- return _regenerator["default"].wrap(function _callee8$(_context8) {
6945
+ function _scrollBackbuttonHandler() {
6946
+ _scrollBackbuttonHandler = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(_event) {
6947
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
6648
6948
  while (1) {
6649
- switch (_context8.prev = _context8.next) {
6949
+ switch (_context2.prev = _context2.next) {
6650
6950
  case 0:
6651
6951
  if (!messageTable.extendedBack) {
6652
- _context8.next = 6;
6952
+ _context2.next = 6;
6653
6953
  break;
6654
6954
  }
6655
6955
 
6656
6956
  removePreviousMessages(true, messageTable);
6657
6957
  messageTable.extendedBack = false;
6658
- setScrollBackButtonIcon();
6659
- _context8.next = 8;
6958
+ setScrollBackbuttonIcon();
6959
+ _context2.next = 8;
6660
6960
  break;
6661
6961
 
6662
6962
  case 6:
6663
- _context8.next = 8;
6963
+ _context2.next = 8;
6664
6964
  return extendBackwards();
6665
6965
 
6666
6966
  case 8:
6667
6967
  case "end":
6668
- return _context8.stop();
6968
+ return _context2.stop();
6669
6969
  }
6670
6970
  }
6671
- }, _callee8);
6971
+ }, _callee2);
6672
6972
  }));
6673
- return _scrollBackButtonHandler.apply(this, arguments);
6973
+ return _scrollBackbuttonHandler.apply(this, arguments);
6674
6974
  }
6675
6975
 
6676
6976
  function extendForwards() {
@@ -6678,20 +6978,20 @@ function _infiniteMessageArea() {
6678
6978
  }
6679
6979
 
6680
6980
  function _extendForwards() {
6681
- _extendForwards = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9() {
6981
+ _extendForwards = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
6682
6982
  var done;
6683
- return _regenerator["default"].wrap(function _callee9$(_context9) {
6983
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
6684
6984
  while (1) {
6685
- switch (_context9.prev = _context9.next) {
6985
+ switch (_context3.prev = _context3.next) {
6686
6986
  case 0:
6687
- _context9.next = 2;
6987
+ _context3.next = 2;
6688
6988
  return insertPreviousMessages(false);
6689
6989
 
6690
6990
  case 2:
6691
- done = _context9.sent;
6991
+ done = _context3.sent;
6692
6992
 
6693
6993
  if (done) {
6694
- scrollForwardButton.firstChild.setAttribute('src', UI.icons.iconBase + 'noun_T-Block_1114655_000000.svg');
6994
+ scrollForwardButton.firstChild.setAttribute('src', _iconBase.icons.iconBase + 'noun_T-Block_1114655_000000.svg');
6695
6995
  scrollForwardButton.disabled = true;
6696
6996
  messageTable["final"] = true;
6697
6997
  } else {
@@ -6699,14 +6999,14 @@ function _infiniteMessageArea() {
6699
6999
  }
6700
7000
 
6701
7001
  setScrollForwardButtonIcon();
6702
- return _context9.abrupt("return", done);
7002
+ return _context3.abrupt("return", done);
6703
7003
 
6704
7004
  case 6:
6705
7005
  case "end":
6706
- return _context9.stop();
7006
+ return _context3.stop();
6707
7007
  }
6708
7008
  }
6709
- }, _callee9);
7009
+ }, _callee3);
6710
7010
  }));
6711
7011
  return _extendForwards.apply(this, arguments);
6712
7012
  }
@@ -6715,37 +7015,48 @@ function _infiniteMessageArea() {
6715
7015
  var sense = messageTable.extendedForwards ? !newestFirst : newestFirst; // noun_T-Block_1114657_000000.svg
6716
7016
 
6717
7017
  var scrollForwardIcon = messageTable["final"] ? 'noun_T-Block_1114657_000000.svg' : getScrollForwardButtonIcon(sense);
6718
- scrollForwardButton.firstChild.setAttribute('src', UI.icons.iconBase + scrollForwardIcon);
7018
+ scrollForwardButton.firstChild.setAttribute('src', _iconBase.icons.iconBase + scrollForwardIcon);
6719
7019
 
6720
7020
  function getScrollForwardButtonIcon(sense) {
6721
7021
  return !sense ? 'noun_1369241.svg' : 'noun_1369237.svg';
6722
7022
  }
6723
7023
  }
6724
7024
 
6725
- function scrollForwardButtonHandler(_x16) {
7025
+ function scrollForwardButtonHandler(_x9) {
6726
7026
  return _scrollForwardButtonHandler.apply(this, arguments);
6727
7027
  } /// ///////////////////////
6728
7028
 
7029
+ /*
7030
+ options = options || {}
7031
+ options.authorDateOnLeft = true
7032
+ const newestFirst = options.newestFirst === '1' || options.newestFirst === true // hack for now
7033
+ const channelObject = new ChatChannel(chatChannel, options)
7034
+ const dateFolder = channelObject.dateFolder
7035
+ const div = dom.createElement('div')
7036
+ const statusArea = div.appendChild(dom.createElement('div'))
7037
+ const userContext = { dom, statusArea, div: statusArea } // logged on state, pointers to user's stuff
7038
+ */
7039
+
6729
7040
 
6730
7041
  function _scrollForwardButtonHandler() {
6731
- _scrollForwardButtonHandler = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(_event) {
6732
- return _regenerator["default"].wrap(function _callee10$(_context10) {
7042
+ _scrollForwardButtonHandler = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(_event) {
7043
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
6733
7044
  while (1) {
6734
- switch (_context10.prev = _context10.next) {
7045
+ switch (_context4.prev = _context4.next) {
6735
7046
  case 0:
6736
7047
  if (!messageTable.extendedForwards) {
6737
- _context10.next = 6;
7048
+ _context4.next = 6;
6738
7049
  break;
6739
7050
  }
6740
7051
 
6741
7052
  removePreviousMessages(false, messageTable);
6742
7053
  messageTable.extendedForwards = false;
6743
7054
  setScrollForwardButtonIcon();
6744
- _context10.next = 9;
7055
+ _context4.next = 9;
6745
7056
  break;
6746
7057
 
6747
7058
  case 6:
6748
- _context10.next = 8;
7059
+ _context4.next = 8;
6749
7060
  return extendForwards();
6750
7061
 
6751
7062
  case 8:
@@ -6754,10 +7065,10 @@ function _infiniteMessageArea() {
6754
7065
 
6755
7066
  case 9:
6756
7067
  case "end":
6757
- return _context10.stop();
7068
+ return _context4.stop();
6758
7069
  }
6759
7070
  }
6760
- }, _callee10);
7071
+ }, _callee4);
6761
7072
  }));
6762
7073
  return _scrollForwardButtonHandler.apply(this, arguments);
6763
7074
  }
@@ -6777,7 +7088,7 @@ function _infiniteMessageArea() {
6777
7088
  messageTable["final"] = true;
6778
7089
  liveMessageTable = messageTable;
6779
7090
  latest.messageTable = messageTable;
6780
- var tr = newMessageForm(messageTable);
7091
+ var tr = (0, _message.renderMessageEditor)(channelObject, messageTable, userContext, options);
6781
7092
 
6782
7093
  if (newestFirst) {
6783
7094
  messageTable.insertBefore(tr, messageTable.firstChild); // If newestFirst
@@ -6792,27 +7103,27 @@ function _infiniteMessageArea() {
6792
7103
 
6793
7104
 
6794
7105
  if (options.infinite) {
6795
- var scrollBackButtonTR = dom.createElement('tr');
6796
- var scrollBackButtonCell = scrollBackButtonTR.appendChild(dom.createElement('td')); // up traingles: noun_1369237.svg
7106
+ var scrollBackbuttonTR = dom.createElement('tr');
7107
+ var scrollBackbuttonCell = scrollBackbuttonTR.appendChild(dom.createElement('td')); // up traingles: noun_1369237.svg
6797
7108
  // down triangles: noun_1369241.svg
6798
7109
 
6799
7110
  var scrollBackIcon = newestFirst ? 'noun_1369241.svg' : 'noun_1369237.svg'; // down and up arrows respoctively
6800
7111
 
6801
- scrollBackButton = UI.widgets.button(dom, UI.icons.iconBase + scrollBackIcon, 'Previous messages ...');
6802
- scrollBackButtonCell.style = 'width:3em; height:3em;';
6803
- scrollBackButton.addEventListener('click', scrollBackButtonHandler, false);
7112
+ scrollBackbutton = widgets.button(dom, _iconBase.icons.iconBase + scrollBackIcon, 'Previous messages ...');
7113
+ scrollBackbuttonCell.style = 'width:3em; height:3em;';
7114
+ scrollBackbutton.addEventListener('click', scrollBackbuttonHandler, false);
6804
7115
  messageTable.extendedBack = false;
6805
- scrollBackButtonCell.appendChild(scrollBackButton);
6806
- setScrollBackButtonIcon();
6807
- var dateCell = scrollBackButtonTR.appendChild(dom.createElement('td'));
7116
+ scrollBackbuttonCell.appendChild(scrollBackbutton);
7117
+ setScrollBackbuttonIcon();
7118
+ var dateCell = scrollBackbuttonTR.appendChild(dom.createElement('td'));
6808
7119
  dateCell.style = 'text-align: center; vertical-align: middle; color: #888; font-style: italic;';
6809
- dateCell.textContent = UI.widgets.shortDate(date.toISOString(), true); // no time, only date
7120
+ dateCell.textContent = widgets.shortDate(date.toISOString(), true); // no time, only date
6810
7121
  // @@@@@@@@@@@ todo move this button to other end of message cell, o
6811
7122
 
6812
- var scrollForwardButtonCell = scrollBackButtonTR.appendChild(dom.createElement('td'));
7123
+ var scrollForwardButtonCell = scrollBackbuttonTR.appendChild(dom.createElement('td'));
6813
7124
  var scrollForwardIcon = newestFirst ? 'noun_1369241.svg' : 'noun_1369237.svg'; // down and up arrows respoctively
6814
7125
 
6815
- scrollForwardButton = UI.widgets.button(dom, UI.icons.iconBase + scrollForwardIcon, 'Later messages ...');
7126
+ scrollForwardButton = widgets.button(dom, _iconBase.icons.iconBase + scrollForwardIcon, 'Later messages ...');
6816
7127
  scrollForwardButtonCell.appendChild(scrollForwardButton);
6817
7128
  scrollForwardButtonCell.style = 'width:3em; height:3em;';
6818
7129
  scrollForwardButton.addEventListener('click', scrollForwardButtonHandler, false);
@@ -6822,13 +7133,13 @@ function _infiniteMessageArea() {
6822
7133
 
6823
7134
  if (!newestFirst) {
6824
7135
  // opposite end from the entry field
6825
- messageTable.insertBefore(scrollBackButtonTR, messageTable.firstChild); // If not newestFirst
7136
+ messageTable.insertBefore(scrollBackbuttonTR, messageTable.firstChild); // If not newestFirst
6826
7137
  } else {
6827
- messageTable.appendChild(scrollBackButtonTR); // newestFirst
7138
+ messageTable.appendChild(scrollBackbuttonTR); // newestFirst
6828
7139
  }
6829
7140
  }
6830
7141
 
6831
- var sts = kb.statementsMatching(null, WF('message'), null, chatDocument);
7142
+ var sts = _logic.store.statementsMatching(null, ns.wf('message'), null, chatDocument);
6832
7143
 
6833
7144
  if (!live && sts.length === 0) {// not todays
6834
7145
  // no need buttomns at the moment
@@ -6845,57 +7156,57 @@ function _infiniteMessageArea() {
6845
7156
  };
6846
7157
 
6847
7158
  _createMessageTable = function _createMessageTable3() {
6848
- _createMessageTable = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12(date, live) {
7159
+ _createMessageTable = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(date, live) {
6849
7160
  var chatDocument, messageTable, statusTR;
6850
- return _regenerator["default"].wrap(function _callee12$(_context12) {
7161
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
6851
7162
  while (1) {
6852
- switch (_context12.prev = _context12.next) {
7163
+ switch (_context6.prev = _context6.next) {
6853
7164
  case 0:
6854
7165
  debug.log(' createMessageTable for ' + date);
6855
7166
  chatDocument = dateFolder.leafDocumentFromDate(date);
6856
- _context12.prev = 2;
6857
- _context12.next = 5;
6858
- return kb.fetcher.load(chatDocument);
7167
+ _context6.prev = 2;
7168
+ _context6.next = 5;
7169
+ return _logic.store.fetcher.load(chatDocument);
6859
7170
 
6860
7171
  case 5:
6861
- _context12.next = 19;
7172
+ _context6.next = 19;
6862
7173
  break;
6863
7174
 
6864
7175
  case 7:
6865
- _context12.prev = 7;
6866
- _context12.t0 = _context12["catch"](2);
7176
+ _context6.prev = 7;
7177
+ _context6.t0 = _context6["catch"](2);
6867
7178
  messageTable = dom.createElement('table');
6868
7179
  statusTR = messageTable.appendChild(dom.createElement('tr')); // ### find status in exception
6869
7180
 
6870
- if (!(_context12.t0.response && _context12.t0.response.status && _context12.t0.response.status === 404)) {
6871
- _context12.next = 16;
7181
+ if (!(_context6.t0.response && _context6.t0.response.status && _context6.t0.response.status === 404)) {
7182
+ _context6.next = 16;
6872
7183
  break;
6873
7184
  }
6874
7185
 
6875
7186
  debug.log('Error 404 for chat file ' + chatDocument);
6876
- return _context12.abrupt("return", renderMessageTable(date, live));
7187
+ return _context6.abrupt("return", renderMessageTable(date, live));
6877
7188
 
6878
7189
  case 16:
6879
7190
  debug.log('*** Error NON 404 for chat file ' + chatDocument);
6880
- statusTR.appendChild(UI.widgets.errorMessageBlock(dom, _context12.t0, 'pink'));
7191
+ statusTR.appendChild(widgets.errorMessageBlock(dom, _context6.t0, 'pink'));
6881
7192
 
6882
7193
  case 18:
6883
- return _context12.abrupt("return", statusTR);
7194
+ return _context6.abrupt("return", statusTR);
6884
7195
 
6885
7196
  case 19:
6886
- return _context12.abrupt("return", renderMessageTable(date, live));
7197
+ return _context6.abrupt("return", renderMessageTable(date, live));
6887
7198
 
6888
7199
  case 20:
6889
7200
  case "end":
6890
- return _context12.stop();
7201
+ return _context6.stop();
6891
7202
  }
6892
7203
  }
6893
- }, _callee12, null, [[2, 7]]);
7204
+ }, _callee6, null, [[2, 7]]);
6894
7205
  }));
6895
7206
  return _createMessageTable.apply(this, arguments);
6896
7207
  };
6897
7208
 
6898
- createMessageTable = function _createMessageTable2(_x13, _x14) {
7209
+ createMessageTable = function _createMessageTable2(_x6, _x7) {
6899
7210
  return _createMessageTable.apply(this, arguments);
6900
7211
  };
6901
7212
 
@@ -6917,38 +7228,38 @@ function _infiniteMessageArea() {
6917
7228
  };
6918
7229
 
6919
7230
  _insertPreviousMessages = function _insertPreviousMessag2() {
6920
- _insertPreviousMessages = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee11(backwards) {
7231
+ _insertPreviousMessages = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(backwards) {
6921
7232
  var extremity, date, live, todayDoc, doc, newMessageTable;
6922
- return _regenerator["default"].wrap(function _callee11$(_context11) {
7233
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
6923
7234
  while (1) {
6924
- switch (_context11.prev = _context11.next) {
7235
+ switch (_context5.prev = _context5.next) {
6925
7236
  case 0:
6926
7237
  extremity = backwards ? earliest : latest;
6927
7238
  date = extremity.messageTable.date; // day in mssecs
6928
7239
 
6929
- _context11.next = 4;
7240
+ _context5.next = 4;
6930
7241
  return dateFolder.loadPrevious(date, backwards);
6931
7242
 
6932
7243
  case 4:
6933
- date = _context11.sent;
7244
+ date = _context5.sent;
6934
7245
  // backwards
6935
7246
  debug.log("insertPreviousMessages: from ".concat(backwards ? 'backwards' : 'forwards', " loadPrevious: ").concat(date));
6936
7247
 
6937
7248
  if (!(!date && !backwards && !liveMessageTable)) {
6938
- _context11.next = 9;
7249
+ _context5.next = 9;
6939
7250
  break;
6940
7251
  }
6941
7252
 
6942
- _context11.next = 9;
7253
+ _context5.next = 9;
6943
7254
  return appendCurrentMessages();
6944
7255
 
6945
7256
  case 9:
6946
7257
  if (date) {
6947
- _context11.next = 11;
7258
+ _context5.next = 11;
6948
7259
  break;
6949
7260
  }
6950
7261
 
6951
- return _context11.abrupt("return", true);
7262
+ return _context5.abrupt("return", true);
6952
7263
 
6953
7264
  case 11:
6954
7265
  // done
@@ -6960,11 +7271,11 @@ function _infiniteMessageArea() {
6960
7271
  live = doc.sameTerm(todayDoc); // Is this todays?
6961
7272
  }
6962
7273
 
6963
- _context11.next = 15;
7274
+ _context5.next = 15;
6964
7275
  return createMessageTable(date, live);
6965
7276
 
6966
7277
  case 15:
6967
- newMessageTable = _context11.sent;
7278
+ newMessageTable = _context5.sent;
6968
7279
  extremity.messageTable = newMessageTable; // move pointer to earliest
6969
7280
 
6970
7281
  if (backwards ? newestFirst : !newestFirst) {
@@ -6975,30 +7286,30 @@ function _infiniteMessageArea() {
6975
7286
  div.insertBefore(newMessageTable, div.firstChild);
6976
7287
  }
6977
7288
 
6978
- return _context11.abrupt("return", live);
7289
+ return _context5.abrupt("return", live);
6979
7290
 
6980
7291
  case 19:
6981
7292
  case "end":
6982
- return _context11.stop();
7293
+ return _context5.stop();
6983
7294
  }
6984
7295
  }
6985
- }, _callee11);
7296
+ }, _callee5);
6986
7297
  }));
6987
7298
  return _insertPreviousMessages.apply(this, arguments);
6988
7299
  };
6989
7300
 
6990
- insertPreviousMessages = function _insertPreviousMessag(_x12) {
7301
+ insertPreviousMessages = function _insertPreviousMessag(_x5) {
6991
7302
  return _insertPreviousMessages.apply(this, arguments);
6992
7303
  };
6993
7304
 
6994
7305
  addMessage = function _addMessage(message, messageTable) {
6995
- var bindings = {
6996
- '?msg': message,
6997
- '?creator': kb.any(message, ns.foaf('maker')),
6998
- '?date': kb.any(message, DCT('created')),
6999
- '?content': kb.any(message, ns.sioc('content'))
7000
- };
7001
- (0, _message.renderMessage)(messageTable, bindings, messageTable.fresh, options, userContext); // fresh from elsewhere
7306
+ var latest = (0, _chatLogic.mostRecentVersion)(message); // const content = store.any(latest, ns.sioc('content'))
7307
+
7308
+ if ((0, _chatLogic.isDeleted)(latest) && !options.showDeletedMessages) {
7309
+ return; // ignore deleted messaged -- @@ could also leave a placeholder
7310
+ }
7311
+
7312
+ insertMessageIntoTable(channelObject, messageTable, message, messageTable.fresh, options, userContext); // fresh from elsewhere
7002
7313
  };
7003
7314
 
7004
7315
  syncMessages = function _syncMessages(about, messageTable) {
@@ -7011,9 +7322,10 @@ function _infiniteMessageArea() {
7011
7322
  }
7012
7323
  }
7013
7324
 
7014
- var messages = kb.statementsMatching(about, ns.wf('message'), null, messageTable.chatDocument).map(function (st) {
7325
+ var messages = _logic.store.statementsMatching(about, ns.wf('message'), null, messageTable.chatDocument).map(function (st) {
7015
7326
  return st.object;
7016
7327
  });
7328
+
7017
7329
  var stored = {};
7018
7330
  messages.forEach(function (m) {
7019
7331
  stored[m.uri] = true;
@@ -7036,470 +7348,130 @@ function _infiniteMessageArea() {
7036
7348
  for (ele = messageTable.firstChild; ele; ele = ele.nextSibling) {
7037
7349
  if (ele.AJAR_subject) {
7038
7350
  // Refresh thumbs up etc
7039
- UI.widgets.refreshTree(ele); // Things inside may have changed too
7351
+ widgets.refreshTree(ele); // Things inside may have changed too
7040
7352
  }
7041
7353
  }
7042
7354
  };
7043
7355
 
7044
- newMessageForm = function _newMessageForm(messageTable) {
7045
- var form = dom.createElement('tr');
7046
- var lhs = dom.createElement('td');
7047
- var middle = dom.createElement('td');
7048
- var rhs = dom.createElement('td');
7049
- form.appendChild(lhs);
7050
- form.appendChild(middle);
7051
- form.appendChild(rhs);
7052
- form.AJAR_date = '9999-01-01T00:00:00Z'; // ISO format for field sort
7053
-
7054
- var field, sendButton;
7055
-
7056
- function sendMessage(_x6) {
7057
- return _sendMessage.apply(this, arguments);
7058
- } // sendMessage
7356
+ // Body of main function
7357
+ options = options || {};
7358
+ options.authorDateOnLeft = false; // @@ make a user optiosn
7059
7359
 
7360
+ newestFirst = options.newestFirst === '1' || options.newestFirst === true; // hack for now
7060
7361
 
7061
- function _sendMessage() {
7062
- _sendMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(text) {
7063
- var now, sts, timestamp, dateStamp, chatDocument, message, content, sendComplete;
7064
- return _regenerator["default"].wrap(function _callee6$(_context6) {
7065
- while (1) {
7066
- switch (_context6.prev = _context6.next) {
7067
- case 0:
7068
- sendComplete = function _sendComplete() {
7069
- var bindings = {
7070
- '?msg': message,
7071
- '?content': content,
7072
- '?date': dateStamp,
7073
- '?creator': me
7074
- };
7075
- (0, _message.renderMessage)(liveMessageTable, bindings, false, options, userContext); // not green
7362
+ channelObject = new _chatLogic.ChatChannel(chatChannel, options);
7363
+ dateFolder = channelObject.dateFolder;
7364
+ div = dom.createElement('div');
7365
+ channelObject.div = div;
7366
+ statusArea = div.appendChild(dom.createElement('div'));
7367
+ userContext = {
7368
+ dom: dom,
7369
+ statusArea: statusArea,
7370
+ div: statusArea
7371
+ }; // logged on state, pointers to user's stuff
7372
+ // const messageTable = dom.createElement('table') // @@ check does this go in renderMessageTable
7076
7373
 
7077
- if (!text) {
7078
- field.value = ''; // clear from out for reuse
7374
+ earliest = {
7375
+ messageTable: null
7376
+ }; // Stuff about each end of the loaded days
7079
7377
 
7080
- field.setAttribute('style', messageBodyStyle);
7081
- field.disabled = false;
7082
- field.scrollIntoView(newestFirst); // allign bottom (top)
7378
+ latest = {
7379
+ messageTable: null
7380
+ };
7381
+ lock = false;
7382
+ _context12.next = 30;
7383
+ return loadInitialContent();
7083
7384
 
7084
- field.focus(); // Start typing next line immediately
7385
+ case 30:
7386
+ return _context12.abrupt("return", div);
7085
7387
 
7086
- field.select();
7087
- }
7088
- };
7388
+ case 31:
7389
+ case "end":
7390
+ return _context12.stop();
7391
+ }
7392
+ }
7393
+ }, _callee12);
7394
+ }));
7395
+ return _infiniteMessageArea.apply(this, arguments);
7396
+ }
7397
+ //# sourceMappingURL=infinite.js.map
7089
7398
 
7090
- now = new Date();
7091
- _context6.next = 4;
7092
- return addNewTableIfNewDay(now);
7399
+ /***/ }),
7093
7400
 
7094
- case 4:
7095
- if (!text) {
7096
- field.setAttribute('style', messageBodyStyle + 'color: #bbb;'); // pendingedit
7401
+ /***/ "./lib/chat/message.js":
7402
+ /*!*****************************!*\
7403
+ !*** ./lib/chat/message.js ***!
7404
+ \*****************************/
7405
+ /*! no static exports found */
7406
+ /***/ (function(module, exports, __webpack_require__) {
7097
7407
 
7098
- field.disabled = true;
7099
- }
7408
+ "use strict";
7100
7409
 
7101
- sts = [];
7102
- timestamp = '' + now.getTime();
7103
- dateStamp = $rdf.term(now);
7104
- chatDocument = dateFolder.leafDocumentFromDate(now);
7105
- message = kb.sym(chatDocument.uri + '#' + 'Msg' + timestamp);
7106
- content = kb.literal(text || field.value); // if (text) field.value = text No - don't destroy half-finsihed user input
7107
7410
 
7108
- sts.push(new $rdf.Statement(chatChannel, ns.wf('message'), message, chatDocument));
7109
- sts.push(new $rdf.Statement(message, ns.sioc('content'), content, chatDocument));
7110
- sts.push(new $rdf.Statement(message, DCT('created'), dateStamp, chatDocument));
7411
+ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
7111
7412
 
7112
- if (me) {
7113
- sts.push(new $rdf.Statement(message, ns.foaf('maker'), me, chatDocument));
7114
- }
7413
+ var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
7115
7414
 
7116
- if (!(SERVER_MKDIRP_BUG && (kb.fetcher.requested[chatDocument.uri] === undefined || kb.fetcher.requested[chatDocument.uri] === 404))) {
7117
- _context6.next = 19;
7118
- break;
7119
- }
7415
+ Object.defineProperty(exports, "__esModule", {
7416
+ value: true
7417
+ });
7418
+ exports.creatorAndDate = creatorAndDate;
7419
+ exports.creatorAndDateHorizontal = creatorAndDateHorizontal;
7420
+ exports.elementForImageURI = elementForImageURI;
7421
+ exports.renderMessageEditor = renderMessageEditor;
7422
+ exports.renderMessageRow = renderMessageRow;
7423
+ exports.switchToEditor = switchToEditor;
7120
7424
 
7121
- debug.log('@@@ SERVER_MKDIRP_BUG: Should only happen once: create chat file: ' + chatDocument);
7122
- _context6.next = 19;
7123
- return createIfNotExists(chatDocument);
7425
+ var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
7124
7426
 
7125
- case 19:
7126
- _context6.prev = 19;
7127
- _context6.next = 22;
7128
- return updater.update([], sts);
7427
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
7129
7428
 
7130
- case 22:
7131
- _context6.next = 28;
7132
- break;
7429
+ var _infinite = __webpack_require__(/*! ./infinite */ "./lib/chat/infinite.js");
7133
7430
 
7134
- case 24:
7135
- _context6.prev = 24;
7136
- _context6.t0 = _context6["catch"](19);
7137
- form.appendChild(UI.widgets.errorMessageBlock(dom, 'Error writing message: ' + _context6.t0));
7138
- return _context6.abrupt("return");
7431
+ var _messageTools = __webpack_require__(/*! ./messageTools */ "./lib/chat/messageTools.js");
7139
7432
 
7140
- case 28:
7141
- sendComplete();
7433
+ var _bookmarks = __webpack_require__(/*! ./bookmarks */ "./lib/chat/bookmarks.js");
7142
7434
 
7143
- case 29:
7144
- case "end":
7145
- return _context6.stop();
7146
- }
7147
- }
7148
- }, _callee6, null, [[19, 24]]);
7149
- }));
7150
- return _sendMessage.apply(this, arguments);
7151
- }
7435
+ var _chatLogic = __webpack_require__(/*! ./chatLogic */ "./lib/chat/chatLogic.js");
7152
7436
 
7153
- form.appendChild(dom.createElement('br')); // DRAG AND DROP
7437
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./lib/debug.js"));
7154
7438
 
7155
- function droppedFileHandler(files) {
7156
- var base = messageTable.chatDocument.dir().uri;
7157
- UI.widgets.uploadFiles(kb.fetcher, files, base + 'Files', base + 'Pictures', /*#__PURE__*/function () {
7158
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(theFile, destURI) {
7159
- return _regenerator["default"].wrap(function _callee2$(_context2) {
7160
- while (1) {
7161
- switch (_context2.prev = _context2.next) {
7162
- case 0:
7163
- _context2.next = 2;
7164
- return sendMessage(destURI);
7439
+ var _index = __webpack_require__(/*! ../authn/index */ "./lib/authn/index.js");
7165
7440
 
7166
- case 2:
7167
- case "end":
7168
- return _context2.stop();
7169
- }
7170
- }
7171
- }, _callee2);
7172
- }));
7441
+ var _iconBase = __webpack_require__(/*! ../iconBase */ "./lib/iconBase.js");
7173
7442
 
7174
- return function (_x7, _x8) {
7175
- return _ref.apply(this, arguments);
7176
- };
7177
- }());
7178
- } // When a set of URIs are dropped on the field
7443
+ var _logic = __webpack_require__(/*! ../logic */ "./lib/logic.js");
7179
7444
 
7445
+ var _index2 = __webpack_require__(/*! ../media/index */ "./lib/media/index.js");
7180
7446
 
7181
- var droppedURIHandler = /*#__PURE__*/function () {
7182
- var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(uris) {
7183
- var _iterator, _step, uri;
7447
+ var ns = _interopRequireWildcard(__webpack_require__(/*! ../ns */ "./lib/ns.js"));
7184
7448
 
7185
- return _regenerator["default"].wrap(function _callee3$(_context3) {
7186
- while (1) {
7187
- switch (_context3.prev = _context3.next) {
7188
- case 0:
7189
- _iterator = _createForOfIteratorHelper(uris);
7190
- _context3.prev = 1;
7449
+ var pad = _interopRequireWildcard(__webpack_require__(/*! ../pad */ "./lib/pad.js"));
7191
7450
 
7192
- _iterator.s();
7451
+ var style = _interopRequireWildcard(__webpack_require__(/*! ../style */ "./lib/style.js"));
7193
7452
 
7194
- case 3:
7195
- if ((_step = _iterator.n()).done) {
7196
- _context3.next = 9;
7197
- break;
7198
- }
7453
+ var utils = _interopRequireWildcard(__webpack_require__(/*! ../utils */ "./lib/utils/index.js"));
7199
7454
 
7200
- uri = _step.value;
7201
- _context3.next = 7;
7202
- return sendMessage(uri);
7455
+ var widgets = _interopRequireWildcard(__webpack_require__(/*! ../widgets */ "./lib/widgets/index.js"));
7203
7456
 
7204
- case 7:
7205
- _context3.next = 3;
7206
- break;
7457
+ 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); }
7207
7458
 
7208
- case 9:
7209
- _context3.next = 14;
7210
- break;
7459
+ 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; }
7211
7460
 
7212
- case 11:
7213
- _context3.prev = 11;
7214
- _context3.t0 = _context3["catch"](1);
7461
+ 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; } } }; }
7215
7462
 
7216
- _iterator.e(_context3.t0);
7463
+ 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); }
7217
7464
 
7218
- case 14:
7219
- _context3.prev = 14;
7465
+ 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; }
7220
7466
 
7221
- _iterator.f();
7467
+ // const UI = { authn, icons, ns, media, pad, rdf, store, style, utils, widgets }
7468
+ var dom = window.document; // const store = store
7222
7469
 
7223
- return _context3.finish(14);
7224
-
7225
- case 17:
7226
- case "end":
7227
- return _context3.stop();
7228
- }
7229
- }
7230
- }, _callee3, null, [[1, 11, 14, 17]]);
7231
- }));
7232
-
7233
- return function droppedURIHandler(_x9) {
7234
- return _ref2.apply(this, arguments);
7235
- };
7236
- }(); // When we are actually logged on
7237
-
7238
-
7239
- function turnOnInput() {
7240
- if (options.menuHandler && menuButton) {
7241
- var menuOptions = {
7242
- me: me,
7243
- dom: dom,
7244
- div: div,
7245
- newBase: messageTable.chatDocument.dir().uri
7246
- };
7247
- menuButton.addEventListener('click', function (event) {
7248
- options.menuHandler(event, chatChannel, menuOptions);
7249
- }, false);
7250
- } // Turn on message input
7251
-
7252
-
7253
- (0, _message.creatorAndDate)(lhs, me, '', null);
7254
- field = dom.createElement('textarea');
7255
- middle.innerHTML = '';
7256
- middle.appendChild(field);
7257
- field.rows = 3; // field.cols = 40
7258
-
7259
- field.setAttribute('style', messageBodyStyle + 'background-color: #eef;'); // Trap the Enter BEFORE it is used ti make a newline
7260
-
7261
- field.addEventListener('keydown', /*#__PURE__*/function () {
7262
- var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(e) {
7263
- return _regenerator["default"].wrap(function _callee4$(_context4) {
7264
- while (1) {
7265
- switch (_context4.prev = _context4.next) {
7266
- case 0:
7267
- if (!(e.keyCode === 13)) {
7268
- _context4.next = 4;
7269
- break;
7270
- }
7271
-
7272
- if (e.altKey) {
7273
- _context4.next = 4;
7274
- break;
7275
- }
7276
-
7277
- _context4.next = 4;
7278
- return sendMessage();
7279
-
7280
- case 4:
7281
- case "end":
7282
- return _context4.stop();
7283
- }
7284
- }
7285
- }, _callee4);
7286
- }));
7287
-
7288
- return function (_x10) {
7289
- return _ref3.apply(this, arguments);
7290
- };
7291
- }(), false);
7292
- UI.widgets.makeDropTarget(field, droppedURIHandler, droppedFileHandler);
7293
- rhs.innerHTML = '';
7294
- sendButton = UI.widgets.button(dom, UI.icons.iconBase + 'noun_383448.svg', 'Send');
7295
- sendButton.setAttribute('style', UI.style.buttonStyle + 'float: right;');
7296
- sendButton.addEventListener('click', function (_event) {
7297
- return sendMessage();
7298
- }, false);
7299
- rhs.appendChild(sendButton);
7300
- var chatDocument = dateFolder.leafDocumentFromDate(new Date());
7301
- var imageDoc;
7302
-
7303
- function getImageDoc() {
7304
- imageDoc = kb.sym(chatDocument.dir().uri + 'Image_' + Date.now() + '.png');
7305
- return imageDoc;
7306
- }
7307
-
7308
- function tookPicture(_x11) {
7309
- return _tookPicture.apply(this, arguments);
7310
- }
7311
-
7312
- function _tookPicture() {
7313
- _tookPicture = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(imageDoc) {
7314
- return _regenerator["default"].wrap(function _callee5$(_context5) {
7315
- while (1) {
7316
- switch (_context5.prev = _context5.next) {
7317
- case 0:
7318
- if (!imageDoc) {
7319
- _context5.next = 3;
7320
- break;
7321
- }
7322
-
7323
- _context5.next = 3;
7324
- return sendMessage(imageDoc.uri);
7325
-
7326
- case 3:
7327
- case "end":
7328
- return _context5.stop();
7329
- }
7330
- }
7331
- }, _callee5);
7332
- }));
7333
- return _tookPicture.apply(this, arguments);
7334
- }
7335
-
7336
- middle.appendChild(UI.media.cameraButton(dom, kb, getImageDoc, tookPicture));
7337
- UI.pad.recordParticipation(chatChannel, chatChannel.doc()); // participation =
7338
- } // turn on inpuut
7339
-
7340
-
7341
- var context = {
7342
- div: middle,
7343
- dom: dom
7344
- };
7345
- UI.authn.logIn(context).then(function (context) {
7346
- me = context.me;
7347
- turnOnInput();
7348
- Object.assign(context, userContext);
7349
- (0, _bookmarks.findBookmarkDocument)(context).then(function (context) {
7350
- debug.log('Bookmark file: ' + context.bookmarkDocument);
7351
- });
7352
- });
7353
- return form;
7354
- };
7355
-
7356
- kb = kb || UI.store;
7357
- ns = UI.ns;
7358
- WF = $rdf.Namespace('http://www.w3.org/2005/01/wf/flow#');
7359
- DCT = $rdf.Namespace('http://purl.org/dc/terms/'); // const POSIX = $rdf.Namespace('http://www.w3.org/ns/posix/stat#')
7360
-
7361
- options = options || {};
7362
- newestFirst = options.newestFirst === '1' || options.newestFirst === true; // hack for now
7363
-
7364
- dateFolder = new _dateFolder.DateFolder(chatChannel, 'chat.ttl');
7365
- options.authorAboveContent = true; // var participation // An object tracking users use and prefs
7366
-
7367
- 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;'
7368
- // 'font-size: 100%; margin: 0.1em 1em 0.1em 1em; background-color: white; white-space: pre-wrap; padding: 0.1em;'
7369
-
7370
- div = dom.createElement('div');
7371
- statusArea = div.appendChild(dom.createElement('div'));
7372
- userContext = {
7373
- dom: dom,
7374
- statusArea: statusArea,
7375
- div: statusArea
7376
- }; // logged on state, pointers to user's stuff
7377
-
7378
- updater = UI.store.updater;
7379
- /** Does a file exist on the web?
7380
- * @returns {Boolean}
7381
- */
7382
-
7383
- /*
7384
- async function documentExists (doc) {
7385
- try {
7386
- await kb.fetcher.load(doc)
7387
- } catch (err) {
7388
- if (err.response.status === 404) {
7389
- return false
7390
- } else {
7391
- debug.log('documentExists: doc load error NOT 404: ' + doc + ': ' + err)
7392
- throw err
7393
- }
7394
- }
7395
- return true
7396
- }
7397
- */
7398
-
7399
- /* Form for a new message
7400
- */
7401
-
7402
- earliest = {
7403
- messageTable: null
7404
- }; // Stuff about each end of the loaded days
7405
-
7406
- latest = {
7407
- messageTable: null
7408
- };
7409
- lock = false;
7410
- _context17.next = 35;
7411
- return loadInitialContent();
7412
-
7413
- case 35:
7414
- return _context17.abrupt("return", div);
7415
-
7416
- case 36:
7417
- case "end":
7418
- return _context17.stop();
7419
- }
7420
- }
7421
- }, _callee17);
7422
- }));
7423
- return _infiniteMessageArea.apply(this, arguments);
7424
- }
7425
- //# sourceMappingURL=infinite.js.map
7426
-
7427
- /***/ }),
7428
-
7429
- /***/ "./lib/chat/message.js":
7430
- /*!*****************************!*\
7431
- !*** ./lib/chat/message.js ***!
7432
- \*****************************/
7433
- /*! no static exports found */
7434
- /***/ (function(module, exports, __webpack_require__) {
7435
-
7436
- "use strict";
7437
-
7438
-
7439
- var _typeof = __webpack_require__(/*! @babel/runtime/helpers/typeof */ "./node_modules/@babel/runtime/helpers/typeof.js");
7440
-
7441
- Object.defineProperty(exports, "__esModule", {
7442
- value: true
7443
- });
7444
- exports.creatorAndDate = creatorAndDate;
7445
- exports.creatorAndDateHorizontal = creatorAndDateHorizontal;
7446
- exports.elementForImageURI = elementForImageURI;
7447
- exports.renderMessage = renderMessage;
7448
-
7449
- var _messageTools = __webpack_require__(/*! ./messageTools */ "./lib/chat/messageTools.js");
7450
-
7451
- var _index = __webpack_require__(/*! ../authn/index */ "./lib/authn/index.js");
7452
-
7453
- var _iconBase = __webpack_require__(/*! ../iconBase */ "./lib/iconBase.js");
7454
-
7455
- var _logic = __webpack_require__(/*! ../logic */ "./lib/logic.js");
7456
-
7457
- var _index2 = __webpack_require__(/*! ../media/index */ "./lib/media/index.js");
7458
-
7459
- var ns = _interopRequireWildcard(__webpack_require__(/*! ../ns */ "./lib/ns.js"));
7460
-
7461
- var pad = _interopRequireWildcard(__webpack_require__(/*! ../pad */ "./lib/pad.js"));
7462
-
7463
- var rdf = _interopRequireWildcard(__webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js"));
7464
-
7465
- var style = _interopRequireWildcard(__webpack_require__(/*! ../style */ "./lib/style.js"));
7466
-
7467
- var utils = _interopRequireWildcard(__webpack_require__(/*! ../utils */ "./lib/utils/index.js"));
7468
-
7469
- var widgets = _interopRequireWildcard(__webpack_require__(/*! ../widgets */ "./lib/widgets/index.js"));
7470
-
7471
- 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); }
7472
-
7473
- 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; }
7474
-
7475
- /**
7476
- * Contains the [[renderMessage]] function,
7477
- * along with [[elementForImageURI]],
7478
- * [[creatorAndDate]], and [[creatorAndDateHorizontal]]
7479
- * @packageDocumentation
7480
- */
7481
-
7482
- /* global $rdf */
7483
- // pull in first avoid cross-refs
7484
- var UI = {
7485
- authn: _index.authn,
7486
- icons: _iconBase.icons,
7487
- ns: ns,
7488
- media: _index2.media,
7489
- pad: pad,
7490
- rdf: rdf,
7491
- store: _logic.store,
7492
- style: style,
7493
- utils: utils,
7494
- widgets: widgets
7495
- };
7496
- var dom = UI.dom || window.document; // const kb = UI.store
7497
-
7498
- var messageBodyStyle = UI.style.messageBodyStyle;
7499
- var label = UI.utils.label;
7500
- /**
7501
- * HTML component for an image
7502
- */
7470
+ var messageBodyStyle = style.messageBodyStyle;
7471
+ var label = utils.label;
7472
+ /**
7473
+ * HTML component for an image
7474
+ */
7503
7475
 
7504
7476
  function elementForImageURI(imageUri, options) {
7505
7477
  var img = dom.createElement('img');
@@ -7509,14 +7481,14 @@ function elementForImageURI(imageUri, options) {
7509
7481
  height = ('' + options.inlineImageHeightEms).trim();
7510
7482
  }
7511
7483
 
7512
- img.setAttribute('style', 'max-height: ' + height + 'em; border-radius: 1em; margin: 0.7em;'); // UI.widgets.makeDropTarget(img, handleURIsDroppedOnMugshot, droppedFileHandler)
7484
+ img.setAttribute('style', 'max-height: ' + height + 'em; border-radius: 1em; margin: 0.7em;'); // widgets.makeDropTarget(img, handleURIsDroppedOnMugshot, droppedFileHandler)
7513
7485
 
7514
7486
  if (imageUri) img.setAttribute('src', imageUri);
7515
7487
  var anchor = dom.createElement('a');
7516
7488
  anchor.setAttribute('href', imageUri);
7517
7489
  anchor.setAttribute('target', 'images');
7518
7490
  anchor.appendChild(img);
7519
- UI.widgets.makeDraggable(img, $rdf.sym(imageUri));
7491
+ widgets.makeDraggable(img, $rdf.sym(imageUri));
7520
7492
  return anchor;
7521
7493
  }
7522
7494
 
@@ -7526,7 +7498,7 @@ var anchor = function anchor(text, term) {
7526
7498
 
7527
7499
  if (term && term.uri) {
7528
7500
  a.setAttribute('href', term.uri);
7529
- a.addEventListener('click', UI.widgets.openHrefInOutlineMode, true);
7501
+ a.addEventListener('click', widgets.openHrefInOutlineMode, true);
7530
7502
  a.setAttribute('style', 'color: #3B5998; text-decoration: none; '); // font-weight: bold
7531
7503
  }
7532
7504
 
@@ -7535,7 +7507,8 @@ var anchor = function anchor(text, term) {
7535
7507
  };
7536
7508
 
7537
7509
  function nick(person) {
7538
- var s = UI.store.any(person, UI.ns.foaf('nick'));
7510
+ var s = _logic.store.any(person, ns.foaf('nick'));
7511
+
7539
7512
  if (s) return '' + s.value;
7540
7513
  return '' + label(person);
7541
7514
  }
@@ -7549,7 +7522,7 @@ function creatorAndDate(td1, creator, date, message) {
7549
7522
  var nickAnchor = td1.appendChild(anchor(nick(creator), creator));
7550
7523
 
7551
7524
  if (creator.uri) {
7552
- UI.store.fetcher.nowOrWhenFetched(creator.doc(), undefined, function (_ok, _body) {
7525
+ _logic.store.fetcher.nowOrWhenFetched(creator.doc(), undefined, function (_ok, _body) {
7553
7526
  nickAnchor.textContent = nick(creator);
7554
7527
  });
7555
7528
  }
@@ -7567,7 +7540,7 @@ function creatorAndDateHorizontal(td1, creator, date, message) {
7567
7540
  var nickAnchor = td1.appendChild(anchor(label(creator), creator));
7568
7541
 
7569
7542
  if (creator.uri) {
7570
- UI.store.fetcher.nowOrWhenFetched(creator.doc(), undefined, function (_ok, _body) {
7543
+ _logic.store.fetcher.nowOrWhenFetched(creator.doc(), undefined, function (_ok, _body) {
7571
7544
  nickAnchor.textContent = nick(creator);
7572
7545
  });
7573
7546
  }
@@ -7578,143 +7551,516 @@ function creatorAndDateHorizontal(td1, creator, date, message) {
7578
7551
  td1.appendChild(dom.createElement('br'));
7579
7552
  }
7580
7553
  /**
7581
- * Renders a chat message inside a `messageTable`
7554
+ * Renders a chat message, read-only mode
7555
+ */
7556
+
7557
+
7558
+ function renderMessageRow(channelObject, message, fresh, options, userContext) {
7559
+ var colorizeByAuthor = options.colorizeByAuthor === '1' || options.colorizeByAuthor === true;
7560
+
7561
+ var creator = _logic.store.any(message, ns.foaf('maker'));
7562
+
7563
+ var date = _logic.store.any(message, ns.dct('created'));
7564
+
7565
+ var latestVersion = (0, _chatLogic.mostRecentVersion)(message);
7566
+
7567
+ var content = _logic.store.any(latestVersion, ns.sioc('content'));
7568
+
7569
+ var originalMessage = (0, _chatLogic.originalVersion)(message);
7570
+ var edited = !message.sameTerm(originalMessage);
7571
+
7572
+ var sortDate = _logic.store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()); // In message
7573
+
7574
+
7575
+ var messageRow = dom.createElement('tr');
7576
+ messageRow.AJAR_date = sortDate.value;
7577
+ messageRow.AJAR_subject = message;
7578
+ var td1 = dom.createElement('td');
7579
+ messageRow.appendChild(td1);
7580
+
7581
+ if (!options.authorDateOnLeft) {
7582
+ var img = dom.createElement('img');
7583
+ img.setAttribute('style', 'max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;');
7584
+ widgets.setImage(img, creator);
7585
+ td1.appendChild(img);
7586
+ } else {
7587
+ creatorAndDate(td1, creator, widgets.shortDate(sortDate.value), message);
7588
+ }
7589
+
7590
+ var bothDates = widgets.shortDate(sortDate.value);
7591
+
7592
+ if (edited) {
7593
+ bothDates += ' ... ' + widgets.shortDate(date.value);
7594
+ } // Render the content ot the message itself
7595
+
7596
+
7597
+ var td2 = messageRow.appendChild(dom.createElement('td'));
7598
+
7599
+ if (!options.authorDateOnLeft) {
7600
+ creatorAndDateHorizontal(td2, creator, bothDates, // widgets.shortDate(dateString)
7601
+ message);
7602
+ }
7603
+
7604
+ var text = content.value.trim();
7605
+ var isURI = /^https?:\/[^ <>]*$/i.test(text);
7606
+ var para = null;
7607
+
7608
+ if (isURI) {
7609
+ var isImage = /\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(text); // @@ Should use content-type not URI
7610
+
7611
+ if (isImage && options.expandImagesInline) {
7612
+ var _img = elementForImageURI(text, options);
7613
+
7614
+ td2.appendChild(_img);
7615
+ } else {
7616
+ // Link but not Image
7617
+ var anc = td2.appendChild(dom.createElement('a'));
7618
+ para = anc.appendChild(dom.createElement('p'));
7619
+ anc.href = text;
7620
+ para.textContent = text;
7621
+ td2.appendChild(anc);
7622
+ }
7623
+ } else {
7624
+ // text
7625
+ para = dom.createElement('p');
7626
+ td2.appendChild(para);
7627
+ para.textContent = text;
7628
+ }
7629
+
7630
+ if (para) {
7631
+ var bgcolor = colorizeByAuthor ? pad.lightColorHash(creator) : getBgColor(fresh);
7632
+ para.setAttribute('style', messageBodyStyle + 'background-color: ' + bgcolor + ';');
7633
+ }
7634
+
7635
+ function getBgColor(fresh) {
7636
+ return fresh ? '#e8ffe8' : 'white';
7637
+ } // Sentiment strip
7638
+
7639
+
7640
+ var strip = (0, _messageTools.sentimentStripLinked)(message, message.doc());
7641
+
7642
+ if (strip.children.length) {
7643
+ td2.appendChild(dom.createElement('br'));
7644
+ td2.appendChild(strip);
7645
+ } // Message tool bar button
7646
+
7647
+
7648
+ var td3 = dom.createElement('td');
7649
+ messageRow.appendChild(td3);
7650
+ var toolsButton = widgets.button(dom, _iconBase.icons.iconBase + 'noun_243787.svg', '...');
7651
+ td3.appendChild(toolsButton);
7652
+ toolsButton.addEventListener('click', function (_event) {
7653
+ if (messageRow.toolTR) {
7654
+ // already got a toolbar? Toogle
7655
+ messageRow.parentNode.removeChild(messageRow.toolTR);
7656
+ delete messageRow.toolTR;
7657
+ return;
7658
+ }
7659
+
7660
+ var toolsTR = dom.createElement('tr');
7661
+ var tools = (0, _messageTools.messageToolbar)(message, messageRow, userContext, channelObject);
7662
+ 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
7663
+
7664
+ if (messageRow.nextSibling) {
7665
+ messageRow.parentElement.insertBefore(toolsTR, messageRow.nextSibling);
7666
+ } else {
7667
+ messageRow.parentElement.appendChild(toolsTR);
7668
+ }
7669
+
7670
+ messageRow.toolTR = toolsTR;
7671
+ toolsTR.appendChild(dom.createElement('td')); // left
7672
+
7673
+ var toolsTD = toolsTR.appendChild(dom.createElement('td'));
7674
+ toolsTR.appendChild(dom.createElement('td')); // right
7675
+
7676
+ toolsTD.appendChild(tools);
7677
+ });
7678
+ return messageRow;
7679
+ }
7680
+
7681
+ function switchToEditor(messageRow, message, channelObject, userContext) {
7682
+ var messageTable = messageRow.parentNode;
7683
+ var editRow = renderMessageEditor(channelObject, messageTable, userContext, channelObject.options, (0, _chatLogic.mostRecentVersion)(message));
7684
+ messageTable.insertBefore(editRow, messageRow);
7685
+ editRow.originalRow = messageRow;
7686
+ messageRow.style.visibility = 'hidden'; // Hide the original message. unhide if user cancels edit
7687
+ }
7688
+ /* Control for a new message -- or editing an old message ***************
7689
+ *
7582
7690
  */
7583
7691
 
7584
7692
 
7585
- function renderMessage(messageTable, bindings, fresh, options, userContext) {
7586
- var colorizeByAuthor = options.colorizeByAuthor === '1' || options.colorizeByAuthor === true;
7587
- var creator = bindings['?creator'];
7588
- var message = bindings['?msg'];
7589
- var date = bindings['?date'];
7590
- var content = bindings['?content'];
7591
- var dateString = date.value;
7592
- var messageRow = dom.createElement('tr');
7593
- messageRow.AJAR_date = dateString;
7594
- messageRow.AJAR_subject = message;
7693
+ function renderMessageEditor(channelObject, messageTable, userContext, options, originalMessage) {
7694
+ function revertEditing(messageEditor) {
7695
+ messageEditor.originalRow.style.visibility = 'visible'; // restore read-only version
7696
+
7697
+ messageEditor.parentNode.removeChild(messageEditor);
7698
+ }
7699
+
7700
+ function handleFieldInput(_x) {
7701
+ return _handleFieldInput.apply(this, arguments);
7702
+ }
7703
+
7704
+ function _handleFieldInput() {
7705
+ _handleFieldInput = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(_event) {
7706
+ return _regenerator["default"].wrap(function _callee5$(_context6) {
7707
+ while (1) {
7708
+ switch (_context6.prev = _context6.next) {
7709
+ case 0:
7710
+ _context6.next = 2;
7711
+ return sendMessage(field.value, true);
7712
+
7713
+ case 2:
7714
+ case "end":
7715
+ return _context6.stop();
7716
+ }
7717
+ }
7718
+ }, _callee5);
7719
+ }));
7720
+ return _handleFieldInput.apply(this, arguments);
7721
+ }
7722
+
7723
+ function sendMessage(_x2, _x3) {
7724
+ return _sendMessage.apply(this, arguments);
7725
+ } // sendMessage
7726
+ // DRAG AND DROP
7727
+
7728
+
7729
+ function _sendMessage() {
7730
+ _sendMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(text, fromMainField) {
7731
+ var sendComplete, message, statusArea;
7732
+ return _regenerator["default"].wrap(function _callee6$(_context7) {
7733
+ while (1) {
7734
+ switch (_context7.prev = _context7.next) {
7735
+ case 0:
7736
+ sendComplete = function _sendComplete(message, _text2) {
7737
+ // const dateStamp = store.any(message, ns.dct('created'), null, message.doc())
7738
+ // const content = $rdf.literal(text2)
7739
+ (0, _infinite.insertMessageIntoTable)(channelObject, messageTable, message, false, options, userContext); // not green
7740
+
7741
+ if (originalMessage) {
7742
+ // editing another message
7743
+ var oldRow = messageEditor.originalRow; // oldRow.style.display = '' // restore read-only version, re-attack
7744
+
7745
+ if (oldRow.parentNode) {
7746
+ oldRow.parentNode.removeChild(oldRow); // No longer needed old version
7747
+ } else {
7748
+ debug.warn('No parentNode on old message ' + oldRow.textContent);
7749
+ oldRow.style.backgroundColor = '#fee';
7750
+ oldRow.style.visibility = 'hidden'; // @@ FIX THIS AND REMOVE FROM DOM INSTEAD
7751
+ }
7752
+
7753
+ messageEditor.parentNode.removeChild(messageEditor); // no longer need editor
7754
+ } else {
7755
+ if (fromMainField) {
7756
+ field.value = ''; // clear from out for reuse
7757
+
7758
+ field.setAttribute('style', messageBodyStyle);
7759
+ field.disabled = false;
7760
+ field.scrollIntoView(options.newestFirst); // allign bottom (top)
7761
+
7762
+ field.focus(); // Start typing next line immediately
7763
+
7764
+ field.select();
7765
+ }
7766
+ } // await channelObject.div.refresh() // Add new day if nec @@ add back
7767
+
7768
+ };
7769
+
7770
+ // const me = authn.currentUser() // Must be logged on or wuld have got login button
7771
+ if (fromMainField) {
7772
+ field.setAttribute('style', messageBodyStyle + 'color: #bbb;'); // pendingedit
7773
+
7774
+ field.disabled = true;
7775
+ }
7776
+
7777
+ _context7.prev = 2;
7778
+ _context7.next = 5;
7779
+ return channelObject.updateMessage(text, originalMessage);
7780
+
7781
+ case 5:
7782
+ message = _context7.sent;
7783
+ _context7.next = 13;
7784
+ break;
7785
+
7786
+ case 8:
7787
+ _context7.prev = 8;
7788
+ _context7.t0 = _context7["catch"](2);
7789
+ statusArea = userContext.statusArea || messageEditor;
7790
+ statusArea.appendChild(widgets.errorMessageBlock(dom, 'Error writing message: ' + _context7.t0));
7791
+ return _context7.abrupt("return");
7792
+
7793
+ case 13:
7794
+ sendComplete(message, text);
7795
+
7796
+ case 14:
7797
+ case "end":
7798
+ return _context7.stop();
7799
+ }
7800
+ }
7801
+ }, _callee6, null, [[2, 8]]);
7802
+ }));
7803
+ return _sendMessage.apply(this, arguments);
7804
+ }
7805
+
7806
+ function droppedFileHandler(files) {
7807
+ var base = messageTable.chatDocument.dir().uri;
7808
+ widgets.uploadFiles(_logic.store.fetcher, files, base + 'Files', base + 'Pictures', /*#__PURE__*/function () {
7809
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(theFile, destURI) {
7810
+ return _regenerator["default"].wrap(function _callee$(_context2) {
7811
+ while (1) {
7812
+ switch (_context2.prev = _context2.next) {
7813
+ case 0:
7814
+ _context2.next = 2;
7815
+ return sendMessage(destURI);
7816
+
7817
+ case 2:
7818
+ case "end":
7819
+ return _context2.stop();
7820
+ }
7821
+ }
7822
+ }, _callee);
7823
+ }));
7824
+
7825
+ return function (_x4, _x5) {
7826
+ return _ref.apply(this, arguments);
7827
+ };
7828
+ }());
7829
+ } // When a set of URIs are dropped on the field
7830
+
7831
+
7832
+ var droppedURIHandler = /*#__PURE__*/function () {
7833
+ var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(uris) {
7834
+ var _iterator, _step, uri;
7835
+
7836
+ return _regenerator["default"].wrap(function _callee2$(_context3) {
7837
+ while (1) {
7838
+ switch (_context3.prev = _context3.next) {
7839
+ case 0:
7840
+ _iterator = _createForOfIteratorHelper(uris);
7841
+ _context3.prev = 1;
7842
+
7843
+ _iterator.s();
7844
+
7845
+ case 3:
7846
+ if ((_step = _iterator.n()).done) {
7847
+ _context3.next = 9;
7848
+ break;
7849
+ }
7850
+
7851
+ uri = _step.value;
7852
+ _context3.next = 7;
7853
+ return sendMessage(uri);
7854
+
7855
+ case 7:
7856
+ _context3.next = 3;
7857
+ break;
7858
+
7859
+ case 9:
7860
+ _context3.next = 14;
7861
+ break;
7862
+
7863
+ case 11:
7864
+ _context3.prev = 11;
7865
+ _context3.t0 = _context3["catch"](1);
7866
+
7867
+ _iterator.e(_context3.t0);
7868
+
7869
+ case 14:
7870
+ _context3.prev = 14;
7871
+
7872
+ _iterator.f();
7873
+
7874
+ return _context3.finish(14);
7875
+
7876
+ case 17:
7877
+ case "end":
7878
+ return _context3.stop();
7879
+ }
7880
+ }
7881
+ }, _callee2, null, [[1, 11, 14, 17]]);
7882
+ }));
7883
+
7884
+ return function droppedURIHandler(_x6) {
7885
+ return _ref2.apply(this, arguments);
7886
+ };
7887
+ }(); // When we are actually logged on
7888
+
7889
+
7890
+ function turnOnInput() {
7891
+ function getImageDoc() {
7892
+ imageDoc = $rdf.sym(chatDocument.dir().uri + 'Image_' + Date.now() + '.png');
7893
+ return imageDoc;
7894
+ }
7895
+
7896
+ function tookPicture(_x7) {
7897
+ return _tookPicture.apply(this, arguments);
7898
+ } // Body of turnOnInput
7899
+
7900
+
7901
+ function _tookPicture() {
7902
+ _tookPicture = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(imageDoc) {
7903
+ return _regenerator["default"].wrap(function _callee4$(_context5) {
7904
+ while (1) {
7905
+ switch (_context5.prev = _context5.next) {
7906
+ case 0:
7907
+ if (!imageDoc) {
7908
+ _context5.next = 3;
7909
+ break;
7910
+ }
7911
+
7912
+ _context5.next = 3;
7913
+ return sendMessage(imageDoc.uri);
7914
+
7915
+ case 3:
7916
+ case "end":
7917
+ return _context5.stop();
7918
+ }
7919
+ }
7920
+ }, _callee4);
7921
+ }));
7922
+ return _tookPicture.apply(this, arguments);
7923
+ }
7595
7924
 
7596
- if (options.selectedMessage && options.selectedMessage.sameTerm(message)) {
7597
- messageRow.style.backgroundColor = 'yellow';
7598
- options.selectedElement = messageRow;
7599
- messageTable.selectedElement = messageRow;
7600
- }
7925
+ var menuButton;
7601
7926
 
7602
- var done = false;
7927
+ if (options.menuHandler) {
7928
+ var _menuButton = widgets.button(dom, _iconBase.icons.iconBase + 'noun_243787.svg', 'More');
7603
7929
 
7604
- for (var ele = messageTable.firstChild;; ele = ele.nextSibling) {
7605
- if (!ele) {
7606
- // empty
7607
- break;
7608
- }
7930
+ _menuButton.setAttribute('style', style.buttonStyle + 'float: right;'); // menuButton.addEventListener('click', _event => sendMessage(), false) (done in turnoninput)
7609
7931
 
7610
- var newestFirst = options.newestfirst === true;
7611
7932
 
7612
- if (dateString > ele.AJAR_date && newestFirst || dateString < ele.AJAR_date && !newestFirst) {
7613
- messageTable.insertBefore(messageRow, ele);
7614
- done = true;
7615
- break;
7933
+ rhs.appendChild(_menuButton);
7616
7934
  }
7617
- }
7618
7935
 
7619
- if (!done) {
7620
- messageTable.appendChild(messageRow);
7621
- }
7936
+ if (options.menuHandler && menuButton) {
7937
+ var _me = _index.authn.currentUser();
7622
7938
 
7623
- var td1 = dom.createElement('td');
7624
- messageRow.appendChild(td1);
7939
+ var menuOptions = {
7940
+ me: _me,
7941
+ dom: dom,
7942
+ div: null,
7943
+ // @@ was: div
7944
+ newBase: messageTable.chatDocument.dir().uri
7945
+ };
7946
+ menuButton.addEventListener('click', function (event) {
7947
+ options.menuHandler(event, channelObject.chatChannel, menuOptions);
7948
+ }, false);
7949
+ }
7625
7950
 
7626
- if (options.authorAboveContent) {
7627
- var img = dom.createElement('img');
7628
- img.setAttribute('style', 'max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;');
7629
- UI.widgets.setImage(img, creator);
7630
- td1.appendChild(img);
7631
- } else {
7632
- creatorAndDate(td1, creator, UI.widgets.shortDate(dateString), message);
7633
- } // Render the content ot the message itself
7951
+ var me = _index.authn.currentUser(); // If already logged on
7634
7952
 
7635
7953
 
7636
- var td2 = messageRow.appendChild(dom.createElement('td'));
7954
+ creatorAndDate(lhs, me, '', null);
7955
+ field = dom.createElement('textarea');
7956
+ middle.innerHTML = '';
7957
+ middle.appendChild(field);
7958
+ field.rows = 3;
7637
7959
 
7638
- if (options.authorAboveContent) {
7639
- creatorAndDateHorizontal(td2, creator, UI.widgets.shortDate(dateString), message);
7640
- }
7960
+ if (originalMessage) {
7961
+ field.value = _logic.store.anyValue(originalMessage, ns.sioc('content'), null, originalMessage.doc());
7962
+ } // field.cols = 40
7641
7963
 
7642
- var text = content.value.trim();
7643
- var isURI = /^https?:\/[^ <>]*$/i.test(text);
7644
- var para = null;
7645
7964
 
7646
- if (isURI) {
7647
- var isImage = /\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(text); // @@ Should use content-type not URI
7965
+ field.setAttribute('style', messageBodyStyle + 'background-color: #eef;'); // Trap the Enter BEFORE it is used ti make a newline
7648
7966
 
7649
- if (isImage && options.expandImagesInline) {
7650
- var _img = elementForImageURI(text, options);
7967
+ field.addEventListener('keydown', /*#__PURE__*/function () {
7968
+ var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(e) {
7969
+ return _regenerator["default"].wrap(function _callee3$(_context4) {
7970
+ while (1) {
7971
+ switch (_context4.prev = _context4.next) {
7972
+ case 0:
7973
+ if (!(e.code === 'Enter')) {
7974
+ _context4.next = 4;
7975
+ break;
7976
+ }
7651
7977
 
7652
- td2.appendChild(_img);
7653
- } else {
7654
- // Link but not Image
7655
- var anc = td2.appendChild(dom.createElement('a'));
7656
- para = anc.appendChild(dom.createElement('p'));
7657
- anc.href = text;
7658
- para.textContent = text;
7659
- td2.appendChild(anc);
7660
- }
7661
- } else {
7662
- // text
7663
- para = dom.createElement('p');
7664
- td2.appendChild(para);
7665
- para.textContent = text;
7666
- }
7978
+ if (!(!e.shiftKey && !options.shiftEnterSendsMessage || e.shiftKey && options.shiftEnterSendsMessage)) {
7979
+ _context4.next = 4;
7980
+ break;
7981
+ }
7667
7982
 
7668
- if (para) {
7669
- var bgcolor = colorizeByAuthor ? UI.pad.lightColorHash(creator) : getBgColor(fresh);
7670
- para.setAttribute('style', messageBodyStyle + 'background-color: ' + bgcolor + ';');
7671
- }
7983
+ _context4.next = 4;
7984
+ return handleFieldInput(e);
7672
7985
 
7673
- function getBgColor(fresh) {
7674
- return fresh ? '#e8ffe8' : 'white';
7675
- } // Sentiment strip
7986
+ case 4:
7987
+ case "end":
7988
+ return _context4.stop();
7989
+ }
7990
+ }
7991
+ }, _callee3);
7992
+ }));
7676
7993
 
7994
+ return function (_x8) {
7995
+ return _ref3.apply(this, arguments);
7996
+ };
7997
+ }(), false);
7998
+ widgets.makeDropTarget(field, droppedURIHandler, droppedFileHandler);
7999
+ rhs.innerHTML = '';
8000
+ sendButton = widgets.button(dom, sendIcon, 'Send');
8001
+ sendButton.style["float"] = 'right';
8002
+ sendButton.addEventListener('click', function (_event) {
8003
+ return handleFieldInput();
8004
+ }, false);
8005
+ rhs.appendChild(sendButton);
7677
8006
 
7678
- var strip = (0, _messageTools.sentimentStripLinked)(message, message.doc());
8007
+ if (originalMessage) {
8008
+ // Are we editing another message?
8009
+ var cancelButton = rhs.appendChild(widgets.cancelButton(dom));
8010
+ cancelButton.style["float"] = 'left'; // cancelButton.firstChild.style.opacity = '0.3' // moved to buttons
7679
8011
 
7680
- if (strip.children.length) {
7681
- td2.appendChild(dom.createElement('br'));
7682
- td2.appendChild(strip);
7683
- } // Message tool bar button
8012
+ cancelButton.addEventListener('click', function (_event) {
8013
+ return revertEditing(messageEditor);
8014
+ }, false);
8015
+ rhs.appendChild(cancelButton);
8016
+ }
7684
8017
 
8018
+ var chatDocument = channelObject.dateFolder.leafDocumentFromDate(new Date());
8019
+ var imageDoc;
8020
+ middle.appendChild(_index2.media.cameraButton(dom, _logic.store, getImageDoc, tookPicture));
8021
+ pad.recordParticipation(channelObject.channel, channelObject.channel.doc()); // participation =
8022
+ } // turn on inpuut
8023
+ // Body of renderMessageEditor
7685
8024
 
7686
- var td3 = dom.createElement('td');
7687
- messageRow.appendChild(td3);
7688
- var toolsButton = UI.widgets.button(dom, UI.icons.iconBase + 'noun_243787.svg', '...');
7689
- td3.appendChild(toolsButton);
7690
- toolsButton.addEventListener('click', function (_event) {
7691
- if (messageRow.toolTR) {
7692
- // already got a toolbar? Toogle
7693
- messageRow.parentNode.removeChild(messageRow.toolTR);
7694
- delete messageRow.toolTR;
7695
- return;
7696
- }
7697
8025
 
7698
- var toolsTR = dom.createElement('tr');
7699
- var tools = (0, _messageTools.messageToolbar)(message, messageRow, userContext);
7700
- 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
8026
+ var sortDate, sendIcon;
7701
8027
 
7702
- if (messageRow.nextSibling) {
7703
- messageRow.parentElement.insertBefore(toolsTR, messageRow.nextSibling);
7704
- } else {
7705
- messageRow.parentElement.appendChild(toolsTR);
7706
- }
8028
+ if (originalMessage) {
8029
+ sortDate = _logic.store.anyValue(originalMessage, ns.dct('created'), null, originalMessage.doc()); // text = store.anyValue(originalMessage, ns.sioc('content'), null, originalMessage.doc())
7707
8030
 
7708
- messageRow.toolTR = toolsTR;
7709
- toolsTR.appendChild(dom.createElement('td')); // left
8031
+ sendIcon = _iconBase.icons.iconBase + 'noun_1180158.svg'; // Green check
8032
+ // cancelIcon = icons.iconBase + 'noun_1180156.svg' // Black cross
8033
+ } else {
8034
+ sendIcon = _iconBase.icons.iconBase + 'noun_383448.svg';
8035
+ sortDate = '9999-01-01T00:00:00Z'; // ISO format for field sort
8036
+ // text = ''
8037
+ }
7710
8038
 
7711
- var toolsTD = toolsTR.appendChild(dom.createElement('td'));
7712
- toolsTR.appendChild(dom.createElement('td')); // right
8039
+ var messageEditor = dom.createElement('tr');
8040
+ var lhs = dom.createElement('td');
8041
+ var middle = dom.createElement('td');
8042
+ var rhs = dom.createElement('td');
8043
+ messageEditor.appendChild(lhs);
8044
+ messageEditor.appendChild(middle);
8045
+ messageEditor.appendChild(rhs);
8046
+ messageEditor.AJAR_date = sortDate; // messageEditor.appendChild(dom.createElement('br'))
7713
8047
 
7714
- toolsTD.appendChild(tools);
8048
+ var field, sendButton;
8049
+ var context = {
8050
+ div: middle,
8051
+ dom: dom
8052
+ };
8053
+
8054
+ _index.authn.logIn(context).then(function (context) {
8055
+ // me = context.me
8056
+ turnOnInput();
8057
+ Object.assign(context, userContext);
8058
+ (0, _bookmarks.findBookmarkDocument)(context).then(function (_context) {// console.log('Bookmark file: ' + context.bookmarkDocument)
8059
+ });
7715
8060
  });
7716
- return messageRow;
7717
- }
8061
+
8062
+ return messageEditor;
8063
+ } // renderMessageEditor
7718
8064
  //# sourceMappingURL=message.js.map
7719
8065
 
7720
8066
  /***/ }),
@@ -7746,28 +8092,28 @@ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/r
7746
8092
 
7747
8093
  var _slicedToArray2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/slicedToArray */ "./node_modules/@babel/runtime/helpers/slicedToArray.js"));
7748
8094
 
8095
+ var debug = _interopRequireWildcard(__webpack_require__(/*! ../debug */ "./lib/debug.js"));
8096
+
7749
8097
  var _index = __webpack_require__(/*! ../authn/index */ "./lib/authn/index.js");
7750
8098
 
7751
8099
  var _iconBase = __webpack_require__(/*! ../iconBase */ "./lib/iconBase.js");
7752
8100
 
7753
8101
  var _logic = __webpack_require__(/*! ../logic */ "./lib/logic.js");
7754
8102
 
7755
- var _index2 = __webpack_require__(/*! ../media/index */ "./lib/media/index.js");
7756
-
7757
8103
  var ns = _interopRequireWildcard(__webpack_require__(/*! ../ns */ "./lib/ns.js"));
7758
8104
 
7759
- var pad = _interopRequireWildcard(__webpack_require__(/*! ../pad */ "./lib/pad.js"));
7760
-
7761
8105
  var rdf = _interopRequireWildcard(__webpack_require__(/*! rdflib */ "./node_modules/rdflib/esm/index.js"));
7762
8106
 
7763
- var style = _interopRequireWildcard(__webpack_require__(/*! ../style */ "./lib/style.js"));
7764
-
7765
8107
  var utils = _interopRequireWildcard(__webpack_require__(/*! ../utils */ "./lib/utils/index.js"));
7766
8108
 
7767
8109
  var widgets = _interopRequireWildcard(__webpack_require__(/*! ../widgets */ "./lib/widgets/index.js"));
7768
8110
 
7769
8111
  var _bookmarks = __webpack_require__(/*! ./bookmarks */ "./lib/chat/bookmarks.js");
7770
8112
 
8113
+ var _chatLogic = __webpack_require__(/*! ./chatLogic */ "./lib/chat/chatLogic.js");
8114
+
8115
+ var _message = __webpack_require__(/*! ./message */ "./lib/chat/message.js");
8116
+
7771
8117
  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); }
7772
8118
 
7773
8119
  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; }
@@ -7781,52 +8127,29 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
7781
8127
  * If you made it originally: edit, delete, attach
7782
8128
  * @packageDocumentation
7783
8129
  */
7784
-
7785
- /* global $rdf */
8130
+ // import { media } from '../media/index'
8131
+ // import * as pad from '../pad'
7786
8132
  // pull in first avoid cross-refs
7787
- var UI = {
7788
- authn: _index.authn,
7789
- icons: _iconBase.icons,
7790
- ns: ns,
7791
- media: _index2.media,
7792
- pad: pad,
7793
- rdf: rdf,
7794
- store: _logic.store,
7795
- style: style,
7796
- utils: utils,
7797
- widgets: widgets
7798
- };
7799
- var dom = window.document;
7800
- var kb = _logic.store; // const label = UI.utils.label
7801
- // THE UNUSED ICONS are here as reminders for possible future functionality
8133
+ // import * as style from '../style'
8134
+ // import { infiniteMessageArea } from './infinite.js'
8135
+ // import { renderMessage, creatorAndDate } from './message'
8136
+ // import * as debug from '../debug'
8137
+ var dom = window.document; // THE UNUSED ICONS are here as reminders for possible future functionality
7802
8138
  // const BOOKMARK_ICON = 'noun_45961.svg'
7803
8139
  // const HEART_ICON = 'noun_130259.svg' -> Add this to my (private) favorites
7804
8140
  // const MENU_ICON = 'noun_897914.svg'
7805
8141
  // const PAPERCLIP_ICON = 'noun_25830.svg' -> add attachments to this message
7806
8142
  // const PIN_ICON = 'noun_562340.svg' -> pin this message permanently in the chat UI
7807
- // const PENCIL_ICON = 'noun_253504.svg'
8143
+
8144
+ var PENCIL_ICON = 'noun_253504.svg'; // edit a message
7808
8145
  // const SPANNER_ICON = 'noun_344563.svg' -> settings
7809
8146
 
7810
8147
  var THUMBS_UP_ICON = 'noun_1384132.svg';
7811
- var THUMBS_DOWN_ICON = 'noun_1384135.svg'; // module.export = { messageTools, sentimentStripLinked, sentimentStrip }
7812
- // @@@@ use the one in rdflib.js when it is avaiable and delete this
7813
-
7814
- function updatePromise(del, ins) {
7815
- return new Promise(function (resolve, reject) {
7816
- kb.updater.update(del, ins, function (uri, ok, errorBody) {
7817
- if (!ok) {
7818
- reject(new Error(errorBody));
7819
- } else {
7820
- resolve();
7821
- }
7822
- }); // callback
7823
- }); // promise
7824
- }
8148
+ var THUMBS_DOWN_ICON = 'noun_1384135.svg';
7825
8149
  /**
7826
8150
  * Emoji in Unicode
7827
8151
  */
7828
8152
 
7829
-
7830
8153
  var emoji = {};
7831
8154
  emoji[ns.schema('AgreeAction')] = '👍';
7832
8155
  emoji[ns.schema('DisagreeAction')] = '👎';
@@ -7837,9 +8160,11 @@ emoji[ns.schema('LikeAction')] = '❤️';
7837
8160
  */
7838
8161
 
7839
8162
  function sentimentStrip(target, doc) {
7840
- var actions = kb.each(null, ns.schema('target'), target, doc);
8163
+ // alain seems not used
8164
+ var latest = (0, _chatLogic.mostRecentVersion)(target);
8165
+ var actions = _logic.store.holds(latest, ns.schema('dateDeleted').value, null, latest.doc()) ? _logic.store.each(null, ns.schema('target'), target, doc) : [];
7841
8166
  var sentiments = actions.map(function (a) {
7842
- return kb.any(a, ns.rdf('type'), null, doc);
8167
+ return _logic.store.any(a, ns.rdf('type'), null, doc);
7843
8168
  });
7844
8169
  sentiments.sort();
7845
8170
  var strings = sentiments.map(function (x) {
@@ -7860,9 +8185,9 @@ function sentimentStripLinked(target, doc) {
7860
8185
 
7861
8186
  function refresh() {
7862
8187
  strip.innerHTML = '';
7863
- var actions = kb.each(null, ns.schema('target'), target, doc);
8188
+ var actions = (0, _chatLogic.mostRecentVersion)(target).uri !== ns.schema('dateDeleted').uri ? _logic.store.each(null, ns.schema('target'), target, doc) : [];
7864
8189
  var sentiments = actions.map(function (a) {
7865
- return [kb.any(a, ns.rdf('type'), null, doc), kb.any(a, ns.schema('agent'), null, doc)];
8190
+ return [_logic.store.any(a, ns.rdf('type'), null, doc), _logic.store.any(a, ns.schema('agent'), null, doc)];
7866
8191
  });
7867
8192
  sentiments.sort();
7868
8193
  sentiments.forEach(function (ss) {
@@ -7893,60 +8218,142 @@ function sentimentStripLinked(target, doc) {
7893
8218
  */
7894
8219
 
7895
8220
 
7896
- function messageToolbar(message, messageRow, userContext) {
7897
- var div = dom.createElement('div');
8221
+ function messageToolbar(message, messageRow, userContext, channelObject) {
8222
+ function deleteMessage() {
8223
+ return _deleteMessage.apply(this, arguments);
8224
+ }
7898
8225
 
7899
- function closeToolbar() {
7900
- div.parentElement.parentElement.removeChild(div.parentElement); // remive the TR
8226
+ function _deleteMessage() {
8227
+ _deleteMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
8228
+ var author, msg, area;
8229
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
8230
+ while (1) {
8231
+ switch (_context2.prev = _context2.next) {
8232
+ case 0:
8233
+ author = _logic.store.any(message, ns.foaf('maker'));
8234
+
8235
+ if (me) {
8236
+ _context2.next = 5;
8237
+ break;
8238
+ }
8239
+
8240
+ alert('You can\'t delete the message, you are not logged in.');
8241
+ _context2.next = 22;
8242
+ break;
8243
+
8244
+ case 5:
8245
+ if (!me.sameTerm(author)) {
8246
+ _context2.next = 21;
8247
+ break;
8248
+ }
8249
+
8250
+ _context2.prev = 6;
8251
+ _context2.next = 9;
8252
+ return channelObject.deleteMessage(message);
8253
+
8254
+ case 9:
8255
+ _context2.next = 18;
8256
+ break;
8257
+
8258
+ case 11:
8259
+ _context2.prev = 11;
8260
+ _context2.t0 = _context2["catch"](6);
8261
+ msg = 'Error deleting messaage ' + _context2.t0;
8262
+ debug.warn(msg);
8263
+ alert(msg);
8264
+ area = userContext.statusArea || messageRow.parentNode;
8265
+ area.appendChild(widgets.errorMessageBlock(dom, msg));
8266
+
8267
+ case 18:
8268
+ messageRow.parentNode.removeChild(messageRow);
8269
+ _context2.next = 22;
8270
+ break;
8271
+
8272
+ case 21:
8273
+ alert('You can\'t delete the message, you are not logged in as the author, ' + author);
8274
+
8275
+ case 22:
8276
+ closeToolbar();
8277
+
8278
+ case 23:
8279
+ case "end":
8280
+ return _context2.stop();
8281
+ }
8282
+ }
8283
+ }, _callee2, null, [[6, 11]]);
8284
+ }));
8285
+ return _deleteMessage.apply(this, arguments);
7901
8286
  }
7902
8287
 
7903
- function deleteThingThen(_x) {
7904
- return _deleteThingThen.apply(this, arguments);
7905
- } // Things only the original author can do
8288
+ function editMessage(_x) {
8289
+ return _editMessage.apply(this, arguments);
8290
+ } // alain TODO allow chat owner to fully delete message + sentiments and replacing messages
7906
8291
 
7907
8292
 
7908
- function _deleteThingThen() {
7909
- _deleteThingThen = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(x) {
8293
+ function _editMessage() {
8294
+ _editMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(messageRow) {
7910
8295
  return _regenerator["default"].wrap(function _callee3$(_context3) {
7911
8296
  while (1) {
7912
8297
  switch (_context3.prev = _context3.next) {
7913
8298
  case 0:
7914
- _context3.next = 2;
7915
- return updatePromise(kb.connectedStatements(x), []);
8299
+ if (me.value === _logic.store.any(message, ns.foaf('maker')).value) {
8300
+ closeToolbar(); // edit is a one-off action
7916
8301
 
7917
- case 2:
8302
+ (0, _message.switchToEditor)(messageRow, message, channelObject, userContext);
8303
+ }
8304
+
8305
+ case 1:
7918
8306
  case "end":
7919
8307
  return _context3.stop();
7920
8308
  }
7921
8309
  }
7922
8310
  }, _callee3);
7923
8311
  }));
7924
- return _deleteThingThen.apply(this, arguments);
8312
+ return _editMessage.apply(this, arguments);
7925
8313
  }
7926
8314
 
7927
- var me = UI.authn.currentUser(); // If already logged on
8315
+ var div = dom.createElement('div'); // is message deleted ?
7928
8316
 
7929
- if (me && kb.holds(message, ns.foaf('maker'), me)) {
7930
- // button to delete the message
7931
- var deleteButton = UI.widgets.deleteButtonWithCheck(dom, div, 'message', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
7932
- return _regenerator["default"].wrap(function _callee$(_context) {
8317
+ if ((0, _chatLogic.mostRecentVersion)(message).value === ns.schema('dateDeleted').value) return div;
8318
+
8319
+ function closeToolbar() {
8320
+ div.parentElement.parentElement.removeChild(div.parentElement); // remive the TR
8321
+ }
8322
+
8323
+ function deleteThingThen(_x2) {
8324
+ return _deleteThingThen.apply(this, arguments);
8325
+ } // Things only the original author can do
8326
+
8327
+
8328
+ function _deleteThingThen() {
8329
+ _deleteThingThen = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(x) {
8330
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
7933
8331
  while (1) {
7934
- switch (_context.prev = _context.next) {
8332
+ switch (_context4.prev = _context4.next) {
7935
8333
  case 0:
7936
- _context.next = 2;
7937
- return kb.updater.update(kb.connectedStatements[message], []);
8334
+ _context4.next = 2;
8335
+ return _logic.store.updater.update(_logic.store.connectedStatements(x), []);
7938
8336
 
7939
8337
  case 2:
7940
- closeToolbar();
7941
-
7942
- case 3:
7943
8338
  case "end":
7944
- return _context.stop();
8339
+ return _context4.stop();
7945
8340
  }
7946
8341
  }
7947
- }, _callee);
7948
- })));
7949
- div.appendChild(deleteButton);
8342
+ }, _callee4);
8343
+ }));
8344
+ return _deleteThingThen.apply(this, arguments);
8345
+ }
8346
+
8347
+ var me = _index.authn.currentUser(); // If already logged on
8348
+
8349
+
8350
+ if (me && _logic.store.holds(message, ns.foaf('maker'), me)) {
8351
+ // button to delete the message
8352
+ div.appendChild(widgets.deleteButtonWithCheck(dom, div, 'message', deleteMessage)); // button to edit the message
8353
+
8354
+ div.appendChild(widgets.button(dom, _iconBase.icons.iconBase + PENCIL_ICON, 'edit', function () {
8355
+ return editMessage(messageRow);
8356
+ }));
7950
8357
  } // if mine
7951
8358
  // Things anyone can do if they have a bookmark list async
7952
8359
 
@@ -7977,39 +8384,39 @@ function messageToolbar(message, messageRow, userContext) {
7977
8384
  button.style.backgroundColor = action ? 'yellow' : 'white';
7978
8385
  }
7979
8386
 
7980
- var button = UI.widgets.button(dom, icon, UI.utils.label(actionClass), /*#__PURE__*/function () {
7981
- var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(_event) {
8387
+ var button = widgets.button(dom, icon, utils.label(actionClass), /*#__PURE__*/function () {
8388
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_event) {
7982
8389
  var insertMe, dirty, i, a;
7983
- return _regenerator["default"].wrap(function _callee2$(_context2) {
8390
+ return _regenerator["default"].wrap(function _callee$(_context) {
7984
8391
  while (1) {
7985
- switch (_context2.prev = _context2.next) {
8392
+ switch (_context.prev = _context.next) {
7986
8393
  case 0:
7987
8394
  if (!action) {
7988
- _context2.next = 7;
8395
+ _context.next = 7;
7989
8396
  break;
7990
8397
  }
7991
8398
 
7992
- _context2.next = 3;
8399
+ _context.next = 3;
7993
8400
  return deleteThingThen(action);
7994
8401
 
7995
8402
  case 3:
7996
8403
  action = null;
7997
8404
  setColor();
7998
- _context2.next = 25;
8405
+ _context.next = 25;
7999
8406
  break;
8000
8407
 
8001
8408
  case 7:
8002
8409
  // no action
8003
- action = UI.widgets.newThing(doc);
8004
- 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)];
8005
- _context2.next = 11;
8006
- return updatePromise([], insertMe);
8410
+ action = widgets.newThing(doc);
8411
+ 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)];
8412
+ _context.next = 11;
8413
+ return _logic.store.updater.update([], insertMe);
8007
8414
 
8008
8415
  case 11:
8009
8416
  setColor();
8010
8417
 
8011
8418
  if (!mutuallyExclusive) {
8012
- _context2.next = 25;
8419
+ _context.next = 25;
8013
8420
  break;
8014
8421
  }
8015
8422
 
@@ -8019,18 +8426,18 @@ function messageToolbar(message, messageRow, userContext) {
8019
8426
 
8020
8427
  case 15:
8021
8428
  if (!(i < mutuallyExclusive.length)) {
8022
- _context2.next = 24;
8429
+ _context.next = 24;
8023
8430
  break;
8024
8431
  }
8025
8432
 
8026
8433
  a = existingAction(mutuallyExclusive[i]);
8027
8434
 
8028
8435
  if (!a) {
8029
- _context2.next = 21;
8436
+ _context.next = 21;
8030
8437
  break;
8031
8438
  }
8032
8439
 
8033
- _context2.next = 20;
8440
+ _context.next = 20;
8034
8441
  return deleteThingThen(a);
8035
8442
 
8036
8443
  case 20:
@@ -8039,34 +8446,35 @@ function messageToolbar(message, messageRow, userContext) {
8039
8446
 
8040
8447
  case 21:
8041
8448
  i++;
8042
- _context2.next = 15;
8449
+ _context.next = 15;
8043
8450
  break;
8044
8451
 
8045
8452
  case 24:
8046
8453
  if (dirty) {
8047
- // UI.widgets.refreshTree(button.parentNode) // requires them all to be immediate siblings
8048
- UI.widgets.refreshTree(messageRow); // requires them all to be immediate siblings
8454
+ // widgets.refreshTree(button.parentNode) // requires them all to be immediate siblings
8455
+ widgets.refreshTree(messageRow); // requires them all to be immediate siblings
8049
8456
  }
8050
8457
 
8051
8458
  case 25:
8052
8459
  case "end":
8053
- return _context2.stop();
8460
+ return _context.stop();
8054
8461
  }
8055
8462
  }
8056
- }, _callee2);
8463
+ }, _callee);
8057
8464
  }));
8058
8465
 
8059
- return function (_x2) {
8060
- return _ref2.apply(this, arguments);
8466
+ return function (_x3) {
8467
+ return _ref.apply(this, arguments);
8061
8468
  };
8062
8469
  }());
8063
8470
 
8064
8471
  function existingAction(actionClass) {
8065
- var actions = kb.each(null, ns.schema('agent'), context.me, doc).filter(function (x) {
8066
- return kb.holds(x, ns.rdf('type'), actionClass, doc);
8472
+ var actions = _logic.store.each(null, ns.schema('agent'), context.me, doc).filter(function (x) {
8473
+ return _logic.store.holds(x, ns.rdf('type'), actionClass, doc);
8067
8474
  }).filter(function (x) {
8068
- return kb.holds(x, ns.schema('target'), target, doc);
8475
+ return _logic.store.holds(x, ns.schema('target'), target, doc);
8069
8476
  });
8477
+
8070
8478
  return actions.length ? actions[0] : null;
8071
8479
  }
8072
8480
 
@@ -8084,23 +8492,23 @@ function messageToolbar(message, messageRow, userContext) {
8084
8492
  // https://schema.org/AgreeAction
8085
8493
 
8086
8494
 
8087
- me = UI.authn.currentUser(); // If already logged on
8495
+ me = _index.authn.currentUser(); // If already logged on
8496
+ // debug.log('Actions 3' + mostRecentVersion(message).value + ' ' + ns.schema('dateDeleted').value + ' ' + (mostRecentVersion(message).value !== ns.schema('dateDeleted').value))
8088
8497
 
8089
- if (me) {
8090
- // Things you mnust be logged in for
8498
+ if (me && (0, _chatLogic.mostRecentVersion)(message).value !== ns.schema('dateDeleted').value) {
8091
8499
  var context1 = {
8092
8500
  me: me,
8093
8501
  dom: dom,
8094
8502
  div: div
8095
8503
  };
8096
- div.appendChild(sentimentButton(context1, message, // @@ TODO use UI.widgets.sentimentButton
8097
- UI.icons.iconBase + THUMBS_UP_ICON, ns.schema('AgreeAction'), message.doc(), [ns.schema('DisagreeAction')])); // Thumbs down
8504
+ div.appendChild(sentimentButton(context1, message, // @@ TODO use widgets.sentimentButton
8505
+ _iconBase.icons.iconBase + THUMBS_UP_ICON, ns.schema('AgreeAction'), message.doc(), [ns.schema('DisagreeAction')])); // Thumbs down
8098
8506
 
8099
- div.appendChild(sentimentButton(context1, message, UI.icons.iconBase + THUMBS_DOWN_ICON, ns.schema('DisagreeAction'), message.doc(), [ns.schema('AgreeAction')]));
8507
+ div.appendChild(sentimentButton(context1, message, _iconBase.icons.iconBase + THUMBS_DOWN_ICON, ns.schema('DisagreeAction'), message.doc(), [ns.schema('AgreeAction')]));
8100
8508
  } // X button to remove the tool UI itself
8101
8509
 
8102
8510
 
8103
- var cancelButton = div.appendChild(UI.widgets.cancelButton(dom));
8511
+ var cancelButton = div.appendChild(widgets.cancelButton(dom));
8104
8512
  cancelButton.style["float"] = 'right';
8105
8513
  cancelButton.firstChild.style.opacity = '0.3';
8106
8514
  cancelButton.addEventListener('click', closeToolbar);
@@ -15733,10 +16141,10 @@ Object.defineProperty(exports, "__esModule", {
15733
16141
  });
15734
16142
  exports["default"] = void 0;
15735
16143
  var _default = {
15736
- buildTime: '2022-01-27T19:22:56Z',
15737
- commit: 'fb2b21e1e0c28c850c52cb27596b0bd4d509a104',
16144
+ buildTime: '2022-01-28T22:55:43Z',
16145
+ commit: '9d83fb1702a1835b5d82fb97bc51b3cb98285373',
15738
16146
  npmInfo: {
15739
- 'solid-ui': '2.4.15',
16147
+ 'solid-ui': '2.4.16',
15740
16148
  npm: '6.14.15',
15741
16149
  ares: '1.18.1',
15742
16150
  brotli: '1.0.9',
@@ -16455,7 +16863,14 @@ function button(dom, iconURI, text, handler) {
16455
16863
 
16456
16864
 
16457
16865
  function cancelButton(dom, handler) {
16458
- return button(dom, cancelIconURI, 'Cancel', handler);
16866
+ var b = button(dom, cancelIconURI, 'Cancel', handler);
16867
+
16868
+ if (b.firstChild) {
16869
+ // sigh for tsc
16870
+ b.firstChild.style.opacity = '0.3'; // Black X is too harsh: current language is grey X
16871
+ }
16872
+
16873
+ return b;
16459
16874
  }
16460
16875
  /* Make a continue button
16461
16876
  *