@uimkit/uikit-react
Version:
<img style="width:64px" src="https://mgmt.uimkit.chat/media/img/avatar.png"/>
49 lines (44 loc) • 1.87 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var React = require('react');
require('../types/models.js');
require('../types/events.js');
require('../store/conversations/actions.js');
require('tslib');
var selectors = require('../store/conversations/selectors.js');
var commands = require('../store/conversations/commands.js');
var useDispatch = require('../store/useDispatch.js');
var reactRedux = require('react-redux');
require('redux');
require('../store/rootReducer.js');
require('../store/accounts/actions.js');
require('../store/accounts/selectors.js');
require('../node_modules/.pnpm/invariant@2.2.4/node_modules/invariant/invariant.js');
require('i18next');
require('../store/messages/actions.js');
require('../store/contacts/actions.js');
require('../node_modules/.pnpm/lodash.flatten@4.4.0/node_modules/lodash.flatten/index.js');
function useConversationList(accountId) {
var _a;
var dispatch = useDispatch.useDispatch();
React.useEffect(function () {
if (accountId) {
dispatch(commands.fetchConversationsByAccount(accountId));
}
}, [accountId]);
var loadMore = React.useCallback(function () {
if (accountId) {
dispatch(commands.fetchConversationsByAccount(accountId, true));
}
}, [accountId]);
var _b = reactRedux.useSelector(selectors.getConversationsStateByAccount(accountId)), conversations = _b.conversations, cursor = _b.cursor, loading = _b.loading, error = _b.error;
return {
loadMore: loadMore,
conversations: conversations,
loading: loading,
error: error,
hasMore: (_a = cursor === null || cursor === void 0 ? void 0 : cursor.has_next) !== null && _a !== void 0 ? _a : false,
};
}
exports.useConversationList = useConversationList;
//# sourceMappingURL=useConversationList.js.map