mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-28 14:03:55 +03:00
7621bccf22
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
24 lines
605 B
TypeScript
24 lines
605 B
TypeScript
import { type ViewContext, type ViewContextType } from '@hcengineering/view'
|
|
import { writable } from 'svelte/store'
|
|
|
|
/**
|
|
* @public
|
|
*/
|
|
export class ContextStore {
|
|
constructor (readonly contexts: ViewContext[]) {}
|
|
|
|
getLastContext (): ViewContext | undefined {
|
|
return this.contexts[this.contexts.length - 1]
|
|
}
|
|
|
|
isIncludes (type: ViewContextType): boolean {
|
|
return (
|
|
this.contexts.find((it) => it.mode === type || (Array.isArray(it.mode) && it.mode.includes(type))) !== undefined
|
|
)
|
|
}
|
|
}
|
|
/**
|
|
* @public
|
|
*/
|
|
export const contextStore = writable<ContextStore>(new ContextStore([]))
|