feat: Option for separate edit mode (#4203)
* stash * wip * cleanup * Remove collaborativeEditing toggle, it will always be on in next release. Flip separateEdit -> seamlessEdit * Clarify language, hide toggle when collaborative editing is disabled * Flip boolean to match, easier to reason about
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { subMinutes } from "date-fns";
|
||||
import { computed, observable } from "mobx";
|
||||
import { now } from "mobx-utils";
|
||||
import type { Role, UserPreferences } from "@shared/types";
|
||||
import type { Role, UserPreference, UserPreferences } from "@shared/types";
|
||||
import ParanoidModel from "./ParanoidModel";
|
||||
import Field from "./decorators/Field";
|
||||
|
||||
@@ -66,6 +66,31 @@ class User extends ParanoidModel {
|
||||
return "member";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value for a specific preference key, or return the fallback if
|
||||
* none is set.
|
||||
*
|
||||
* @param key The UserPreference key to retrieve
|
||||
* @param fallback An optional fallback value, defaults to false.
|
||||
* @returns The value
|
||||
*/
|
||||
getPreference(key: UserPreference, fallback = false): boolean {
|
||||
return this.preferences?.[key] ?? fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value for a specific preference key.
|
||||
*
|
||||
* @param key The UserPreference key to retrieve
|
||||
* @param value The value to set
|
||||
*/
|
||||
setPreference(key: UserPreference, value: boolean) {
|
||||
this.preferences = {
|
||||
...this.preferences,
|
||||
[key]: value,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default User;
|
||||
|
||||
Reference in New Issue
Block a user