Skip to content

Commit

Permalink
Remove background fetch calls to the recently-viewed endpoint (#657)
Browse files Browse the repository at this point in the history
* Remove background fetches

* Update project-test.ts
  • Loading branch information
jeffdaley authored Mar 20, 2024
1 parent 4275a0a commit f8db8c0
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 16 deletions.
6 changes: 1 addition & 5 deletions web/app/routes/authenticated/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ export default class DashboardRoute extends Route {
promises.push(this.latestDocs.fetchAll.perform().then(() => {}));
}

if (this.recentlyViewed.index) {
void this.recentlyViewed.fetchAll.perform();
} else {
promises.push(this.recentlyViewed.fetchAll.perform());
}
promises.push(this.recentlyViewed.fetchAll.perform());

const [docsAwaitingReview] = await Promise.all(promises);

Expand Down
6 changes: 0 additions & 6 deletions web/app/routes/authenticated/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,6 @@ export default class AuthenticatedDocumentRoute extends Route {
}

afterModel(model: DocumentRouteModel, transition: any) {
/**
* Generally speaking, ensure an up-to-date list of recently viewed docs
* by the time the user returns to the dashboard.
*/
void this.recentlyViewed.fetchAll.perform();

/**
* Record the document view with the analytics backend.
*/
Expand Down
5 changes: 0 additions & 5 deletions web/app/routes/authenticated/projects/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ export default class AuthenticatedProjectsProjectRoute extends Route {
}

afterModel() {
/**
* Update the recently viewed index in the background.
*/
void this.recentlyViewed.fetchAll.perform();

/**
* Set `newModelHasLoaded` false in case it was set true in the model hook.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ module("Acceptance | authenticated/projects/project", function (hooks) {

await visit("/projects/1");

await recentlyViewed.fetchAll.perform();
assert.equal(recentlyViewed.index?.length, 1);

const project = recentlyViewed.index?.[0];
Expand Down

0 comments on commit f8db8c0

Please sign in to comment.