mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-10-23 06:46:11 +08:00
(ui): Update Queue state when new list of groups is fetched
This commit is contained in:
@@ -9,15 +9,18 @@ export const LIST_GROUPS_ERROR = "LIST_GROUPS_ERROR";
|
||||
|
||||
interface ListGroupsBeginAction {
|
||||
type: typeof LIST_GROUPS_BEGIN;
|
||||
queue: string;
|
||||
}
|
||||
|
||||
interface ListGroupsSuccessAction {
|
||||
type: typeof LIST_GROUPS_SUCCESS;
|
||||
payload: ListGroupsResponse;
|
||||
queue: string;
|
||||
}
|
||||
|
||||
interface ListGroupsErrorAction {
|
||||
type: typeof LIST_GROUPS_ERROR;
|
||||
queue: string;
|
||||
error: string;
|
||||
}
|
||||
|
||||
@@ -29,18 +32,20 @@ export type GroupsActionTypes =
|
||||
|
||||
export function listGroupsAsync(qname: string) {
|
||||
return async (dispatch: Dispatch<GroupsActionTypes>) => {
|
||||
dispatch({ type: LIST_GROUPS_BEGIN });
|
||||
dispatch({ type: LIST_GROUPS_BEGIN, queue: qname });
|
||||
try {
|
||||
const response = await listGroups(qname);
|
||||
dispatch({
|
||||
type: LIST_GROUPS_SUCCESS,
|
||||
payload: response,
|
||||
queue: qname,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(`listGroupsAsync: ${toErrorStringWithHttpStatus(error)}`);
|
||||
dispatch({
|
||||
type: LIST_GROUPS_ERROR,
|
||||
error: toErrorString(error),
|
||||
queue: qname,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user