stream-chat-react-native-core
Version:
The official React Native and Expo components for Stream Chat, a service for building chat applications
54 lines • 1.6 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useCreateThreadContext = void 0;
var _hooks = require("../../../hooks");
var selector = nextValue => ({
isLoadingNext: nextValue.pagination.isLoadingNext,
isLoadingPrev: nextValue.pagination.isLoadingPrev,
latestReplies: nextValue.replies
});
var useCreateThreadContext = ({
allowThreadMessagesInChannel,
onAlsoSentToChannelHeaderPress,
closeThread,
loadMoreThread,
openThread,
reloadThread,
setThreadLoadingMore,
thread,
threadHasMore,
threadInstance,
threadLoadingMore,
threadMessages
}) => {
var _useStateStore;
var _ref = (_useStateStore = (0, _hooks.useStateStore)(threadInstance == null ? void 0 : threadInstance.state, selector)) != null ? _useStateStore : {},
isLoadingNext = _ref.isLoadingNext,
isLoadingPrev = _ref.isLoadingPrev,
latestReplies = _ref.latestReplies;
var contextAdapter = threadInstance ? {
loadMoreRecentThread: threadInstance.loadNextPage,
loadMoreThread: threadInstance.loadPrevPage,
threadInstance,
threadLoadingMore: isLoadingPrev,
threadLoadingMoreRecent: isLoadingNext,
threadMessages: latestReplies != null ? latestReplies : []
} : {};
return {
allowThreadMessagesInChannel,
onAlsoSentToChannelHeaderPress,
closeThread,
loadMoreThread,
openThread,
reloadThread,
setThreadLoadingMore,
thread,
threadHasMore,
threadLoadingMore,
threadMessages,
...contextAdapter
};
};
exports.useCreateThreadContext = useCreateThreadContext;
//# sourceMappingURL=useCreateThreadContext.js.map