stream-chat-react-native-core 5.26.1-beta.1 → 5.26.1-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/Channel/Channel.js +399 -359
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Chat/Chat.js +12 -5
- package/lib/commonjs/components/Chat/Chat.js.map +1 -1
- package/lib/commonjs/components/Chat/hooks/useCreateChatContext.js +2 -0
- package/lib/commonjs/components/Chat/hooks/useCreateChatContext.js.map +1 -1
- package/lib/commonjs/contexts/chatContext/ChatContext.js +2 -2
- package/lib/commonjs/contexts/chatContext/ChatContext.js.map +1 -1
- package/lib/commonjs/i18n/es.json +12 -12
- package/lib/commonjs/i18n/fr.json +12 -12
- package/lib/commonjs/i18n/he.json +12 -12
- package/lib/commonjs/i18n/hi.json +12 -12
- package/lib/commonjs/i18n/it.json +12 -12
- package/lib/commonjs/i18n/ja.json +12 -12
- package/lib/commonjs/i18n/ko.json +12 -12
- package/lib/commonjs/i18n/nl.json +12 -12
- package/lib/commonjs/i18n/pt-BR.json +12 -12
- package/lib/commonjs/i18n/ru.json +12 -12
- package/lib/commonjs/i18n/tr.json +12 -12
- package/lib/commonjs/utils/StreamChatRN.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Channel/Channel.js +399 -359
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Chat/Chat.js +12 -5
- package/lib/module/components/Chat/Chat.js.map +1 -1
- package/lib/module/components/Chat/hooks/useCreateChatContext.js +2 -0
- package/lib/module/components/Chat/hooks/useCreateChatContext.js.map +1 -1
- package/lib/module/contexts/chatContext/ChatContext.js +2 -2
- package/lib/module/contexts/chatContext/ChatContext.js.map +1 -1
- package/lib/module/i18n/es.json +12 -12
- package/lib/module/i18n/fr.json +12 -12
- package/lib/module/i18n/he.json +12 -12
- package/lib/module/i18n/hi.json +12 -12
- package/lib/module/i18n/it.json +12 -12
- package/lib/module/i18n/ja.json +12 -12
- package/lib/module/i18n/ko.json +12 -12
- package/lib/module/i18n/nl.json +12 -12
- package/lib/module/i18n/pt-BR.json +12 -12
- package/lib/module/i18n/ru.json +12 -12
- package/lib/module/i18n/tr.json +12 -12
- package/lib/module/utils/StreamChatRN.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Chat/Chat.d.ts +1 -1
- package/lib/typescript/components/Chat/hooks/useCreateChatContext.d.ts +1 -1
- package/lib/typescript/contexts/chatContext/ChatContext.d.ts +4 -0
- package/lib/typescript/i18n/es.json +12 -12
- package/lib/typescript/i18n/fr.json +12 -12
- package/lib/typescript/i18n/he.json +12 -12
- package/lib/typescript/i18n/hi.json +12 -12
- package/lib/typescript/i18n/it.json +12 -12
- package/lib/typescript/i18n/ja.json +12 -12
- package/lib/typescript/i18n/ko.json +12 -12
- package/lib/typescript/i18n/nl.json +12 -12
- package/lib/typescript/i18n/pt-BR.json +12 -12
- package/lib/typescript/i18n/ru.json +12 -12
- package/lib/typescript/i18n/tr.json +12 -12
- package/lib/typescript/utils/StreamChatRN.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/Channel/Channel.tsx +52 -34
- package/src/components/Chat/Chat.tsx +7 -1
- package/src/components/Chat/hooks/useCreateChatContext.ts +2 -0
- package/src/contexts/chatContext/ChatContext.tsx +4 -0
- package/src/i18n/es.json +12 -12
- package/src/i18n/fr.json +12 -12
- package/src/i18n/he.json +12 -12
- package/src/i18n/hi.json +12 -12
- package/src/i18n/it.json +12 -12
- package/src/i18n/ja.json +12 -12
- package/src/i18n/ko.json +12 -12
- package/src/i18n/nl.json +12 -12
- package/src/i18n/pt-BR.json +12 -12
- package/src/i18n/ru.json +12 -12
- package/src/i18n/tr.json +12 -12
- package/src/utils/StreamChatRN.ts +2 -0
- package/src/version.json +1 -1
|
@@ -146,7 +146,7 @@ var debounceOptions = {
|
|
|
146
146
|
trailing: true
|
|
147
147
|
};
|
|
148
148
|
var ChannelWithContext = function ChannelWithContext(props) {
|
|
149
|
-
var _client$user, _channel$data2,
|
|
149
|
+
var _client$user, _channel$data2, _ref30, _ref31;
|
|
150
150
|
var additionalKeyboardAvoidingViewProps = props.additionalKeyboardAvoidingViewProps,
|
|
151
151
|
additionalTextInputProps = props.additionalTextInputProps,
|
|
152
152
|
additionalTouchableProps = props.additionalTouchableProps,
|
|
@@ -779,71 +779,111 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
779
779
|
return unreadMessageIdToScrollTo;
|
|
780
780
|
});
|
|
781
781
|
};
|
|
782
|
-
var loadChannelAroundMessage = function
|
|
783
|
-
var
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
782
|
+
var loadChannelAroundMessage = function () {
|
|
783
|
+
var _ref6 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee5(_ref5) {
|
|
784
|
+
var messageIdToLoadAround;
|
|
785
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
786
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
788
787
|
case 0:
|
|
789
|
-
|
|
790
|
-
if (!
|
|
791
|
-
|
|
788
|
+
messageIdToLoadAround = _ref5.messageId;
|
|
789
|
+
if (!thread) {
|
|
790
|
+
_context5.next = 18;
|
|
792
791
|
break;
|
|
793
792
|
}
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
return channel.state.loadMessageIntoState(messageIdToLoadAround);
|
|
797
|
-
case 5:
|
|
798
|
-
currentMessageSet = channel.state.messageSets.find(function (set) {
|
|
799
|
-
return set.isCurrent;
|
|
800
|
-
});
|
|
801
|
-
if (!(currentMessageSet && !(currentMessageSet != null && currentMessageSet.isLatest))) {
|
|
802
|
-
_context4.next = 10;
|
|
793
|
+
if (!messageIdToLoadAround) {
|
|
794
|
+
_context5.next = 16;
|
|
803
795
|
break;
|
|
804
796
|
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
_context4.next = 14;
|
|
797
|
+
setThreadLoadingMore(true);
|
|
798
|
+
_context5.prev = 4;
|
|
799
|
+
_context5.next = 7;
|
|
800
|
+
return channel.state.loadMessageIntoState(messageIdToLoadAround, thread.id);
|
|
801
|
+
case 7:
|
|
802
|
+
setThreadLoadingMore(false);
|
|
803
|
+
setThreadMessages(channel.state.threads[thread.id]);
|
|
804
|
+
setTargetedMessage(messageIdToLoadAround);
|
|
805
|
+
_context5.next = 16;
|
|
815
806
|
break;
|
|
816
807
|
case 12:
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
808
|
+
_context5.prev = 12;
|
|
809
|
+
_context5.t0 = _context5["catch"](4);
|
|
810
|
+
if (_context5.t0 instanceof Error) {
|
|
811
|
+
setError(_context5.t0);
|
|
812
|
+
} else {
|
|
813
|
+
setError(true);
|
|
814
|
+
}
|
|
815
|
+
setThreadLoadingMore(false);
|
|
816
|
+
case 16:
|
|
817
|
+
_context5.next = 20;
|
|
818
|
+
break;
|
|
819
|
+
case 18:
|
|
820
|
+
_context5.next = 20;
|
|
821
|
+
return channelQueryCallRef.current((0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4() {
|
|
822
|
+
var currentMessageSet, recentCurrentSetMsgId;
|
|
823
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
824
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
825
|
+
case 0:
|
|
826
|
+
setLoading(true);
|
|
827
|
+
if (!messageIdToLoadAround) {
|
|
828
|
+
_context4.next = 10;
|
|
829
|
+
break;
|
|
830
|
+
}
|
|
831
|
+
setMessages([]);
|
|
832
|
+
_context4.next = 5;
|
|
833
|
+
return channel.state.loadMessageIntoState(messageIdToLoadAround);
|
|
834
|
+
case 5:
|
|
835
|
+
currentMessageSet = channel.state.messageSets.find(function (set) {
|
|
836
|
+
return set.isCurrent;
|
|
837
|
+
});
|
|
838
|
+
if (!(currentMessageSet && !(currentMessageSet != null && currentMessageSet.isLatest))) {
|
|
839
|
+
_context4.next = 10;
|
|
840
|
+
break;
|
|
841
|
+
}
|
|
842
|
+
recentCurrentSetMsgId = currentMessageSet.messages[currentMessageSet.messages.length - 1].id;
|
|
843
|
+
_context4.next = 10;
|
|
844
|
+
return channel.query({
|
|
845
|
+
messages: {
|
|
846
|
+
id_gte: recentCurrentSetMsgId,
|
|
847
|
+
limit: 25
|
|
848
|
+
}
|
|
849
|
+
}, 'current');
|
|
850
|
+
case 10:
|
|
851
|
+
case "end":
|
|
852
|
+
return _context4.stop();
|
|
853
|
+
}
|
|
854
|
+
}, _callee4);
|
|
855
|
+
})), function () {
|
|
856
|
+
if (messageIdToLoadAround) {
|
|
857
|
+
clearInterval(mergeSetsIntervalRef.current);
|
|
858
|
+
setTargetedMessage(messageIdToLoadAround);
|
|
859
|
+
}
|
|
860
|
+
}, messageIdToLoadAround);
|
|
861
|
+
case 20:
|
|
820
862
|
case "end":
|
|
821
|
-
return
|
|
863
|
+
return _context5.stop();
|
|
822
864
|
}
|
|
823
|
-
},
|
|
824
|
-
}))
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
}, messageIdToLoadAround);
|
|
830
|
-
};
|
|
865
|
+
}, _callee5, null, [[4, 12]]);
|
|
866
|
+
}));
|
|
867
|
+
return function loadChannelAroundMessage(_x2) {
|
|
868
|
+
return _ref6.apply(this, arguments);
|
|
869
|
+
};
|
|
870
|
+
}();
|
|
831
871
|
(0, _react.useEffect)(function () {
|
|
832
872
|
if (!targetedMessage && prevTargetedMessage) {
|
|
833
873
|
restartSetsMergeFuncRef.current();
|
|
834
874
|
}
|
|
835
875
|
}, [targetedMessage]);
|
|
836
|
-
var loadChannelAtMessage = function loadChannelAtMessage(
|
|
837
|
-
var
|
|
838
|
-
after =
|
|
839
|
-
|
|
840
|
-
before =
|
|
841
|
-
messageId =
|
|
842
|
-
return channelQueryCallRef.current((0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function
|
|
843
|
-
return _regenerator["default"].wrap(function
|
|
844
|
-
while (1) switch (
|
|
876
|
+
var loadChannelAtMessage = function loadChannelAtMessage(_ref8) {
|
|
877
|
+
var _ref8$after = _ref8.after,
|
|
878
|
+
after = _ref8$after === void 0 ? 2 : _ref8$after,
|
|
879
|
+
_ref8$before = _ref8.before,
|
|
880
|
+
before = _ref8$before === void 0 ? 30 : _ref8$before,
|
|
881
|
+
messageId = _ref8.messageId;
|
|
882
|
+
return channelQueryCallRef.current((0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee6() {
|
|
883
|
+
return _regenerator["default"].wrap(function _callee6$(_context6) {
|
|
884
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
845
885
|
case 0:
|
|
846
|
-
|
|
886
|
+
_context6.next = 2;
|
|
847
887
|
return queryAtMessage({
|
|
848
888
|
after: after,
|
|
849
889
|
before: before,
|
|
@@ -855,9 +895,9 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
855
895
|
}
|
|
856
896
|
case 3:
|
|
857
897
|
case "end":
|
|
858
|
-
return
|
|
898
|
+
return _context6.stop();
|
|
859
899
|
}
|
|
860
|
-
},
|
|
900
|
+
}, _callee6);
|
|
861
901
|
})));
|
|
862
902
|
};
|
|
863
903
|
var splitLatestCurrentMessageSetRef = (0, _react.useRef)(function () {
|
|
@@ -910,14 +950,14 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
910
950
|
clearInterval(mergeSetsIntervalRef.current);
|
|
911
951
|
if (!hasOverlappingRecentMessagesRef.current) return;
|
|
912
952
|
});
|
|
913
|
-
var loadLatestMessagesRef = (0, _react.useRef)((0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function
|
|
953
|
+
var loadLatestMessagesRef = (0, _react.useRef)((0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee7() {
|
|
914
954
|
var clearLatest,
|
|
915
955
|
latestSet,
|
|
916
|
-
|
|
917
|
-
return _regenerator["default"].wrap(function
|
|
918
|
-
while (1) switch (
|
|
956
|
+
_args7 = arguments;
|
|
957
|
+
return _regenerator["default"].wrap(function _callee7$(_context7) {
|
|
958
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
919
959
|
case 0:
|
|
920
|
-
clearLatest =
|
|
960
|
+
clearLatest = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : false;
|
|
921
961
|
mergeOverlappingMessageSetsRef.current();
|
|
922
962
|
if (clearLatest) {
|
|
923
963
|
latestSet = channel.state.messageSets.find(function (set) {
|
|
@@ -926,143 +966,143 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
926
966
|
if (latestSet) latestSet.messages = [];
|
|
927
967
|
}
|
|
928
968
|
if (!(channel.state.latestMessages.length === 0)) {
|
|
929
|
-
|
|
969
|
+
_context7.next = 6;
|
|
930
970
|
break;
|
|
931
971
|
}
|
|
932
|
-
|
|
972
|
+
_context7.next = 6;
|
|
933
973
|
return channel.query({}, 'latest');
|
|
934
974
|
case 6:
|
|
935
|
-
|
|
975
|
+
_context7.next = 8;
|
|
936
976
|
return channel.state.loadMessageIntoState('latest');
|
|
937
977
|
case 8:
|
|
938
978
|
case "end":
|
|
939
|
-
return
|
|
979
|
+
return _context7.stop();
|
|
940
980
|
}
|
|
941
|
-
},
|
|
981
|
+
}, _callee7);
|
|
942
982
|
})));
|
|
943
983
|
var loadChannel = function loadChannel() {
|
|
944
|
-
return channelQueryCallRef.current((0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function
|
|
945
|
-
return _regenerator["default"].wrap(function
|
|
946
|
-
while (1) switch (
|
|
984
|
+
return channelQueryCallRef.current((0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee8() {
|
|
985
|
+
return _regenerator["default"].wrap(function _callee8$(_context8) {
|
|
986
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
947
987
|
case 0:
|
|
948
988
|
if (!(!(channel != null && channel.initialized) || !channel.state.isUpToDate)) {
|
|
949
|
-
|
|
989
|
+
_context8.next = 7;
|
|
950
990
|
break;
|
|
951
991
|
}
|
|
952
|
-
|
|
992
|
+
_context8.next = 3;
|
|
953
993
|
return channel == null ? void 0 : channel.watch();
|
|
954
994
|
case 3:
|
|
955
995
|
channel == null ? void 0 : channel.state.setIsUpToDate(true);
|
|
956
996
|
setHasNoMoreRecentMessagesToLoad(true);
|
|
957
|
-
|
|
997
|
+
_context8.next = 9;
|
|
958
998
|
break;
|
|
959
999
|
case 7:
|
|
960
|
-
|
|
1000
|
+
_context8.next = 9;
|
|
961
1001
|
return channel.state.loadMessageIntoState('latest');
|
|
962
1002
|
case 9:
|
|
963
1003
|
case "end":
|
|
964
|
-
return
|
|
1004
|
+
return _context8.stop();
|
|
965
1005
|
}
|
|
966
|
-
},
|
|
1006
|
+
}, _callee8);
|
|
967
1007
|
})));
|
|
968
1008
|
};
|
|
969
1009
|
var reloadThread = function () {
|
|
970
|
-
var
|
|
1010
|
+
var _ref12 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee9() {
|
|
971
1011
|
var parentID, limit, queryResponse, updatedHasMore, updatedThreadMessages, _yield$channel$getMes, _messages, _messages2, threadMessage, formattedMessage;
|
|
972
|
-
return _regenerator["default"].wrap(function
|
|
973
|
-
while (1) switch (
|
|
1012
|
+
return _regenerator["default"].wrap(function _callee9$(_context9) {
|
|
1013
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
974
1014
|
case 0:
|
|
975
1015
|
if (!(!channel || !(thread != null && thread.id))) {
|
|
976
|
-
|
|
1016
|
+
_context9.next = 2;
|
|
977
1017
|
break;
|
|
978
1018
|
}
|
|
979
|
-
return
|
|
1019
|
+
return _context9.abrupt("return");
|
|
980
1020
|
case 2:
|
|
981
1021
|
setThreadLoadingMore(true);
|
|
982
|
-
|
|
1022
|
+
_context9.prev = 3;
|
|
983
1023
|
parentID = thread.id;
|
|
984
1024
|
limit = 50;
|
|
985
1025
|
channel.state.threads[parentID] = [];
|
|
986
|
-
|
|
1026
|
+
_context9.next = 9;
|
|
987
1027
|
return channel.getReplies(parentID, {
|
|
988
1028
|
limit: limit
|
|
989
1029
|
});
|
|
990
1030
|
case 9:
|
|
991
|
-
queryResponse =
|
|
1031
|
+
queryResponse = _context9.sent;
|
|
992
1032
|
updatedHasMore = queryResponse.messages.length === limit;
|
|
993
1033
|
updatedThreadMessages = channel.state.threads[parentID] || [];
|
|
994
1034
|
loadMoreThreadFinished(updatedHasMore, updatedThreadMessages);
|
|
995
|
-
|
|
1035
|
+
_context9.next = 15;
|
|
996
1036
|
return channel.getMessagesById([parentID]);
|
|
997
1037
|
case 15:
|
|
998
|
-
_yield$channel$getMes =
|
|
1038
|
+
_yield$channel$getMes = _context9.sent;
|
|
999
1039
|
_messages = _yield$channel$getMes.messages;
|
|
1000
1040
|
_messages2 = (0, _slicedToArray2["default"])(_messages, 1), threadMessage = _messages2[0];
|
|
1001
1041
|
if (threadMessage) {
|
|
1002
1042
|
formattedMessage = channel.state.formatMessage(threadMessage);
|
|
1003
1043
|
setThread(formattedMessage);
|
|
1004
1044
|
}
|
|
1005
|
-
|
|
1045
|
+
_context9.next = 27;
|
|
1006
1046
|
break;
|
|
1007
1047
|
case 21:
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
console.warn('Thread loading request failed with error',
|
|
1011
|
-
if (
|
|
1012
|
-
setError(
|
|
1048
|
+
_context9.prev = 21;
|
|
1049
|
+
_context9.t0 = _context9["catch"](3);
|
|
1050
|
+
console.warn('Thread loading request failed with error', _context9.t0);
|
|
1051
|
+
if (_context9.t0 instanceof Error) {
|
|
1052
|
+
setError(_context9.t0);
|
|
1013
1053
|
} else {
|
|
1014
1054
|
setError(true);
|
|
1015
1055
|
}
|
|
1016
1056
|
setThreadLoadingMore(false);
|
|
1017
|
-
throw
|
|
1057
|
+
throw _context9.t0;
|
|
1018
1058
|
case 27:
|
|
1019
1059
|
case "end":
|
|
1020
|
-
return
|
|
1060
|
+
return _context9.stop();
|
|
1021
1061
|
}
|
|
1022
|
-
},
|
|
1062
|
+
}, _callee9, null, [[3, 21]]);
|
|
1023
1063
|
}));
|
|
1024
1064
|
return function reloadThread() {
|
|
1025
|
-
return
|
|
1065
|
+
return _ref12.apply(this, arguments);
|
|
1026
1066
|
};
|
|
1027
1067
|
}();
|
|
1028
1068
|
var resyncChannel = function () {
|
|
1029
|
-
var
|
|
1069
|
+
var _ref13 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee10() {
|
|
1030
1070
|
var _messages$, state, oldListTopMessage, oldListTopMessageId, oldListBottomMessage, newListTopMessage, newListBottomMessage, parseMessage, failedMessages, failedThreadMessages, oldListTopMessageCreatedAt, oldListBottomMessageCreatedAt, newListTopMessageCreatedAt, newListBottomMessageCreatedAt, finalMessages, index;
|
|
1031
|
-
return _regenerator["default"].wrap(function
|
|
1032
|
-
while (1) switch (
|
|
1071
|
+
return _regenerator["default"].wrap(function _callee10$(_context10) {
|
|
1072
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
1033
1073
|
case 0:
|
|
1034
1074
|
if (!(!channel || syncingChannelRef.current)) {
|
|
1035
|
-
|
|
1075
|
+
_context10.next = 2;
|
|
1036
1076
|
break;
|
|
1037
1077
|
}
|
|
1038
|
-
return
|
|
1078
|
+
return _context10.abrupt("return");
|
|
1039
1079
|
case 2:
|
|
1040
1080
|
if (channel.initialized) {
|
|
1041
|
-
|
|
1081
|
+
_context10.next = 4;
|
|
1042
1082
|
break;
|
|
1043
1083
|
}
|
|
1044
|
-
return
|
|
1084
|
+
return _context10.abrupt("return");
|
|
1045
1085
|
case 4:
|
|
1046
1086
|
hasOverlappingRecentMessagesRef.current = false;
|
|
1047
1087
|
clearInterval(mergeSetsIntervalRef.current);
|
|
1048
1088
|
syncingChannelRef.current = true;
|
|
1049
1089
|
setError(false);
|
|
1050
|
-
|
|
1051
|
-
|
|
1090
|
+
_context10.prev = 8;
|
|
1091
|
+
_context10.next = 11;
|
|
1052
1092
|
return channel.watch({
|
|
1053
1093
|
messages: {
|
|
1054
1094
|
limit: messages.length + 30
|
|
1055
1095
|
}
|
|
1056
1096
|
});
|
|
1057
1097
|
case 11:
|
|
1058
|
-
state =
|
|
1098
|
+
state = _context10.sent;
|
|
1059
1099
|
oldListTopMessage = messages[0];
|
|
1060
1100
|
oldListTopMessageId = (_messages$ = messages[0]) == null ? void 0 : _messages$.id;
|
|
1061
1101
|
oldListBottomMessage = messages[messages.length - 1];
|
|
1062
1102
|
newListTopMessage = state.messages[0];
|
|
1063
1103
|
newListBottomMessage = state.messages[state.messages.length - 1];
|
|
1064
1104
|
if (!(!oldListTopMessage || !oldListBottomMessage || !newListTopMessage || !newListBottomMessage)) {
|
|
1065
|
-
|
|
1105
|
+
_context10.next = 24;
|
|
1066
1106
|
break;
|
|
1067
1107
|
}
|
|
1068
1108
|
channel.state.clearMessages();
|
|
@@ -1070,7 +1110,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1070
1110
|
channel.state.addMessagesSorted(state.messages);
|
|
1071
1111
|
channel.state.addPinnedMessages(state.pinned_messages);
|
|
1072
1112
|
copyChannelState();
|
|
1073
|
-
return
|
|
1113
|
+
return _context10.abrupt("return");
|
|
1074
1114
|
case 24:
|
|
1075
1115
|
parseMessage = function parseMessage(message) {
|
|
1076
1116
|
var _message$pinned_at, _message$updated_at;
|
|
@@ -1110,20 +1150,20 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1110
1150
|
channel.state.addMessagesSorted(failedMessages);
|
|
1111
1151
|
copyChannelState();
|
|
1112
1152
|
}
|
|
1113
|
-
|
|
1153
|
+
_context10.next = 43;
|
|
1114
1154
|
return reloadThread();
|
|
1115
1155
|
case 43:
|
|
1116
1156
|
if (thread && failedThreadMessages.length) {
|
|
1117
1157
|
channel.state.addMessagesSorted(failedThreadMessages);
|
|
1118
1158
|
setThreadMessages((0, _toConsumableArray2["default"])(channel.state.threads[thread.id]));
|
|
1119
1159
|
}
|
|
1120
|
-
|
|
1160
|
+
_context10.next = 50;
|
|
1121
1161
|
break;
|
|
1122
1162
|
case 46:
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
if (
|
|
1126
|
-
setError(
|
|
1163
|
+
_context10.prev = 46;
|
|
1164
|
+
_context10.t0 = _context10["catch"](8);
|
|
1165
|
+
if (_context10.t0 instanceof Error) {
|
|
1166
|
+
setError(_context10.t0);
|
|
1127
1167
|
} else {
|
|
1128
1168
|
setError(true);
|
|
1129
1169
|
}
|
|
@@ -1132,12 +1172,12 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1132
1172
|
syncingChannelRef.current = false;
|
|
1133
1173
|
case 51:
|
|
1134
1174
|
case "end":
|
|
1135
|
-
return
|
|
1175
|
+
return _context10.stop();
|
|
1136
1176
|
}
|
|
1137
|
-
},
|
|
1177
|
+
}, _callee10, null, [[8, 46]]);
|
|
1138
1178
|
}));
|
|
1139
1179
|
return function resyncChannel() {
|
|
1140
|
-
return
|
|
1180
|
+
return _ref13.apply(this, arguments);
|
|
1141
1181
|
};
|
|
1142
1182
|
}();
|
|
1143
1183
|
var resyncChannelRef = (0, _react.useRef)(resyncChannel);
|
|
@@ -1167,12 +1207,12 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1167
1207
|
};
|
|
1168
1208
|
}, [enableOfflineSupport, shouldSyncChannel]);
|
|
1169
1209
|
var reloadChannel = function reloadChannel() {
|
|
1170
|
-
return channelQueryCallRef.current((0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function
|
|
1171
|
-
return _regenerator["default"].wrap(function
|
|
1172
|
-
while (1) switch (
|
|
1210
|
+
return channelQueryCallRef.current((0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee11() {
|
|
1211
|
+
return _regenerator["default"].wrap(function _callee11$(_context11) {
|
|
1212
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
1173
1213
|
case 0:
|
|
1174
1214
|
setLoading(true);
|
|
1175
|
-
|
|
1215
|
+
_context11.next = 3;
|
|
1176
1216
|
return loadLatestMessagesRef.current(true);
|
|
1177
1217
|
case 3:
|
|
1178
1218
|
setLoading(false);
|
|
@@ -1180,23 +1220,23 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1180
1220
|
setHasNoMoreRecentMessagesToLoad(true);
|
|
1181
1221
|
case 6:
|
|
1182
1222
|
case "end":
|
|
1183
|
-
return
|
|
1223
|
+
return _context11.stop();
|
|
1184
1224
|
}
|
|
1185
|
-
},
|
|
1225
|
+
}, _callee11);
|
|
1186
1226
|
})));
|
|
1187
1227
|
};
|
|
1188
1228
|
var queryAtMessage = function () {
|
|
1189
|
-
var
|
|
1190
|
-
var
|
|
1191
|
-
return _regenerator["default"].wrap(function
|
|
1192
|
-
while (1) switch (
|
|
1229
|
+
var _ref16 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee12(_ref15) {
|
|
1230
|
+
var _ref15$after, after, _ref15$before, before, messageId;
|
|
1231
|
+
return _regenerator["default"].wrap(function _callee12$(_context12) {
|
|
1232
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1193
1233
|
case 0:
|
|
1194
|
-
|
|
1234
|
+
_ref15$after = _ref15.after, after = _ref15$after === void 0 ? 10 : _ref15$after, _ref15$before = _ref15.before, before = _ref15$before === void 0 ? 10 : _ref15$before, messageId = _ref15.messageId;
|
|
1195
1235
|
if (channel) {
|
|
1196
|
-
|
|
1236
|
+
_context12.next = 3;
|
|
1197
1237
|
break;
|
|
1198
1238
|
}
|
|
1199
|
-
return
|
|
1239
|
+
return _context12.abrupt("return");
|
|
1200
1240
|
case 3:
|
|
1201
1241
|
channel.state.setIsUpToDate(false);
|
|
1202
1242
|
hasOverlappingRecentMessagesRef.current = false;
|
|
@@ -1204,10 +1244,10 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1204
1244
|
channel.state.clearMessages();
|
|
1205
1245
|
setMessages([]);
|
|
1206
1246
|
if (messageId) {
|
|
1207
|
-
|
|
1247
|
+
_context12.next = 13;
|
|
1208
1248
|
break;
|
|
1209
1249
|
}
|
|
1210
|
-
|
|
1250
|
+
_context12.next = 11;
|
|
1211
1251
|
return channel.query({
|
|
1212
1252
|
messages: {
|
|
1213
1253
|
limit: before
|
|
@@ -1216,38 +1256,38 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1216
1256
|
});
|
|
1217
1257
|
case 11:
|
|
1218
1258
|
channel.state.setIsUpToDate(true);
|
|
1219
|
-
return
|
|
1259
|
+
return _context12.abrupt("return");
|
|
1220
1260
|
case 13:
|
|
1221
|
-
|
|
1261
|
+
_context12.next = 15;
|
|
1222
1262
|
return queryBeforeMessage(messageId, before);
|
|
1223
1263
|
case 15:
|
|
1224
|
-
|
|
1264
|
+
_context12.next = 17;
|
|
1225
1265
|
return queryAfterMessage(messageId, after);
|
|
1226
1266
|
case 17:
|
|
1227
1267
|
case "end":
|
|
1228
|
-
return
|
|
1268
|
+
return _context12.stop();
|
|
1229
1269
|
}
|
|
1230
|
-
},
|
|
1270
|
+
}, _callee12);
|
|
1231
1271
|
}));
|
|
1232
|
-
return function queryAtMessage(
|
|
1233
|
-
return
|
|
1272
|
+
return function queryAtMessage(_x3) {
|
|
1273
|
+
return _ref16.apply(this, arguments);
|
|
1234
1274
|
};
|
|
1235
1275
|
}();
|
|
1236
1276
|
var queryBeforeMessage = function () {
|
|
1237
|
-
var
|
|
1277
|
+
var _ref17 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee13(messageId) {
|
|
1238
1278
|
var limit,
|
|
1239
|
-
|
|
1240
|
-
return _regenerator["default"].wrap(function
|
|
1241
|
-
while (1) switch (
|
|
1279
|
+
_args13 = arguments;
|
|
1280
|
+
return _regenerator["default"].wrap(function _callee13$(_context13) {
|
|
1281
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1242
1282
|
case 0:
|
|
1243
|
-
limit =
|
|
1283
|
+
limit = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : 5;
|
|
1244
1284
|
if (channel) {
|
|
1245
|
-
|
|
1285
|
+
_context13.next = 3;
|
|
1246
1286
|
break;
|
|
1247
1287
|
}
|
|
1248
|
-
return
|
|
1288
|
+
return _context13.abrupt("return");
|
|
1249
1289
|
case 3:
|
|
1250
|
-
|
|
1290
|
+
_context13.next = 5;
|
|
1251
1291
|
return channel.query({
|
|
1252
1292
|
messages: {
|
|
1253
1293
|
id_lt: messageId,
|
|
@@ -1259,31 +1299,31 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1259
1299
|
channel.state.setIsUpToDate(false);
|
|
1260
1300
|
case 6:
|
|
1261
1301
|
case "end":
|
|
1262
|
-
return
|
|
1302
|
+
return _context13.stop();
|
|
1263
1303
|
}
|
|
1264
|
-
},
|
|
1304
|
+
}, _callee13);
|
|
1265
1305
|
}));
|
|
1266
|
-
return function queryBeforeMessage(
|
|
1267
|
-
return
|
|
1306
|
+
return function queryBeforeMessage(_x4) {
|
|
1307
|
+
return _ref17.apply(this, arguments);
|
|
1268
1308
|
};
|
|
1269
1309
|
}();
|
|
1270
1310
|
var queryAfterMessage = function () {
|
|
1271
|
-
var
|
|
1311
|
+
var _ref18 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee14(messageId) {
|
|
1272
1312
|
var limit,
|
|
1273
1313
|
state,
|
|
1274
1314
|
currentSet,
|
|
1275
|
-
|
|
1276
|
-
return _regenerator["default"].wrap(function
|
|
1277
|
-
while (1) switch (
|
|
1315
|
+
_args14 = arguments;
|
|
1316
|
+
return _regenerator["default"].wrap(function _callee14$(_context14) {
|
|
1317
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1278
1318
|
case 0:
|
|
1279
|
-
limit =
|
|
1319
|
+
limit = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : 5;
|
|
1280
1320
|
if (channel) {
|
|
1281
|
-
|
|
1321
|
+
_context14.next = 3;
|
|
1282
1322
|
break;
|
|
1283
1323
|
}
|
|
1284
|
-
return
|
|
1324
|
+
return _context14.abrupt("return");
|
|
1285
1325
|
case 3:
|
|
1286
|
-
|
|
1326
|
+
_context14.next = 5;
|
|
1287
1327
|
return channel.query({
|
|
1288
1328
|
messages: {
|
|
1289
1329
|
id_gte: messageId,
|
|
@@ -1292,7 +1332,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1292
1332
|
watch: true
|
|
1293
1333
|
});
|
|
1294
1334
|
case 5:
|
|
1295
|
-
state =
|
|
1335
|
+
state = _context14.sent;
|
|
1296
1336
|
if (state.messages.length < limit) {
|
|
1297
1337
|
currentSet = channel.state.messageSets.find(function (set) {
|
|
1298
1338
|
return set.isCurrent;
|
|
@@ -1312,12 +1352,12 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1312
1352
|
}
|
|
1313
1353
|
case 7:
|
|
1314
1354
|
case "end":
|
|
1315
|
-
return
|
|
1355
|
+
return _context14.stop();
|
|
1316
1356
|
}
|
|
1317
|
-
},
|
|
1357
|
+
}, _callee14);
|
|
1318
1358
|
}));
|
|
1319
|
-
return function queryAfterMessage(
|
|
1320
|
-
return
|
|
1359
|
+
return function queryAfterMessage(_x5) {
|
|
1360
|
+
return _ref18.apply(this, arguments);
|
|
1321
1361
|
};
|
|
1322
1362
|
}();
|
|
1323
1363
|
var getChannelConfigSafely = function getChannelConfigSafely() {
|
|
@@ -1350,12 +1390,12 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1350
1390
|
setMessages(channel.state.messages);
|
|
1351
1391
|
}
|
|
1352
1392
|
};
|
|
1353
|
-
var createMessagePreview = function createMessagePreview(
|
|
1354
|
-
var attachments =
|
|
1355
|
-
mentioned_users =
|
|
1356
|
-
parent_id =
|
|
1357
|
-
text =
|
|
1358
|
-
extraFields = (0, _objectWithoutProperties2["default"])(
|
|
1393
|
+
var createMessagePreview = function createMessagePreview(_ref19) {
|
|
1394
|
+
var attachments = _ref19.attachments,
|
|
1395
|
+
mentioned_users = _ref19.mentioned_users,
|
|
1396
|
+
parent_id = _ref19.parent_id,
|
|
1397
|
+
text = _ref19.text,
|
|
1398
|
+
extraFields = (0, _objectWithoutProperties2["default"])(_ref19, _excluded);
|
|
1359
1399
|
var _client$user2 = client.user,
|
|
1360
1400
|
channel_mutes = _client$user2.channel_mutes,
|
|
1361
1401
|
devices = _client$user2.devices,
|
|
@@ -1390,28 +1430,28 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1390
1430
|
return preview;
|
|
1391
1431
|
};
|
|
1392
1432
|
var uploadPendingAttachments = function () {
|
|
1393
|
-
var
|
|
1433
|
+
var _ref20 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee15(message) {
|
|
1394
1434
|
var _updatedMessage$attac;
|
|
1395
1435
|
var updatedMessage, i, _updatedMessage$attac2, attachment, image, file, _image$name, filename, controller, compressedUri, contentType, uploadResponse, _controller, response;
|
|
1396
|
-
return _regenerator["default"].wrap(function
|
|
1397
|
-
while (1) switch (
|
|
1436
|
+
return _regenerator["default"].wrap(function _callee15$(_context15) {
|
|
1437
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1398
1438
|
case 0:
|
|
1399
1439
|
updatedMessage = (0, _extends2["default"])({}, message);
|
|
1400
1440
|
if (!((_updatedMessage$attac = updatedMessage.attachments) != null && _updatedMessage$attac.length)) {
|
|
1401
|
-
|
|
1441
|
+
_context15.next = 48;
|
|
1402
1442
|
break;
|
|
1403
1443
|
}
|
|
1404
1444
|
i = 0;
|
|
1405
1445
|
case 3:
|
|
1406
1446
|
if (!(i < ((_updatedMessage$attac2 = updatedMessage.attachments) == null ? void 0 : _updatedMessage$attac2.length))) {
|
|
1407
|
-
|
|
1447
|
+
_context15.next = 48;
|
|
1408
1448
|
break;
|
|
1409
1449
|
}
|
|
1410
1450
|
attachment = updatedMessage.attachments[i];
|
|
1411
1451
|
image = attachment.originalImage;
|
|
1412
1452
|
file = attachment.originalFile;
|
|
1413
1453
|
if (!(attachment.type === 'image' && image != null && image.uri && attachment.image_url && (0, _utils.isLocalUrl)(attachment.image_url))) {
|
|
1414
|
-
|
|
1454
|
+
_context15.next = 28;
|
|
1415
1455
|
break;
|
|
1416
1456
|
}
|
|
1417
1457
|
filename = (_image$name = image.name) != null ? _image$name : image.uri.replace(/^(file:\/\/|content:\/\/)/, '');
|
|
@@ -1420,28 +1460,28 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1420
1460
|
controller.abort();
|
|
1421
1461
|
uploadAbortControllerRef.current["delete"](filename);
|
|
1422
1462
|
}
|
|
1423
|
-
|
|
1463
|
+
_context15.next = 13;
|
|
1424
1464
|
return (0, _compressImage.compressedImageURI)(image, compressImageQuality);
|
|
1425
1465
|
case 13:
|
|
1426
|
-
compressedUri =
|
|
1466
|
+
compressedUri = _context15.sent;
|
|
1427
1467
|
contentType = (0, _mimeTypes.lookup)(filename) || 'multipart/form-data';
|
|
1428
1468
|
if (!doImageUploadRequest) {
|
|
1429
|
-
|
|
1469
|
+
_context15.next = 21;
|
|
1430
1470
|
break;
|
|
1431
1471
|
}
|
|
1432
|
-
|
|
1472
|
+
_context15.next = 18;
|
|
1433
1473
|
return doImageUploadRequest(image, channel);
|
|
1434
1474
|
case 18:
|
|
1435
|
-
|
|
1436
|
-
|
|
1475
|
+
_context15.t0 = _context15.sent;
|
|
1476
|
+
_context15.next = 24;
|
|
1437
1477
|
break;
|
|
1438
1478
|
case 21:
|
|
1439
|
-
|
|
1479
|
+
_context15.next = 23;
|
|
1440
1480
|
return channel.sendImage(compressedUri, filename, contentType);
|
|
1441
1481
|
case 23:
|
|
1442
|
-
|
|
1482
|
+
_context15.t0 = _context15.sent;
|
|
1443
1483
|
case 24:
|
|
1444
|
-
uploadResponse =
|
|
1484
|
+
uploadResponse = _context15.t0;
|
|
1445
1485
|
attachment.image_url = uploadResponse.file;
|
|
1446
1486
|
delete attachment.originalFile;
|
|
1447
1487
|
dbApi.updateMessage({
|
|
@@ -1451,7 +1491,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1451
1491
|
});
|
|
1452
1492
|
case 28:
|
|
1453
1493
|
if (!((attachment.type === 'file' || attachment.type === 'audio' || attachment.type === 'video') && attachment.asset_url && (0, _utils.isLocalUrl)(attachment.asset_url) && file != null && file.uri)) {
|
|
1454
|
-
|
|
1494
|
+
_context15.next = 45;
|
|
1455
1495
|
break;
|
|
1456
1496
|
}
|
|
1457
1497
|
_controller = uploadAbortControllerRef.current.get(file.name);
|
|
@@ -1460,22 +1500,22 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1460
1500
|
uploadAbortControllerRef.current["delete"](file.name);
|
|
1461
1501
|
}
|
|
1462
1502
|
if (!doDocUploadRequest) {
|
|
1463
|
-
|
|
1503
|
+
_context15.next = 37;
|
|
1464
1504
|
break;
|
|
1465
1505
|
}
|
|
1466
|
-
|
|
1506
|
+
_context15.next = 34;
|
|
1467
1507
|
return doDocUploadRequest(file, channel);
|
|
1468
1508
|
case 34:
|
|
1469
|
-
|
|
1470
|
-
|
|
1509
|
+
_context15.t1 = _context15.sent;
|
|
1510
|
+
_context15.next = 40;
|
|
1471
1511
|
break;
|
|
1472
1512
|
case 37:
|
|
1473
|
-
|
|
1513
|
+
_context15.next = 39;
|
|
1474
1514
|
return channel.sendFile(file.uri, file.name, file.mimeType);
|
|
1475
1515
|
case 39:
|
|
1476
|
-
|
|
1516
|
+
_context15.t1 = _context15.sent;
|
|
1477
1517
|
case 40:
|
|
1478
|
-
response =
|
|
1518
|
+
response = _context15.t1;
|
|
1479
1519
|
attachment.asset_url = response.file;
|
|
1480
1520
|
if (response.thumb_url) {
|
|
1481
1521
|
attachment.thumb_url = response.thumb_url;
|
|
@@ -1488,37 +1528,37 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1488
1528
|
});
|
|
1489
1529
|
case 45:
|
|
1490
1530
|
i++;
|
|
1491
|
-
|
|
1531
|
+
_context15.next = 3;
|
|
1492
1532
|
break;
|
|
1493
1533
|
case 48:
|
|
1494
|
-
return
|
|
1534
|
+
return _context15.abrupt("return", updatedMessage);
|
|
1495
1535
|
case 49:
|
|
1496
1536
|
case "end":
|
|
1497
|
-
return
|
|
1537
|
+
return _context15.stop();
|
|
1498
1538
|
}
|
|
1499
|
-
},
|
|
1539
|
+
}, _callee15);
|
|
1500
1540
|
}));
|
|
1501
|
-
return function uploadPendingAttachments(
|
|
1502
|
-
return
|
|
1541
|
+
return function uploadPendingAttachments(_x6) {
|
|
1542
|
+
return _ref20.apply(this, arguments);
|
|
1503
1543
|
};
|
|
1504
1544
|
}();
|
|
1505
1545
|
var sendMessageRequest = function () {
|
|
1506
|
-
var
|
|
1546
|
+
var _ref21 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee16(message, retrying) {
|
|
1507
1547
|
var _updatedMessage, __html, attachments, created_at, deleted_at, html, id, latest_reactions, mentioned_users, own_reactions, parent_id, quoted_message, reaction_counts, reactions, status, text, type, updated_at, user, extraFields, mentionedUserIds, _messageData, messageResponse;
|
|
1508
|
-
return _regenerator["default"].wrap(function
|
|
1509
|
-
while (1) switch (
|
|
1548
|
+
return _regenerator["default"].wrap(function _callee16$(_context16) {
|
|
1549
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1510
1550
|
case 0:
|
|
1511
|
-
|
|
1512
|
-
|
|
1551
|
+
_context16.prev = 0;
|
|
1552
|
+
_context16.next = 3;
|
|
1513
1553
|
return uploadPendingAttachments(message);
|
|
1514
1554
|
case 3:
|
|
1515
|
-
_updatedMessage =
|
|
1555
|
+
_updatedMessage = _context16.sent;
|
|
1516
1556
|
__html = _updatedMessage.__html, attachments = _updatedMessage.attachments, created_at = _updatedMessage.created_at, deleted_at = _updatedMessage.deleted_at, html = _updatedMessage.html, id = _updatedMessage.id, latest_reactions = _updatedMessage.latest_reactions, mentioned_users = _updatedMessage.mentioned_users, own_reactions = _updatedMessage.own_reactions, parent_id = _updatedMessage.parent_id, quoted_message = _updatedMessage.quoted_message, reaction_counts = _updatedMessage.reaction_counts, reactions = _updatedMessage.reactions, status = _updatedMessage.status, text = _updatedMessage.text, type = _updatedMessage.type, updated_at = _updatedMessage.updated_at, user = _updatedMessage.user, extraFields = (0, _objectWithoutProperties2["default"])(_updatedMessage, _excluded3);
|
|
1517
1557
|
if (channel.id) {
|
|
1518
|
-
|
|
1558
|
+
_context16.next = 7;
|
|
1519
1559
|
break;
|
|
1520
1560
|
}
|
|
1521
|
-
return
|
|
1561
|
+
return _context16.abrupt("return");
|
|
1522
1562
|
case 7:
|
|
1523
1563
|
mentionedUserIds = (mentioned_users == null ? void 0 : mentioned_users.map(function (user) {
|
|
1524
1564
|
return user.id;
|
|
@@ -1532,24 +1572,24 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1532
1572
|
}, extraFields);
|
|
1533
1573
|
messageResponse = {};
|
|
1534
1574
|
if (!doSendMessageRequest) {
|
|
1535
|
-
|
|
1575
|
+
_context16.next = 16;
|
|
1536
1576
|
break;
|
|
1537
1577
|
}
|
|
1538
|
-
|
|
1578
|
+
_context16.next = 13;
|
|
1539
1579
|
return doSendMessageRequest((channel == null ? void 0 : channel.cid) || '', _messageData);
|
|
1540
1580
|
case 13:
|
|
1541
|
-
messageResponse =
|
|
1542
|
-
|
|
1581
|
+
messageResponse = _context16.sent;
|
|
1582
|
+
_context16.next = 20;
|
|
1543
1583
|
break;
|
|
1544
1584
|
case 16:
|
|
1545
1585
|
if (!channel) {
|
|
1546
|
-
|
|
1586
|
+
_context16.next = 20;
|
|
1547
1587
|
break;
|
|
1548
1588
|
}
|
|
1549
|
-
|
|
1589
|
+
_context16.next = 19;
|
|
1550
1590
|
return channel.sendMessage(_messageData);
|
|
1551
1591
|
case 19:
|
|
1552
|
-
messageResponse =
|
|
1592
|
+
messageResponse = _context16.sent;
|
|
1553
1593
|
case 20:
|
|
1554
1594
|
if (messageResponse.message) {
|
|
1555
1595
|
messageResponse.message.status = _utils.MessageStatusTypes.RECEIVED;
|
|
@@ -1566,12 +1606,12 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1566
1606
|
updateMessage(messageResponse.message);
|
|
1567
1607
|
}
|
|
1568
1608
|
}
|
|
1569
|
-
|
|
1609
|
+
_context16.next = 29;
|
|
1570
1610
|
break;
|
|
1571
1611
|
case 23:
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
console.log(
|
|
1612
|
+
_context16.prev = 23;
|
|
1613
|
+
_context16.t0 = _context16["catch"](0);
|
|
1614
|
+
console.log(_context16.t0);
|
|
1575
1615
|
message.status = _utils.MessageStatusTypes.FAILED;
|
|
1576
1616
|
updateMessage((0, _extends2["default"])({}, message, {
|
|
1577
1617
|
cid: channel.cid
|
|
@@ -1585,20 +1625,20 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1585
1625
|
}
|
|
1586
1626
|
case 29:
|
|
1587
1627
|
case "end":
|
|
1588
|
-
return
|
|
1628
|
+
return _context16.stop();
|
|
1589
1629
|
}
|
|
1590
|
-
},
|
|
1630
|
+
}, _callee16, null, [[0, 23]]);
|
|
1591
1631
|
}));
|
|
1592
|
-
return function sendMessageRequest(
|
|
1593
|
-
return
|
|
1632
|
+
return function sendMessageRequest(_x7, _x8) {
|
|
1633
|
+
return _ref21.apply(this, arguments);
|
|
1594
1634
|
};
|
|
1595
1635
|
}();
|
|
1596
1636
|
var sendMessage = function () {
|
|
1597
|
-
var
|
|
1637
|
+
var _ref22 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee17(message) {
|
|
1598
1638
|
var _channel$state;
|
|
1599
1639
|
var messagePreview;
|
|
1600
|
-
return _regenerator["default"].wrap(function
|
|
1601
|
-
while (1) switch (
|
|
1640
|
+
return _regenerator["default"].wrap(function _callee17$(_context17) {
|
|
1641
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1602
1642
|
case 0:
|
|
1603
1643
|
if (channel != null && (_channel$state = channel.state) != null && _channel$state.filterErrorMessages) {
|
|
1604
1644
|
channel.state.filterErrorMessages();
|
|
@@ -1608,10 +1648,10 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1608
1648
|
}));
|
|
1609
1649
|
mergeOverlappingMessageSetsRef.current();
|
|
1610
1650
|
if (channel != null && channel.state.isUpToDate) {
|
|
1611
|
-
|
|
1651
|
+
_context17.next = 6;
|
|
1612
1652
|
break;
|
|
1613
1653
|
}
|
|
1614
|
-
|
|
1654
|
+
_context17.next = 6;
|
|
1615
1655
|
return reloadChannel();
|
|
1616
1656
|
case 6:
|
|
1617
1657
|
updateMessage(messagePreview, {
|
|
@@ -1626,23 +1666,23 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1626
1666
|
})]
|
|
1627
1667
|
});
|
|
1628
1668
|
}
|
|
1629
|
-
|
|
1669
|
+
_context17.next = 10;
|
|
1630
1670
|
return sendMessageRequest(messagePreview);
|
|
1631
1671
|
case 10:
|
|
1632
1672
|
case "end":
|
|
1633
|
-
return
|
|
1673
|
+
return _context17.stop();
|
|
1634
1674
|
}
|
|
1635
|
-
},
|
|
1675
|
+
}, _callee17);
|
|
1636
1676
|
}));
|
|
1637
|
-
return function sendMessage(
|
|
1638
|
-
return
|
|
1677
|
+
return function sendMessage(_x9) {
|
|
1678
|
+
return _ref22.apply(this, arguments);
|
|
1639
1679
|
};
|
|
1640
1680
|
}();
|
|
1641
1681
|
var retrySendMessage = function () {
|
|
1642
|
-
var
|
|
1682
|
+
var _ref23 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee18(message) {
|
|
1643
1683
|
var statusPendingMessage, messageWithoutReservedFields;
|
|
1644
|
-
return _regenerator["default"].wrap(function
|
|
1645
|
-
while (1) switch (
|
|
1684
|
+
return _regenerator["default"].wrap(function _callee18$(_context18) {
|
|
1685
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1646
1686
|
case 0:
|
|
1647
1687
|
statusPendingMessage = (0, _extends2["default"])({}, message, {
|
|
1648
1688
|
status: _utils.MessageStatusTypes.SENDING
|
|
@@ -1651,16 +1691,16 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1651
1691
|
if (!(0, _utils.isBouncedMessage)(message)) {
|
|
1652
1692
|
updateMessage(messageWithoutReservedFields);
|
|
1653
1693
|
}
|
|
1654
|
-
|
|
1694
|
+
_context18.next = 5;
|
|
1655
1695
|
return sendMessageRequest(messageWithoutReservedFields, true);
|
|
1656
1696
|
case 5:
|
|
1657
1697
|
case "end":
|
|
1658
|
-
return
|
|
1698
|
+
return _context18.stop();
|
|
1659
1699
|
}
|
|
1660
|
-
},
|
|
1700
|
+
}, _callee18);
|
|
1661
1701
|
}));
|
|
1662
|
-
return function retrySendMessage(
|
|
1663
|
-
return
|
|
1702
|
+
return function retrySendMessage(_x10) {
|
|
1703
|
+
return _ref23.apply(this, arguments);
|
|
1664
1704
|
};
|
|
1665
1705
|
}();
|
|
1666
1706
|
var loadMoreFinished = (0, _react.useRef)((0, _debounce["default"])(function (updatedHasMore, newMessages) {
|
|
@@ -1670,46 +1710,46 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1670
1710
|
setHasMore(updatedHasMore);
|
|
1671
1711
|
setMessages(newMessages);
|
|
1672
1712
|
}, defaultDebounceInterval, debounceOptions)).current;
|
|
1673
|
-
var loadMore = (0, _react.useCallback)((0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function
|
|
1713
|
+
var loadMore = (0, _react.useCallback)((0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee19() {
|
|
1674
1714
|
var limit,
|
|
1675
1715
|
currentMessages,
|
|
1676
1716
|
oldestMessage,
|
|
1677
1717
|
oldestID,
|
|
1678
1718
|
queryResponse,
|
|
1679
1719
|
updatedHasMore,
|
|
1680
|
-
|
|
1681
|
-
return _regenerator["default"].wrap(function
|
|
1682
|
-
while (1) switch (
|
|
1720
|
+
_args19 = arguments;
|
|
1721
|
+
return _regenerator["default"].wrap(function _callee19$(_context19) {
|
|
1722
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1683
1723
|
case 0:
|
|
1684
|
-
limit =
|
|
1724
|
+
limit = _args19.length > 0 && _args19[0] !== undefined ? _args19[0] : 20;
|
|
1685
1725
|
if (!(loadingMore || hasMore === false)) {
|
|
1686
|
-
|
|
1726
|
+
_context19.next = 3;
|
|
1687
1727
|
break;
|
|
1688
1728
|
}
|
|
1689
|
-
return
|
|
1729
|
+
return _context19.abrupt("return");
|
|
1690
1730
|
case 3:
|
|
1691
1731
|
currentMessages = channel.state.messages;
|
|
1692
1732
|
if (currentMessages.length) {
|
|
1693
|
-
|
|
1733
|
+
_context19.next = 6;
|
|
1694
1734
|
break;
|
|
1695
1735
|
}
|
|
1696
|
-
return
|
|
1736
|
+
return _context19.abrupt("return", setLoadingMore(false));
|
|
1697
1737
|
case 6:
|
|
1698
1738
|
oldestMessage = currentMessages && currentMessages[0];
|
|
1699
1739
|
if (!(oldestMessage && oldestMessage.status !== _utils.MessageStatusTypes.RECEIVED)) {
|
|
1700
|
-
|
|
1740
|
+
_context19.next = 9;
|
|
1701
1741
|
break;
|
|
1702
1742
|
}
|
|
1703
|
-
return
|
|
1743
|
+
return _context19.abrupt("return", setLoadingMore(false));
|
|
1704
1744
|
case 9:
|
|
1705
1745
|
setLoadingMore(true);
|
|
1706
1746
|
oldestID = oldestMessage && oldestMessage.id;
|
|
1707
|
-
|
|
1747
|
+
_context19.prev = 11;
|
|
1708
1748
|
if (!channel) {
|
|
1709
|
-
|
|
1749
|
+
_context19.next = 18;
|
|
1710
1750
|
break;
|
|
1711
1751
|
}
|
|
1712
|
-
|
|
1752
|
+
_context19.next = 15;
|
|
1713
1753
|
return channel.query({
|
|
1714
1754
|
messages: {
|
|
1715
1755
|
id_lt: oldestID,
|
|
@@ -1717,29 +1757,29 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1717
1757
|
}
|
|
1718
1758
|
});
|
|
1719
1759
|
case 15:
|
|
1720
|
-
queryResponse =
|
|
1760
|
+
queryResponse = _context19.sent;
|
|
1721
1761
|
updatedHasMore = queryResponse.messages.length === limit;
|
|
1722
1762
|
loadMoreFinished(updatedHasMore, channel.state.messages);
|
|
1723
1763
|
case 18:
|
|
1724
|
-
|
|
1764
|
+
_context19.next = 25;
|
|
1725
1765
|
break;
|
|
1726
1766
|
case 20:
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
if (
|
|
1730
|
-
setError(
|
|
1767
|
+
_context19.prev = 20;
|
|
1768
|
+
_context19.t0 = _context19["catch"](11);
|
|
1769
|
+
if (_context19.t0 instanceof Error) {
|
|
1770
|
+
setError(_context19.t0);
|
|
1731
1771
|
} else {
|
|
1732
1772
|
setError(true);
|
|
1733
1773
|
}
|
|
1734
1774
|
setLoadingMore(false);
|
|
1735
|
-
throw
|
|
1775
|
+
throw _context19.t0;
|
|
1736
1776
|
case 25:
|
|
1737
1777
|
case "end":
|
|
1738
|
-
return
|
|
1778
|
+
return _context19.stop();
|
|
1739
1779
|
}
|
|
1740
|
-
},
|
|
1780
|
+
}, _callee19, null, [[11, 20]]);
|
|
1741
1781
|
})), [channelId, hasMore, loadingMore]);
|
|
1742
|
-
var loadMoreRecent = (0, _react.useCallback)((0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function
|
|
1782
|
+
var loadMoreRecent = (0, _react.useCallback)((0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee20() {
|
|
1743
1783
|
var limit,
|
|
1744
1784
|
latestMessageSet,
|
|
1745
1785
|
latestLengthBeforeMerge,
|
|
@@ -1749,22 +1789,22 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1749
1789
|
queryResponse,
|
|
1750
1790
|
gotAllRecentMessages,
|
|
1751
1791
|
currentSet,
|
|
1752
|
-
|
|
1753
|
-
return _regenerator["default"].wrap(function
|
|
1754
|
-
while (1) switch (
|
|
1792
|
+
_args20 = arguments;
|
|
1793
|
+
return _regenerator["default"].wrap(function _callee20$(_context20) {
|
|
1794
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1755
1795
|
case 0:
|
|
1756
|
-
limit =
|
|
1796
|
+
limit = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : 5;
|
|
1757
1797
|
latestMessageSet = channel.state.messageSets.find(function (set) {
|
|
1758
1798
|
return set.isLatest;
|
|
1759
1799
|
});
|
|
1760
1800
|
latestLengthBeforeMerge = (latestMessageSet == null ? void 0 : latestMessageSet.messages.length) || 0;
|
|
1761
1801
|
didMerge = mergeOverlappingMessageSetsRef.current(true);
|
|
1762
1802
|
if (!didMerge) {
|
|
1763
|
-
|
|
1803
|
+
_context20.next = 12;
|
|
1764
1804
|
break;
|
|
1765
1805
|
}
|
|
1766
1806
|
if (!(latestMessageSet && latestLengthBeforeMerge >= limit)) {
|
|
1767
|
-
|
|
1807
|
+
_context20.next = 12;
|
|
1768
1808
|
break;
|
|
1769
1809
|
}
|
|
1770
1810
|
setLoadingMoreRecent(true);
|
|
@@ -1772,31 +1812,31 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1772
1812
|
setHasNoMoreRecentMessagesToLoad(true);
|
|
1773
1813
|
loadMoreRecentFinished(channel.state.messages);
|
|
1774
1814
|
restartSetsMergeFuncRef.current();
|
|
1775
|
-
return
|
|
1815
|
+
return _context20.abrupt("return");
|
|
1776
1816
|
case 12:
|
|
1777
1817
|
if (!channel.state.isUpToDate) {
|
|
1778
|
-
|
|
1818
|
+
_context20.next = 15;
|
|
1779
1819
|
break;
|
|
1780
1820
|
}
|
|
1781
1821
|
setLoadingMoreRecent(false);
|
|
1782
|
-
return
|
|
1822
|
+
return _context20.abrupt("return");
|
|
1783
1823
|
case 15:
|
|
1784
1824
|
currentMessages = channel.state.messages;
|
|
1785
1825
|
recentMessage = currentMessages[currentMessages.length - 1];
|
|
1786
1826
|
if (!((recentMessage == null ? void 0 : recentMessage.status) !== _utils.MessageStatusTypes.RECEIVED)) {
|
|
1787
|
-
|
|
1827
|
+
_context20.next = 20;
|
|
1788
1828
|
break;
|
|
1789
1829
|
}
|
|
1790
1830
|
setLoadingMoreRecent(false);
|
|
1791
|
-
return
|
|
1831
|
+
return _context20.abrupt("return");
|
|
1792
1832
|
case 20:
|
|
1793
1833
|
setLoadingMoreRecent(true);
|
|
1794
|
-
|
|
1834
|
+
_context20.prev = 21;
|
|
1795
1835
|
if (!channel) {
|
|
1796
|
-
|
|
1836
|
+
_context20.next = 32;
|
|
1797
1837
|
break;
|
|
1798
1838
|
}
|
|
1799
|
-
|
|
1839
|
+
_context20.next = 25;
|
|
1800
1840
|
return channel.query({
|
|
1801
1841
|
messages: {
|
|
1802
1842
|
id_gte: recentMessage.id,
|
|
@@ -1805,7 +1845,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1805
1845
|
watch: true
|
|
1806
1846
|
});
|
|
1807
1847
|
case 25:
|
|
1808
|
-
queryResponse =
|
|
1848
|
+
queryResponse = _context20.sent;
|
|
1809
1849
|
gotAllRecentMessages = queryResponse.messages.length < limit;
|
|
1810
1850
|
currentSet = channel.state.messageSets.find(function (set) {
|
|
1811
1851
|
return set.isCurrent;
|
|
@@ -1820,24 +1860,24 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1820
1860
|
setHasNoMoreRecentMessagesToLoad(gotAllRecentMessages);
|
|
1821
1861
|
loadMoreRecentFinished(channel.state.messages);
|
|
1822
1862
|
case 32:
|
|
1823
|
-
|
|
1863
|
+
_context20.next = 40;
|
|
1824
1864
|
break;
|
|
1825
1865
|
case 34:
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
console.warn('Message pagination request failed with error',
|
|
1829
|
-
if (
|
|
1830
|
-
setError(
|
|
1866
|
+
_context20.prev = 34;
|
|
1867
|
+
_context20.t0 = _context20["catch"](21);
|
|
1868
|
+
console.warn('Message pagination request failed with error', _context20.t0);
|
|
1869
|
+
if (_context20.t0 instanceof Error) {
|
|
1870
|
+
setError(_context20.t0);
|
|
1831
1871
|
} else {
|
|
1832
1872
|
setError(true);
|
|
1833
1873
|
}
|
|
1834
1874
|
setLoadingMoreRecent(false);
|
|
1835
|
-
throw
|
|
1875
|
+
throw _context20.t0;
|
|
1836
1876
|
case 40:
|
|
1837
1877
|
case "end":
|
|
1838
|
-
return
|
|
1878
|
+
return _context20.stop();
|
|
1839
1879
|
}
|
|
1840
|
-
},
|
|
1880
|
+
}, _callee20, null, [[21, 34]]);
|
|
1841
1881
|
})), [channelId, hasNoMoreRecentMessagesToLoad]);
|
|
1842
1882
|
var loadMoreRecentFinished = (0, _react.useRef)((0, _debounce["default"])(function (newMessages) {
|
|
1843
1883
|
setLoadingMoreRecent(false);
|
|
@@ -1875,13 +1915,13 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1875
1915
|
}
|
|
1876
1916
|
};
|
|
1877
1917
|
var sendReaction = function () {
|
|
1878
|
-
var
|
|
1918
|
+
var _ref26 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee21(type, messageId) {
|
|
1879
1919
|
var payload;
|
|
1880
|
-
return _regenerator["default"].wrap(function
|
|
1881
|
-
while (1) switch (
|
|
1920
|
+
return _regenerator["default"].wrap(function _callee21$(_context21) {
|
|
1921
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1882
1922
|
case 0:
|
|
1883
1923
|
if (!(!(channel != null && channel.id) || !client.user)) {
|
|
1884
|
-
|
|
1924
|
+
_context21.next = 2;
|
|
1885
1925
|
break;
|
|
1886
1926
|
}
|
|
1887
1927
|
throw new Error('Channel has not been initialized');
|
|
@@ -1892,13 +1932,13 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1892
1932
|
enforce_unique: enforceUniqueReaction
|
|
1893
1933
|
}];
|
|
1894
1934
|
if (enableOfflineSupport) {
|
|
1895
|
-
|
|
1935
|
+
_context21.next = 7;
|
|
1896
1936
|
break;
|
|
1897
1937
|
}
|
|
1898
|
-
|
|
1938
|
+
_context21.next = 6;
|
|
1899
1939
|
return channel.sendReaction.apply(channel, payload);
|
|
1900
1940
|
case 6:
|
|
1901
|
-
return
|
|
1941
|
+
return _context21.abrupt("return");
|
|
1902
1942
|
case 7:
|
|
1903
1943
|
(0, _addReactionToLocalState.addReactionToLocalState)({
|
|
1904
1944
|
channel: channel,
|
|
@@ -1908,7 +1948,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1908
1948
|
user: client.user
|
|
1909
1949
|
});
|
|
1910
1950
|
setMessages(channel.state.messages);
|
|
1911
|
-
|
|
1951
|
+
_context21.next = 11;
|
|
1912
1952
|
return _DBSyncManager.DBSyncManager.queueTask({
|
|
1913
1953
|
client: client,
|
|
1914
1954
|
task: {
|
|
@@ -1921,51 +1961,51 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1921
1961
|
});
|
|
1922
1962
|
case 11:
|
|
1923
1963
|
case "end":
|
|
1924
|
-
return
|
|
1964
|
+
return _context21.stop();
|
|
1925
1965
|
}
|
|
1926
|
-
},
|
|
1966
|
+
}, _callee21);
|
|
1927
1967
|
}));
|
|
1928
|
-
return function sendReaction(
|
|
1929
|
-
return
|
|
1968
|
+
return function sendReaction(_x11, _x12) {
|
|
1969
|
+
return _ref26.apply(this, arguments);
|
|
1930
1970
|
};
|
|
1931
1971
|
}();
|
|
1932
1972
|
var deleteMessage = function () {
|
|
1933
|
-
var
|
|
1973
|
+
var _ref27 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee22(message) {
|
|
1934
1974
|
var _data;
|
|
1935
|
-
return _regenerator["default"].wrap(function
|
|
1936
|
-
while (1) switch (
|
|
1975
|
+
return _regenerator["default"].wrap(function _callee22$(_context22) {
|
|
1976
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1937
1977
|
case 0:
|
|
1938
1978
|
if (channel.id) {
|
|
1939
|
-
|
|
1979
|
+
_context22.next = 2;
|
|
1940
1980
|
break;
|
|
1941
1981
|
}
|
|
1942
1982
|
throw new Error('Channel has not been initialized yet');
|
|
1943
1983
|
case 2:
|
|
1944
1984
|
if (enableOfflineSupport) {
|
|
1945
|
-
|
|
1985
|
+
_context22.next = 9;
|
|
1946
1986
|
break;
|
|
1947
1987
|
}
|
|
1948
1988
|
if (!(message.status === _utils.MessageStatusTypes.FAILED)) {
|
|
1949
|
-
|
|
1989
|
+
_context22.next = 6;
|
|
1950
1990
|
break;
|
|
1951
1991
|
}
|
|
1952
1992
|
removeMessage(message);
|
|
1953
|
-
return
|
|
1993
|
+
return _context22.abrupt("return");
|
|
1954
1994
|
case 6:
|
|
1955
|
-
|
|
1995
|
+
_context22.next = 8;
|
|
1956
1996
|
return client.deleteMessage(message.id);
|
|
1957
1997
|
case 8:
|
|
1958
|
-
return
|
|
1998
|
+
return _context22.abrupt("return");
|
|
1959
1999
|
case 9:
|
|
1960
2000
|
if (!(message.status === _utils.MessageStatusTypes.FAILED)) {
|
|
1961
|
-
|
|
2001
|
+
_context22.next = 14;
|
|
1962
2002
|
break;
|
|
1963
2003
|
}
|
|
1964
2004
|
_DBSyncManager.DBSyncManager.dropPendingTasks({
|
|
1965
2005
|
messageId: message.id
|
|
1966
2006
|
});
|
|
1967
2007
|
removeMessage(message);
|
|
1968
|
-
|
|
2008
|
+
_context22.next = 19;
|
|
1969
2009
|
break;
|
|
1970
2010
|
case 14:
|
|
1971
2011
|
updateMessage((0, _extends2["default"])({}, message, {
|
|
@@ -1973,7 +2013,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1973
2013
|
deleted_at: new Date().toISOString(),
|
|
1974
2014
|
type: 'deleted'
|
|
1975
2015
|
}));
|
|
1976
|
-
|
|
2016
|
+
_context22.next = 17;
|
|
1977
2017
|
return _DBSyncManager.DBSyncManager.queueTask({
|
|
1978
2018
|
client: client,
|
|
1979
2019
|
task: {
|
|
@@ -1985,41 +2025,41 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
1985
2025
|
}
|
|
1986
2026
|
});
|
|
1987
2027
|
case 17:
|
|
1988
|
-
_data =
|
|
2028
|
+
_data = _context22.sent;
|
|
1989
2029
|
if (_data != null && _data.message) {
|
|
1990
2030
|
updateMessage((0, _extends2["default"])({}, _data.message));
|
|
1991
2031
|
}
|
|
1992
2032
|
case 19:
|
|
1993
2033
|
case "end":
|
|
1994
|
-
return
|
|
2034
|
+
return _context22.stop();
|
|
1995
2035
|
}
|
|
1996
|
-
},
|
|
2036
|
+
}, _callee22);
|
|
1997
2037
|
}));
|
|
1998
|
-
return function deleteMessage(
|
|
1999
|
-
return
|
|
2038
|
+
return function deleteMessage(_x13) {
|
|
2039
|
+
return _ref27.apply(this, arguments);
|
|
2000
2040
|
};
|
|
2001
2041
|
}();
|
|
2002
2042
|
var deleteReaction = function () {
|
|
2003
|
-
var
|
|
2043
|
+
var _ref28 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee23(type, messageId) {
|
|
2004
2044
|
var payload;
|
|
2005
|
-
return _regenerator["default"].wrap(function
|
|
2006
|
-
while (1) switch (
|
|
2045
|
+
return _regenerator["default"].wrap(function _callee23$(_context23) {
|
|
2046
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
2007
2047
|
case 0:
|
|
2008
2048
|
if (!(!(channel != null && channel.id) || !client.user)) {
|
|
2009
|
-
|
|
2049
|
+
_context23.next = 2;
|
|
2010
2050
|
break;
|
|
2011
2051
|
}
|
|
2012
2052
|
throw new Error('Channel has not been initialized');
|
|
2013
2053
|
case 2:
|
|
2014
2054
|
payload = [messageId, type];
|
|
2015
2055
|
if (enableOfflineSupport) {
|
|
2016
|
-
|
|
2056
|
+
_context23.next = 7;
|
|
2017
2057
|
break;
|
|
2018
2058
|
}
|
|
2019
|
-
|
|
2059
|
+
_context23.next = 6;
|
|
2020
2060
|
return channel.deleteReaction.apply(channel, payload);
|
|
2021
2061
|
case 6:
|
|
2022
|
-
return
|
|
2062
|
+
return _context23.abrupt("return");
|
|
2023
2063
|
case 7:
|
|
2024
2064
|
(0, _removeReactionFromLocalState.removeReactionFromLocalState)({
|
|
2025
2065
|
channel: channel,
|
|
@@ -2028,7 +2068,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
2028
2068
|
user: client.user
|
|
2029
2069
|
});
|
|
2030
2070
|
setMessages(channel.state.messages);
|
|
2031
|
-
|
|
2071
|
+
_context23.next = 11;
|
|
2032
2072
|
return _DBSyncManager.DBSyncManager.queueTask({
|
|
2033
2073
|
client: client,
|
|
2034
2074
|
task: {
|
|
@@ -2041,12 +2081,12 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
2041
2081
|
});
|
|
2042
2082
|
case 11:
|
|
2043
2083
|
case "end":
|
|
2044
|
-
return
|
|
2084
|
+
return _context23.stop();
|
|
2045
2085
|
}
|
|
2046
|
-
},
|
|
2086
|
+
}, _callee23);
|
|
2047
2087
|
}));
|
|
2048
|
-
return function deleteReaction(
|
|
2049
|
-
return
|
|
2088
|
+
return function deleteReaction(_x14, _x15) {
|
|
2089
|
+
return _ref28.apply(this, arguments);
|
|
2050
2090
|
};
|
|
2051
2091
|
}();
|
|
2052
2092
|
var openThread = (0, _react.useCallback)(function (message) {
|
|
@@ -2065,59 +2105,59 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
2065
2105
|
setThreadMessages(updatedThreadMessages);
|
|
2066
2106
|
}, defaultDebounceInterval, debounceOptions)).current;
|
|
2067
2107
|
var loadMoreThread = function () {
|
|
2068
|
-
var
|
|
2108
|
+
var _ref29 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee24() {
|
|
2069
2109
|
var _threadMessages$, parentID, oldestMessageID, limit, queryResponse, updatedHasMore, updatedThreadMessages;
|
|
2070
|
-
return _regenerator["default"].wrap(function
|
|
2071
|
-
while (1) switch (
|
|
2110
|
+
return _regenerator["default"].wrap(function _callee24$(_context24) {
|
|
2111
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
2072
2112
|
case 0:
|
|
2073
2113
|
if (!(threadLoadingMore || !(thread != null && thread.id))) {
|
|
2074
|
-
|
|
2114
|
+
_context24.next = 2;
|
|
2075
2115
|
break;
|
|
2076
2116
|
}
|
|
2077
|
-
return
|
|
2117
|
+
return _context24.abrupt("return");
|
|
2078
2118
|
case 2:
|
|
2079
2119
|
setThreadLoadingMore(true);
|
|
2080
|
-
|
|
2120
|
+
_context24.prev = 3;
|
|
2081
2121
|
if (!channel) {
|
|
2082
|
-
|
|
2122
|
+
_context24.next = 15;
|
|
2083
2123
|
break;
|
|
2084
2124
|
}
|
|
2085
2125
|
parentID = thread.id;
|
|
2086
2126
|
channel.state.threads[parentID] = threadMessages;
|
|
2087
2127
|
oldestMessageID = threadMessages == null ? void 0 : (_threadMessages$ = threadMessages[0]) == null ? void 0 : _threadMessages$.id;
|
|
2088
2128
|
limit = 50;
|
|
2089
|
-
|
|
2129
|
+
_context24.next = 11;
|
|
2090
2130
|
return channel.getReplies(parentID, {
|
|
2091
2131
|
id_lt: oldestMessageID,
|
|
2092
2132
|
limit: limit
|
|
2093
2133
|
});
|
|
2094
2134
|
case 11:
|
|
2095
|
-
queryResponse =
|
|
2135
|
+
queryResponse = _context24.sent;
|
|
2096
2136
|
updatedHasMore = queryResponse.messages.length === limit;
|
|
2097
2137
|
updatedThreadMessages = channel.state.threads[parentID] || [];
|
|
2098
2138
|
loadMoreThreadFinished(updatedHasMore, updatedThreadMessages);
|
|
2099
2139
|
case 15:
|
|
2100
|
-
|
|
2140
|
+
_context24.next = 23;
|
|
2101
2141
|
break;
|
|
2102
2142
|
case 17:
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
console.warn('Message pagination request failed with error',
|
|
2106
|
-
if (
|
|
2107
|
-
setError(
|
|
2143
|
+
_context24.prev = 17;
|
|
2144
|
+
_context24.t0 = _context24["catch"](3);
|
|
2145
|
+
console.warn('Message pagination request failed with error', _context24.t0);
|
|
2146
|
+
if (_context24.t0 instanceof Error) {
|
|
2147
|
+
setError(_context24.t0);
|
|
2108
2148
|
} else {
|
|
2109
2149
|
setError(true);
|
|
2110
2150
|
}
|
|
2111
2151
|
setThreadLoadingMore(false);
|
|
2112
|
-
throw
|
|
2152
|
+
throw _context24.t0;
|
|
2113
2153
|
case 23:
|
|
2114
2154
|
case "end":
|
|
2115
|
-
return
|
|
2155
|
+
return _context24.stop();
|
|
2116
2156
|
}
|
|
2117
|
-
},
|
|
2157
|
+
}, _callee24, null, [[3, 17]]);
|
|
2118
2158
|
}));
|
|
2119
2159
|
return function loadMoreThread() {
|
|
2120
|
-
return
|
|
2160
|
+
return _ref29.apply(this, arguments);
|
|
2121
2161
|
};
|
|
2122
2162
|
}();
|
|
2123
2163
|
var disabledValue = (0, _react.useMemo)(function () {
|
|
@@ -2135,7 +2175,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
2135
2175
|
enableMessageGroupingByUser: enableMessageGroupingByUser,
|
|
2136
2176
|
enforceUniqueReaction: enforceUniqueReaction,
|
|
2137
2177
|
error: error,
|
|
2138
|
-
giphyEnabled: giphyEnabled != null ? giphyEnabled : !!((
|
|
2178
|
+
giphyEnabled: giphyEnabled != null ? giphyEnabled : !!((_ref30 = (clientChannelConfig == null ? void 0 : clientChannelConfig.commands) || []) != null && _ref30.some(function (command) {
|
|
2139
2179
|
return command.name === 'giphy';
|
|
2140
2180
|
})),
|
|
2141
2181
|
hideDateSeparators: hideDateSeparators,
|
|
@@ -2193,7 +2233,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
2193
2233
|
InputEditingStateHeader: InputEditingStateHeader,
|
|
2194
2234
|
InputGiphySearch: InputGiphySearch,
|
|
2195
2235
|
InputReplyStateHeader: InputReplyStateHeader,
|
|
2196
|
-
maxMessageLength: (
|
|
2236
|
+
maxMessageLength: (_ref31 = maxMessageLengthProp != null ? maxMessageLengthProp : clientChannelConfig == null ? void 0 : clientChannelConfig.max_message_length) != null ? _ref31 : undefined,
|
|
2197
2237
|
maxNumberOfFiles: maxNumberOfFiles,
|
|
2198
2238
|
mentionAllAppUsersEnabled: mentionAllAppUsersEnabled,
|
|
2199
2239
|
mentionAllAppUsersQuery: mentionAllAppUsersQuery,
|
|
@@ -2337,7 +2377,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
2337
2377
|
__self: _this,
|
|
2338
2378
|
__source: {
|
|
2339
2379
|
fileName: _jsxFileName,
|
|
2340
|
-
lineNumber:
|
|
2380
|
+
lineNumber: 2361,
|
|
2341
2381
|
columnNumber: 12
|
|
2342
2382
|
}
|
|
2343
2383
|
});
|
|
@@ -2351,7 +2391,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
2351
2391
|
__self: _this,
|
|
2352
2392
|
__source: {
|
|
2353
2393
|
fileName: _jsxFileName,
|
|
2354
|
-
lineNumber:
|
|
2394
|
+
lineNumber: 2366,
|
|
2355
2395
|
columnNumber: 7
|
|
2356
2396
|
}
|
|
2357
2397
|
}, t('Please select a channel first'));
|
|
@@ -2364,7 +2404,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
2364
2404
|
__self: _this,
|
|
2365
2405
|
__source: {
|
|
2366
2406
|
fileName: _jsxFileName,
|
|
2367
|
-
lineNumber:
|
|
2407
|
+
lineNumber: 2373,
|
|
2368
2408
|
columnNumber: 5
|
|
2369
2409
|
}
|
|
2370
2410
|
}), _react["default"].createElement(_ChannelContext.ChannelProvider, {
|
|
@@ -2372,7 +2412,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
2372
2412
|
__self: _this,
|
|
2373
2413
|
__source: {
|
|
2374
2414
|
fileName: _jsxFileName,
|
|
2375
|
-
lineNumber:
|
|
2415
|
+
lineNumber: 2379,
|
|
2376
2416
|
columnNumber: 7
|
|
2377
2417
|
}
|
|
2378
2418
|
}, _react["default"].createElement(_OwnCapabilitiesContext.OwnCapabilitiesProvider, {
|
|
@@ -2380,7 +2420,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
2380
2420
|
__self: _this,
|
|
2381
2421
|
__source: {
|
|
2382
2422
|
fileName: _jsxFileName,
|
|
2383
|
-
lineNumber:
|
|
2423
|
+
lineNumber: 2380,
|
|
2384
2424
|
columnNumber: 9
|
|
2385
2425
|
}
|
|
2386
2426
|
}, _react["default"].createElement(_TypingContext.TypingProvider, {
|
|
@@ -2388,7 +2428,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
2388
2428
|
__self: _this,
|
|
2389
2429
|
__source: {
|
|
2390
2430
|
fileName: _jsxFileName,
|
|
2391
|
-
lineNumber:
|
|
2431
|
+
lineNumber: 2381,
|
|
2392
2432
|
columnNumber: 11
|
|
2393
2433
|
}
|
|
2394
2434
|
}, _react["default"].createElement(_PaginatedMessageListContext.PaginatedMessageListProvider, {
|
|
@@ -2396,7 +2436,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
2396
2436
|
__self: _this,
|
|
2397
2437
|
__source: {
|
|
2398
2438
|
fileName: _jsxFileName,
|
|
2399
|
-
lineNumber:
|
|
2439
|
+
lineNumber: 2382,
|
|
2400
2440
|
columnNumber: 13
|
|
2401
2441
|
}
|
|
2402
2442
|
}, _react["default"].createElement(_MessagesContext.MessagesProvider, {
|
|
@@ -2404,7 +2444,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
2404
2444
|
__self: _this,
|
|
2405
2445
|
__source: {
|
|
2406
2446
|
fileName: _jsxFileName,
|
|
2407
|
-
lineNumber:
|
|
2447
|
+
lineNumber: 2383,
|
|
2408
2448
|
columnNumber: 15
|
|
2409
2449
|
}
|
|
2410
2450
|
}, _react["default"].createElement(_ThreadContext.ThreadProvider, {
|
|
@@ -2412,7 +2452,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
2412
2452
|
__self: _this,
|
|
2413
2453
|
__source: {
|
|
2414
2454
|
fileName: _jsxFileName,
|
|
2415
|
-
lineNumber:
|
|
2455
|
+
lineNumber: 2384,
|
|
2416
2456
|
columnNumber: 17
|
|
2417
2457
|
}
|
|
2418
2458
|
}, _react["default"].createElement(_SuggestionsContext.SuggestionsProvider, {
|
|
@@ -2420,7 +2460,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
2420
2460
|
__self: _this,
|
|
2421
2461
|
__source: {
|
|
2422
2462
|
fileName: _jsxFileName,
|
|
2423
|
-
lineNumber:
|
|
2463
|
+
lineNumber: 2385,
|
|
2424
2464
|
columnNumber: 19
|
|
2425
2465
|
}
|
|
2426
2466
|
}, _react["default"].createElement(_MessageInputContext.MessageInputProvider, {
|
|
@@ -2428,7 +2468,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
2428
2468
|
__self: _this,
|
|
2429
2469
|
__source: {
|
|
2430
2470
|
fileName: _jsxFileName,
|
|
2431
|
-
lineNumber:
|
|
2471
|
+
lineNumber: 2386,
|
|
2432
2472
|
columnNumber: 21
|
|
2433
2473
|
}
|
|
2434
2474
|
}, _react["default"].createElement(_reactNative.View, {
|
|
@@ -2438,7 +2478,7 @@ var ChannelWithContext = function ChannelWithContext(props) {
|
|
|
2438
2478
|
__self: _this,
|
|
2439
2479
|
__source: {
|
|
2440
2480
|
fileName: _jsxFileName,
|
|
2441
|
-
lineNumber:
|
|
2481
|
+
lineNumber: 2387,
|
|
2442
2482
|
columnNumber: 23
|
|
2443
2483
|
}
|
|
2444
2484
|
}, children))))))))));
|
|
@@ -2489,7 +2529,7 @@ var Channel = function Channel(props) {
|
|
|
2489
2529
|
__self: _this,
|
|
2490
2530
|
__source: {
|
|
2491
2531
|
fileName: _jsxFileName,
|
|
2492
|
-
lineNumber:
|
|
2532
|
+
lineNumber: 2444,
|
|
2493
2533
|
columnNumber: 5
|
|
2494
2534
|
}
|
|
2495
2535
|
}));
|