Add more robust modals controller
This commit is contained in:
parent
8de3b066eb
commit
6835caa760
8 changed files with 173 additions and 23 deletions
|
@ -5,6 +5,8 @@ import * as libapi from './lib/api'
|
|||
import * as storage from './lib/storage'
|
||||
// import * as auth from './auth' TODO
|
||||
|
||||
import {ShellModel} from './models/shell'
|
||||
|
||||
const ROOT_STATE_STORAGE_KEY = 'root'
|
||||
|
||||
export async function setupState() {
|
||||
|
|
|
@ -8,11 +8,13 @@ import {createContext, useContext} from 'react'
|
|||
import {isObj, hasProp} from '../lib/type-guards'
|
||||
import {SessionModel} from './session'
|
||||
import {NavigationModel} from './navigation'
|
||||
import {ShellModel} from './shell'
|
||||
import {MeModel} from './me'
|
||||
|
||||
export class RootStoreModel {
|
||||
session = new SessionModel()
|
||||
nav = new NavigationModel()
|
||||
shell = new ShellModel()
|
||||
me = new MeModel(this)
|
||||
|
||||
constructor(public api: AdxClient) {
|
||||
|
|
28
src/state/models/shell.ts
Normal file
28
src/state/models/shell.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
import {makeAutoObservable} from 'mobx'
|
||||
|
||||
export class LinkActionsModel {
|
||||
name = 'link-actions'
|
||||
|
||||
constructor(public href: string, public title: string) {
|
||||
makeAutoObservable(this)
|
||||
}
|
||||
}
|
||||
|
||||
export class ShellModel {
|
||||
isModalActive = false
|
||||
activeModal: LinkActionsModel | undefined
|
||||
|
||||
constructor() {
|
||||
makeAutoObservable(this)
|
||||
}
|
||||
|
||||
openModal(modal: LinkActionsModel) {
|
||||
this.isModalActive = true
|
||||
this.activeModal = modal
|
||||
}
|
||||
|
||||
closeModal() {
|
||||
this.isModalActive = false
|
||||
this.activeModal = undefined
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue