chore: Simplify model save codepath, prevents text from being sent ever when collab editing enabled

This commit is contained in:
Tom Moor
2022-06-20 22:55:37 +02:00
parent 6975d76faf
commit 9cd3ec0868
4 changed files with 35 additions and 89 deletions

View File

@@ -20,7 +20,10 @@ export default abstract class BaseModel {
this.store = store;
}
save = async (params?: Record<string, any>) => {
save = async (
params?: Record<string, any>,
options?: Record<string, string | boolean | number | undefined>
) => {
this.isSaving = true;
try {
@@ -29,7 +32,7 @@ export default abstract class BaseModel {
params = this.toAPI();
}
const model = await this.store.save({ ...params, id: this.id });
const model = await this.store.save({ ...params, id: this.id }, options);
// if saving is successful set the new values on the model itself
set(this, { ...params, ...model });