@uimkit/uikit-react
Version:
<img style="width:64px" src="https://mgmt.uimkit.chat/media/img/avatar.png"/>
50 lines (45 loc) • 1.89 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var React = require('react');
require('../types/models.js');
require('../types/events.js');
var useDispatch = require('../store/useDispatch.js');
var reactRedux = require('react-redux');
require('redux');
require('../store/rootReducer.js');
require('../store/accounts/actions.js');
require('tslib');
require('../store/accounts/selectors.js');
require('../node_modules/.pnpm/invariant@2.2.4/node_modules/invariant/invariant.js');
require('i18next');
require('../store/conversations/actions.js');
require('../node_modules/.pnpm/lodash.flatten@4.4.0/node_modules/lodash.flatten/index.js');
require('../node_modules/.pnpm/lodash.some@4.6.0/node_modules/lodash.some/index.js');
require('../store/messages/actions.js');
require('../store/contacts/actions.js');
var selectors = require('../store/contacts/selectors.js');
var commands = require('../store/contacts/commands.js');
function useContactList(accountId) {
var _a;
var dispatch = useDispatch.useDispatch();
React.useEffect(function () {
if (accountId) {
dispatch(commands.fetchContactsByAccount(accountId));
}
}, [accountId]);
var loadMore = React.useCallback(function () {
if (accountId) {
dispatch(commands.fetchContactsByAccount(accountId, true));
}
}, [accountId]);
var _b = reactRedux.useSelector(selectors.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,
};
}
exports.useContactList = useContactList;
//# sourceMappingURL=useContactList.js.map