Skip to content

Preserve tree state on reload#1403

Merged
RMacfarlane merged 5 commits intomasterfrom
jackson/tree-preserve-pages
Oct 25, 2019
Merged

Preserve tree state on reload#1403
RMacfarlane merged 5 commits intomasterfrom
jackson/tree-preserve-pages

Conversation

@JacksonKearl
Copy link
Contributor

Fixes #1036.

pageInformation.pullRequestPage++;
addPage(await fetchPage(pageInformation.pullRequestPage));
} else {
if (pageInformation.pullRequestPage === 0) { pageInformation.pullRequestPage = 1; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should pullRequestPage be initialized to 1 above instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would cause the "continue searching in other remotes" action, which triggers a "fetchNextPage" command, to pull from page 2.

This whole thing is a bit tricky because there are three behaviours:

  1. Initialize: fetch the first page of the first remote that has pages
  2. Fetch Next: fetch the next page from this remote, or if it has no more pages, the first page from the next remote that does have pages
  3. Restore (new): fetch all the pages you previously have fetched

And only 2 options: fetchNextPage: true | false.

So when fetchNextPage: true we do 2, and when it's false, we do either 1 or 3. The initial state of 0 pullRequestPages fetched so far is what distinguishes 1 and 3.

Working on a better solution now...

Copy link
Contributor Author

@JacksonKearl JacksonKearl Oct 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pushed a reworking of the logic

Add some comments describing the logic.
Fix bug where fetching the next page of a non-all query would fetch all.
} else {
try {
const response = await this._prManager.getPullRequests(this._type, { fetchNextPage: true });
const response = await this._prManager.getPullRequests(this._type, { fetchNextPage: true }, this._categoryQuery);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was missing previously, causing "fetch more" on "created by me" (for instance), to just load the next page of "all"

};
}

public mayHaveMorePages(): boolean {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused and not really fundamentally compatible with the fact that there are many different queries that may or may not have more pages.

Copy link
Contributor

@RMacfarlane RMacfarlane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, this looks good to me.

@RMacfarlane RMacfarlane merged commit 0836050 into master Oct 25, 2019
@RMacfarlane RMacfarlane deleted the jackson/tree-preserve-pages branch October 25, 2019 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Checking out a PR in the viewlet can hide the checked out PR from view

2 participants