-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[WEB-2545] fix: peek overview loading state #5698
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,15 +34,15 @@ export interface IIssueStoreActions { | |
| } | ||
|
|
||
| export interface IIssueStore extends IIssueStoreActions { | ||
| isFetchingIssueDetails: boolean; | ||
| isLocalDBIssueDescription: boolean; | ||
| getIsFetchingIssueDetails: (issueId: string | undefined) => boolean; | ||
| getIsLocalDBIssueDescription: (issueId: string | undefined) => boolean; | ||
| // helper methods | ||
| getIssueById: (issueId: string) => TIssue | undefined; | ||
| } | ||
|
|
||
| export class IssueStore implements IIssueStore { | ||
| isFetchingIssueDetails: boolean = false; | ||
| isLocalDBIssueDescription: boolean = false; | ||
| fetchingIssueDetails: string | undefined = undefined; | ||
| localDBIssueDescription: string | undefined = undefined; | ||
| // root store | ||
| rootIssueDetailStore: IIssueDetail; | ||
| // services | ||
|
|
@@ -52,7 +52,8 @@ export class IssueStore implements IIssueStore { | |
|
|
||
| constructor(rootStore: IIssueDetail) { | ||
| makeObservable(this, { | ||
| isFetchingIssueDetails: observable.ref, | ||
| fetchingIssueDetails: observable.ref, | ||
| localDBIssueDescription: observable.ref, | ||
| }); | ||
| // root store | ||
| this.rootIssueDetailStore = rootStore; | ||
|
|
@@ -62,6 +63,18 @@ export class IssueStore implements IIssueStore { | |
| this.issueDraftService = new IssueDraftService(); | ||
| } | ||
|
|
||
| getIsFetchingIssueDetails = computedFn((issueId: string | undefined) => { | ||
| if (!issueId) return false; | ||
|
|
||
| return this.fetchingIssueDetails === issueId; | ||
| }); | ||
|
|
||
| getIsLocalDBIssueDescription = computedFn((issueId: string | undefined) => { | ||
| if (!issueId) return false; | ||
|
|
||
| return this.localDBIssueDescription === issueId; | ||
| }); | ||
|
|
||
| // helper methods | ||
| getIssueById = computedFn((issueId: string) => { | ||
| if (!issueId) return undefined; | ||
|
|
@@ -79,11 +92,11 @@ export class IssueStore implements IIssueStore { | |
| // fetch issue from local db | ||
| issue = await persistence.getIssue(issueId); | ||
|
|
||
| this.isFetchingIssueDetails = true; | ||
| this.fetchingIssueDetails = issueId; | ||
|
|
||
| if (issue) { | ||
| this.addIssueToStore(issue); | ||
| this.isLocalDBIssueDescription = true; | ||
| this.localDBIssueDescription = issueId; | ||
|
Comment on lines
+95
to
+99
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure accurate tracking of fetching states for multiple issues When initiating the fetch operation, you set |
||
| } | ||
|
|
||
| if (issueType === "ARCHIVED") | ||
|
|
@@ -95,7 +108,7 @@ export class IssueStore implements IIssueStore { | |
| if (!issue) throw new Error("Issue not found"); | ||
|
|
||
| const issuePayload = this.addIssueToStore(issue); | ||
| this.isLocalDBIssueDescription = false; | ||
| this.localDBIssueDescription = undefined; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Properly clear the local DB issue description state After processing the issue, you set |
||
|
|
||
| this.rootIssueDetailStore.rootIssueStore.issues.addIssue([issuePayload]); | ||
|
|
||
|
|
@@ -173,7 +186,7 @@ export class IssueStore implements IIssueStore { | |
| }; | ||
|
|
||
| this.rootIssueDetailStore.rootIssueStore.issues.addIssue([issuePayload]); | ||
| this.isFetchingIssueDetails = false; | ||
| this.fetchingIssueDetails = undefined; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Properly clear the fetching issue details state At the end of |
||
|
|
||
| return issuePayload; | ||
| }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Potential issue with concurrent fetching of issue details
The properties
fetchingIssueDetailsandlocalDBIssueDescriptionare currently defined to store a singleissueId(string | undefined). If multiple issues are fetched concurrently, this implementation may not accurately reflect the loading state for each issue, leading to race conditions or incorrect UI states.Consider modifying these properties to hold a collection of
issueIds, such as aSet<string>, to properly track the loading state of multiple issues concurrently.