@uimkit/uikit-react
Version:
<img style="width:64px" src="https://mgmt.uimkit.chat/media/img/avatar.png"/>
84 lines (79 loc) • 3.62 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var tslib = require('tslib');
var invariant = require('../../node_modules/.pnpm/invariant@2.2.4/node_modules/invariant/invariant.js');
require('redux');
var i18n = require('i18next');
require('../../types/models.js');
require('../../types/events.js');
require('../rootReducer.js');
require('../accounts/actions.js');
require('../accounts/selectors.js');
require('../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('../messages/actions.js');
var actions = require('./actions.js');
/**
* 查询账号的联系人列表
*
* @param accountId
* @param loadMore 是否查询更多,false 代表重新开始查询,true 代表基于之前的游标继续查询
* @param limit
* @returns
*/
var fetchContactsByAccount = function (accountId, loadMore, limit) {
if (loadMore === void 0) { loadMore = false; }
if (limit === void 0) { limit = 50; }
return function (dispatch, getState, context) { return tslib.__awaiter(void 0, void 0, void 0, function () {
var client, onError, state, account, cursor, request, response, e_2;
var _a;
return tslib.__generator(this, function (_b) {
switch (_b.label) {
case 0:
client = getState().common.client;
onError = context.onError;
invariant(client, "requires client");
state = getState();
account = state.accounts.accounts.find(function (it) { return it.id === accountId; });
cursor = (_a = state.contacts[accountId]) === null || _a === void 0 ? void 0 : _a.cursor;
console.log('上一次的cursor: ', cursor);
request = {
account_id: accountId,
direction: "after",
cursor: (loadMore && cursor) ? cursor.end_cursor : "",
limit: limit
};
_b.label = 1;
case 1:
_b.trys.push([1, 3, , 4]);
dispatch({
type: actions.ContactListActionType.FETCHING_CONTACT_LIST,
payload: request
});
return [4 /*yield*/, client.getContactList(request)];
case 2:
response = _b.sent();
dispatch({
type: actions.ContactListActionType.CONTACT_LIST_FETCHED,
payload: { request: request, response: response }
});
return [3 /*break*/, 4];
case 3:
e_2 = _b.sent();
dispatch({
type: actions.ContactListActionType.ERROR_FETCHING_CONTACT_LIST,
payload: { request: request, error: e_2 }
});
onError && onError(e_2, i18n.t([
"".concat(account === null || account === void 0 ? void 0 : account.provider, ":chat:contacts:fetchListError"),
"default:chat:contacts:fetchListError"
]));
return [3 /*break*/, 4];
case 4: return [2 /*return*/];
}
});
}); };
};
exports.fetchContactsByAccount = fetchContactsByAccount;
//# sourceMappingURL=commands.js.map