Skip to content

Commit

Permalink
fetch currentVersion in all agendapoint subroutes
Browse files Browse the repository at this point in the history
a parent route is not reloaded when switching between child routes, since we
loaded currentVersion there this could become outdated after a save. This in
turn caused unexpected behaviour when switching between subroutes (e.g.
revisions and edit), where either fewer revisions were shown than actually
existed or an older version of the document was shown when returning to the edit route
  • Loading branch information
Niels V committed Oct 12, 2022
1 parent a01b253 commit 0ea7256
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
6 changes: 2 additions & 4 deletions app/routes/agendapoints.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import RSVP from 'rsvp';
import { action } from '@ember/object';
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
Expand All @@ -22,11 +21,10 @@ export default class AgendapointsRoute extends Route {
{ include: 'status' }
);

return RSVP.hash({
return {
documentContainer: container,
editorDocument: await container.get('currentVersion'),
returnToMeeting: params.returnToMeeting,
});
};
}

@action
Expand Down
3 changes: 2 additions & 1 deletion app/routes/agendapoints/attachments.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ export default class AgendapointsAttachmentsRoute extends Route {
@service documentService;

async model() {
const { documentContainer, editorDocument, returnToMeeting } =
const { documentContainer, returnToMeeting } =
this.modelFor('agendapoints');
const editorDocument = await documentContainer.currentVersion;
const decisions = this.documentService.getDecisions(editorDocument);
return {
documentContainer,
Expand Down
6 changes: 5 additions & 1 deletion app/routes/agendapoints/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ export default class AgendapointsEditRoute extends Route {
}

async model() {
return this.modelFor('agendapoints');
const { documentContainer } = this.modelFor('agendapoints');
return {
documentContainer,
editorDocument: await documentContainer.get('currentVersion'),
};
}

setupController(controller, model) {
Expand Down
4 changes: 2 additions & 2 deletions app/routes/agendapoints/revisions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export default class AgendapointsRevisionsRoute extends Route {

async model() {
const { documentContainer, returnToMeeting } =
this.modelFor('agendapoints');
const editorDocument = await this.documentContainer.currentVersion;
this.modelFor('agendapoints');
const editorDocument = await documentContainer.currentVersion;
return RSVP.hash({
revisions: this.fetchRevisions.perform(editorDocument),
documentContainer,
Expand Down

0 comments on commit 0ea7256

Please sign in to comment.