mirror of
https://github.com/outline/outline.git
synced 2026-11-20 21:23:06 +03:00
* Upgrade Mobx * fix: Enforce MobX action boundaries * fix: Wrap static observable updates in actions * Remove iteration tests
40 lines
703 B
TypeScript
40 lines
703 B
TypeScript
import { action, observable } from "mobx";
|
|
import Document from "./Document";
|
|
import User from "./User";
|
|
import Model from "./base/Model";
|
|
import Relation from "./decorators/Relation";
|
|
|
|
class View extends Model {
|
|
static modelName = "View";
|
|
|
|
constructor(fields: Record<string, unknown>, store: Model["store"]) {
|
|
super(fields, store);
|
|
this.initialize(fields);
|
|
}
|
|
|
|
documentId: string;
|
|
|
|
@Relation(() => Document)
|
|
document?: Document;
|
|
|
|
firstViewedAt: string;
|
|
|
|
@observable
|
|
lastViewedAt: string;
|
|
|
|
@observable
|
|
count: number;
|
|
|
|
userId: string;
|
|
|
|
@Relation(() => User)
|
|
user?: User;
|
|
|
|
@action
|
|
touch() {
|
|
this.lastViewedAt = new Date().toString();
|
|
}
|
|
}
|
|
|
|
export default View;
|