Skip to content

Commit

Permalink
fix: Always return initial content when needed
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Mar 30, 2024
1 parent 711f0c7 commit eea65b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cypress/e2e/initial.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ describe('Test state loading of documents', function() {
})

it('Load after state has been saved', function() {
cy.uploadFile('test.md', 'text/markdown')
cy.uploadFile('test.md', 'text/markdown', 'test2.md')
cy.intercept({ method: 'POST', url: '**/session/*/push' }).as('push')
cy.intercept({ method: 'POST', url: '**/session/*/sync' }).as('sync')
cy.intercept({ method: 'POST', url: '**/session/*/save' }).as('save')

let readToken = null
let writeToken = null
cy.shareFile('/test.md', { edit: true })
cy.shareFile('/test2.md', { edit: true })
.then((token) => {
writeToken = token
cy.logout()
Expand All @@ -137,8 +137,8 @@ describe('Test state loading of documents', function() {
.should('contain', 'Hello world')
.find('h2').should('contain', 'Something new Hello world')

cy.login(user)
cy.shareFile('/test.md')
cy.login(user)
cy.shareFile('/test2.md')
.then((token) => {
readToken = token
cy.logout()
Expand Down
4 changes: 4 additions & 0 deletions lib/Service/ApiService.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ public function create(?int $fileId = null, ?string $filePath = null, ?string $b
$this->logger->debug('Existing document, state file loaded ' . $file->getId());
} catch (NotFoundException $e) {
$this->logger->debug('Existing document, but state file not found for ' . $file->getId());

// If we have no state file we need to load the content from the file
// On the client side we use this to initialize a idempotent initial y.js document
$content = $this->loadContent($file);
}
}

Expand Down

0 comments on commit eea65b2

Please sign in to comment.