@uimkit/uikit-react
Version:
<img style="width:64px" src="https://mgmt.uimkit.chat/media/img/avatar.png"/>
46 lines (43 loc) • 1.76 kB
JavaScript
import { useEffect, useCallback } from 'react';
import '../types/models.js';
import '../types/events.js';
import { useDispatch } from '../store/useDispatch.js';
import { useSelector } from 'react-redux';
import 'redux';
import '../store/rootReducer.js';
import '../store/accounts/actions.js';
import 'tslib';
import '../store/accounts/selectors.js';
import '../node_modules/.pnpm/invariant@2.2.4/node_modules/invariant/invariant.js';
import 'i18next';
import '../store/conversations/actions.js';
import '../node_modules/.pnpm/lodash.flatten@4.4.0/node_modules/lodash.flatten/index.js';
import '../node_modules/.pnpm/lodash.some@4.6.0/node_modules/lodash.some/index.js';
import '../store/messages/actions.js';
import '../store/contacts/actions.js';
import { getContactsByAccountState } from '../store/contacts/selectors.js';
import { fetchContactsByAccount } from '../store/contacts/commands.js';
function useContactList(accountId) {
var _a;
var dispatch = useDispatch();
useEffect(function () {
if (accountId) {
dispatch(fetchContactsByAccount(accountId));
}
}, [accountId]);
var loadMore = useCallback(function () {
if (accountId) {
dispatch(fetchContactsByAccount(accountId, true));
}
}, [accountId]);
var _b = useSelector(getContactsByAccountState(accountId)), contacts = _b.contacts, loading = _b.loading, cursor = _b.cursor, error = _b.error;
return {
loadMore: loadMore,
hasMore: (_a = cursor === null || cursor === void 0 ? void 0 : cursor.has_next) !== null && _a !== void 0 ? _a : false,
loading: loading,
contacts: contacts,
error: error,
};
}
export { useContactList };
//# sourceMappingURL=useContactList.js.map