convergencelabs / convergence-project

The project used for Convergence Project Management and Issue Reporting
https://convergence.io
42 stars 5 forks source link

Unable to close model with froala editor in angular #260

Open creativearish opened 2 years ago

creativearish commented 2 years ago

Versions

Describe the Bug

I am using convergence with Froala editor and angular.

We will be having different pages where we will need froala with convergence. So it is necessary to close the model whenever necessary (also to update live collaborators on each page).

But I am unable to close the model.

Following is the code which I am using to close the model:-

import { RealTimeModel } from '@convergence/convergence';
export class ConvergenceService {
public realTimeModel: RealTimeModel | undefined = undefined;
  public closeModel() {
    this.realTimeModel.close();
  }
}

I am checking if model is not getting closed (on opening the page) by

modelService.isOpen(model_id)

and everytime I call closeModel() and opens the page it shows that model is not closed (by logging above code line)

I also enabled logging and played with the convergence code a little bit and found that it logs in console the following lines:-

DEBUG 05:50:07.142 RealtimeModel.close() called: my_unique_model_id
DEBUG 05:50:07.142 Model("my_unique_model_id"): Close called on a non-resyncing model
DEBUG 05:50:07.142 Model("my_unique_model_id"): Close initiated (online)
DEBUG 05:50:07.187 Model("my_unique_model_id"): Closed with server

However it is not logging:-

DEBUG 05:50:07.189 Model("my_unique_model_id"): Finishing close

If I comment this line from convergence code (in node_modules) code in src then it works fine. Not sure why it is checking !this._connection.isConnected() and value of this._concurrencyControl.isCommitted() is false, though nothing has been changed in model.

Also I have tried to close the model without navigating away and it works well. But I would like to call closeModel in ngOnDestroy() because I want to make sure that model gets closed whenver user leaves the page.

And if I do not call closeModel then it works well for the first time (when opening the page for the first time) but after navigating back (by going back to previous page and opening it again) to that page I am unable to see anything in editor. And If I edit the doc then all my changes gets vanished and it overwrites the whole model. But if I open the page and go back and refresh the window and open that page again everything works well.

Expected Behavior

model should get closed and logs should be with 'Finishing close', like below:-

DEBUG 05:50:07.142 RealtimeModel.close() called: my_unique_model_id
DEBUG 05:50:07.142 Model("my_unique_model_id"): Close called on a non-resyncing model
DEBUG 05:50:07.142 Model("my_unique_model_id"): Close initiated (online)
DEBUG 05:50:07.187 Model("my_unique_model_id"): Closed with server
DEBUG 05:50:07.189 Model("my_unique_model_id"): Finishing close

I hope that everything is clear. Please let me know if anything is confusing or misunderstood by me. If you want anything from my side, please feel free to let me know. I tried to create stackblitz demo, but I am really sorry as it is not possible at the moment.

I really need this to be fixed as early as possible.

Thanks!