Cancel edition whithout saving

Hi,

I have a form in Angular with an iframe to edit a file using CODE. Is there a way to cancel the document editing without triggering autosave? I have set background_autosave to false and autosave_duration_secs to 0.
Thanks.

hii @galociber

I looked into this, and unfortunately, it’s not directly possible to cancel document editing in Collabora Online without triggering a save on close. Collabora is designed to save changes to prevent data loss, so even with background_autosave set to false and autosave_duration_secs set to 0, a final save usually occurs when the document is closed.

While there are some advanced workarounds (like modifying the source or specific WOPI server configurations), these are not straightforward or fully reliable for preventing a save action in standard deployments.

Thanks,
Darshan

Thank you very much for you answer.

Galo

Message from @galociber

Hi again,

With your guidance, I made a change to my @Post(':fileId/contents') method. In the request headers, there is a header "x-cool-wopi-isexitsave", which is false when the Action_Save message is sent implicitly and true when it is saved automatically by CODE.

With this code, I fixed it:

@Post(‘:fileId/contents’)
async saveFileContents(
@Param(‘fileId’) fileId: string,
@Req() req: Request,
@Res() res: Response,
) {

if (req.headers['x-cool-wopi-isexitsave'] === 'true') {
  console.log('Closing without saving.......')
  res.status(HttpStatus.OK).send();

}
else {
  console.log('Implicitly saving...');
  try {
    await this.wopiService.saveFileContents(fileId, req);
    res.status(HttpStatus.OK).send('File saved successfully');
  } catch (error) {
    res.status(HttpStatus.INTERNAL_SERVER_ERROR).send('Error saving file');
  }
}

}

Thank you.
Galo

Thanks @galociber for the workaround. Much Appreciated :partying_face: