about summary refs log tree commit diff
path: root/src/state/models/shell.ts
blob: 2dddb9a33bfb15885361213df90fc0794205cc40 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import {makeAutoObservable} from 'mobx'
import {ProfileViewModel} from './profile-view'

export class LinkActionsModel {
  name = 'link-actions'

  constructor(public href: string, public title: string) {
    makeAutoObservable(this)
  }
}

export class SharePostModel {
  name = 'share-post'

  constructor(public href: string) {
    makeAutoObservable(this)
  }
}

export class ComposePostModel {
  name = 'compose-post'

  constructor(public replyTo?: string) {
    makeAutoObservable(this)
  }
}

export class EditProfileModel {
  name = 'edit-profile'

  constructor(public profileView: ProfileViewModel) {
    makeAutoObservable(this)
  }
}

export class ShellModel {
  isModalActive = false
  activeModal:
    | LinkActionsModel
    | SharePostModel
    | ComposePostModel
    | EditProfileModel
    | undefined

  constructor() {
    makeAutoObservable(this)
  }

  openModal(
    modal:
      | LinkActionsModel
      | SharePostModel
      | ComposePostModel
      | EditProfileModel,
  ) {
    this.isModalActive = true
    this.activeModal = modal
  }

  closeModal() {
    this.isModalActive = false
    this.activeModal = undefined
  }
}