Skip to content

Commit

Permalink
improved listen to create for tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
klakhov committed May 23, 2024
1 parent 358e046 commit 8b02cec
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
16 changes: 10 additions & 6 deletions cvat-core/src/requests-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,16 @@ class RequestsManager {
});
};

this.listening[storedID] = {
onUpdate: callback ? [callback] : [],
timeout: window.setTimeout(timeoutCallback),
request: initialRequest,
requestDelayIdx: 0,
};
if (initialRequest?.status === RQStatus.FAILED) {
reject(new RequestError(initialRequest?.message));
} else {
this.listening[storedID] = {
onUpdate: callback ? [callback] : [],
timeout: window.setTimeout(timeoutCallback),
request: initialRequest,
requestDelayIdx: 0,
};
}
});

this.listening[storedID] = {
Expand Down
3 changes: 2 additions & 1 deletion cvat-core/src/session-implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,10 +516,11 @@ export function implementTask(Task) {
};

Task.prototype.listenToCreate.implementation = async function (
rqID,
options,
): Promise<TaskClass> {
if (Number.isInteger(this.id) && this.size === 0) {
const request = await requestsManager.listen(null, options);
const request = await requestsManager.listen(rqID, options);
const [serializedTask] = await serverProxy.tasks.get({ id: request.operation.taskID });
return new Task(omit(serializedTask, ['labels', 'jobs']));
}
Expand Down
3 changes: 2 additions & 1 deletion cvat-core/src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1072,9 +1072,10 @@ export class Task extends Session {
}

async listenToCreate(
rqID,
options,
): Promise<Task> {
const result = await PluginRegistry.apiWrapper.call(this, Task.prototype.listenToCreate, options);
const result = await PluginRegistry.apiWrapper.call(this, Task.prototype.listenToCreate, rqID, options);
return result;
}

Expand Down
1 change: 1 addition & 0 deletions cvat-ui/src/components/tasks-page/task-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class TaskItemComponent extends React.PureComponent<TaskItemProps & RouteCompone
});
}
},
initialRequest: activeRequest,
},
).then((createdTask: Task) => {
if (!this.#isUnmounted) {
Expand Down

0 comments on commit 8b02cec

Please sign in to comment.