mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
[WEB-1398] fix: quick add issue flicker for cycle and module grouping (#4579)
* utilize optimistic updates to fix quick add issue flicker * add comments
This commit is contained in:
parent
9f573d4299
commit
7a47ce9d1d
@ -293,24 +293,26 @@ export class CycleIssues extends IssueHelperStore implements ICycleIssues {
|
|||||||
|
|
||||||
const response = await this.createIssue(workspaceSlug, projectId, data, cycleId);
|
const response = await this.createIssue(workspaceSlug, projectId, data, cycleId);
|
||||||
|
|
||||||
if (data.module_ids && data.module_ids.length > 0)
|
const quickAddIssueIndex = this.issues[cycleId].findIndex((_issueId) => _issueId === data.id);
|
||||||
|
if (quickAddIssueIndex >= 0) {
|
||||||
|
runInAction(() => {
|
||||||
|
this.issues[cycleId].splice(quickAddIssueIndex, 1);
|
||||||
|
this.rootIssueStore.issues.removeIssue(data.id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.module_ids && data.module_ids.length > 0) {
|
||||||
await this.rootStore.moduleIssues.changeModulesInIssue(
|
await this.rootStore.moduleIssues.changeModulesInIssue(
|
||||||
workspaceSlug,
|
workspaceSlug,
|
||||||
projectId,
|
projectId,
|
||||||
response.id,
|
response.id,
|
||||||
data.module_ids,
|
data.module_ids,
|
||||||
[]
|
[]
|
||||||
);
|
)
|
||||||
|
}
|
||||||
|
|
||||||
this.rootIssueStore.rootStore.cycle.fetchCycleDetails(workspaceSlug, projectId, cycleId);
|
this.rootIssueStore.rootStore.cycle.fetchCycleDetails(workspaceSlug, projectId, cycleId);
|
||||||
|
|
||||||
const quickAddIssueIndex = this.issues[cycleId].findIndex((_issueId) => _issueId === data.id);
|
|
||||||
if (quickAddIssueIndex >= 0)
|
|
||||||
runInAction(() => {
|
|
||||||
this.issues[cycleId].splice(quickAddIssueIndex, 1);
|
|
||||||
this.rootIssueStore.issues.removeIssue(data.id);
|
|
||||||
});
|
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (cycleId) this.fetchIssues(workspaceSlug, projectId, "mutation", cycleId);
|
if (cycleId) this.fetchIssues(workspaceSlug, projectId, "mutation", cycleId);
|
||||||
|
@ -294,17 +294,19 @@ export class ModuleIssues extends IssueHelperStore implements IModuleIssues {
|
|||||||
|
|
||||||
const response = await this.createIssue(workspaceSlug, projectId, data, moduleId);
|
const response = await this.createIssue(workspaceSlug, projectId, data, moduleId);
|
||||||
|
|
||||||
if (data.cycle_id && data.cycle_id !== "")
|
|
||||||
await this.rootStore.cycleIssues.addIssueToCycle(workspaceSlug, projectId, data.cycle_id, [response.id]);
|
|
||||||
|
|
||||||
this.rootIssueStore.rootStore.module.fetchModuleDetails(workspaceSlug, projectId, moduleId);
|
|
||||||
|
|
||||||
const quickAddIssueIndex = this.issues[moduleId].findIndex((_issueId) => _issueId === data.id);
|
const quickAddIssueIndex = this.issues[moduleId].findIndex((_issueId) => _issueId === data.id);
|
||||||
if (quickAddIssueIndex >= 0)
|
if (quickAddIssueIndex >= 0) {
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
this.issues[moduleId].splice(quickAddIssueIndex, 1);
|
this.issues[moduleId].splice(quickAddIssueIndex, 1);
|
||||||
this.rootIssueStore.issues.removeIssue(data.id);
|
this.rootIssueStore.issues.removeIssue(data.id);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.cycle_id && data.cycle_id !== "") {
|
||||||
|
await this.rootStore.cycleIssues.addCycleToIssue(workspaceSlug, projectId, data.cycle_id, response.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.rootIssueStore.rootStore.module.fetchModuleDetails(workspaceSlug, projectId, moduleId);
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -239,24 +239,27 @@ export class ProjectViewIssues extends IssueHelperStore implements IProjectViewI
|
|||||||
|
|
||||||
const response = await this.createIssue(workspaceSlug, projectId, data, viewId);
|
const response = await this.createIssue(workspaceSlug, projectId, data, viewId);
|
||||||
|
|
||||||
if (data.cycle_id && data.cycle_id !== "")
|
const quickAddIssueIndex = this.issues[viewId].findIndex((_issueId) => _issueId === data.id);
|
||||||
await this.rootStore.cycleIssues.addIssueToCycle(workspaceSlug, projectId, data.cycle_id, [response.id]);
|
if (quickAddIssueIndex >= 0) {
|
||||||
|
runInAction(() => {
|
||||||
|
this.issues[viewId].splice(quickAddIssueIndex, 1);
|
||||||
|
this.rootIssueStore.issues.removeIssue(data.id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (data.module_ids && data.module_ids.length > 0)
|
if (data.cycle_id && data.cycle_id !== "") {
|
||||||
|
await this.rootStore.cycleIssues.addCycleToIssue(workspaceSlug, projectId, data.cycle_id, response.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.module_ids && data.module_ids.length > 0) {
|
||||||
await this.rootStore.moduleIssues.changeModulesInIssue(
|
await this.rootStore.moduleIssues.changeModulesInIssue(
|
||||||
workspaceSlug,
|
workspaceSlug,
|
||||||
projectId,
|
projectId,
|
||||||
response.id,
|
response.id,
|
||||||
data.module_ids,
|
data.module_ids,
|
||||||
[]
|
[]
|
||||||
);
|
)
|
||||||
|
}
|
||||||
const quickAddIssueIndex = this.issues[viewId].findIndex((_issueId) => _issueId === data.id);
|
|
||||||
if (quickAddIssueIndex >= 0)
|
|
||||||
runInAction(() => {
|
|
||||||
this.issues[viewId].splice(quickAddIssueIndex, 1);
|
|
||||||
this.rootIssueStore.issues.removeIssue(data.id);
|
|
||||||
});
|
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -243,24 +243,29 @@ export class ProjectIssues extends IssueHelperStore implements IProjectIssues {
|
|||||||
|
|
||||||
const response = await this.createIssue(workspaceSlug, projectId, data);
|
const response = await this.createIssue(workspaceSlug, projectId, data);
|
||||||
|
|
||||||
if (data.cycle_id && data.cycle_id !== "")
|
const quickAddIssueIndex = this.issues[projectId].findIndex((_issueId) => _issueId === data.id);
|
||||||
await this.rootStore.cycleIssues.addIssueToCycle(workspaceSlug, projectId, data.cycle_id, [response.id]);
|
|
||||||
|
|
||||||
if (data.module_ids && data.module_ids.length > 0)
|
if (quickAddIssueIndex >= 0) {
|
||||||
|
runInAction(() => {
|
||||||
|
this.issues[projectId].splice(quickAddIssueIndex, 1);
|
||||||
|
this.rootStore.issues.removeIssue(data.id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: error handling needs to be improved for rare cases
|
||||||
|
if (data.cycle_id && data.cycle_id !== "") {
|
||||||
|
await this.rootStore.cycleIssues.addCycleToIssue(workspaceSlug, projectId, data.cycle_id, response.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.module_ids && data.module_ids.length > 0) {
|
||||||
await this.rootStore.moduleIssues.changeModulesInIssue(
|
await this.rootStore.moduleIssues.changeModulesInIssue(
|
||||||
workspaceSlug,
|
workspaceSlug,
|
||||||
projectId,
|
projectId,
|
||||||
response.id,
|
response.id,
|
||||||
data.module_ids,
|
data.module_ids,
|
||||||
[]
|
[]
|
||||||
);
|
)
|
||||||
|
}
|
||||||
const quickAddIssueIndex = this.issues[projectId].findIndex((_issueId) => _issueId === data.id);
|
|
||||||
if (quickAddIssueIndex >= 0)
|
|
||||||
runInAction(() => {
|
|
||||||
this.issues[projectId].splice(quickAddIssueIndex, 1);
|
|
||||||
this.rootStore.issues.removeIssue(data.id);
|
|
||||||
});
|
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.fetchIssues(workspaceSlug, projectId, "mutation");
|
this.fetchIssues(workspaceSlug, projectId, "mutation");
|
||||||
|
Loading…
Reference in New Issue
Block a user