Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
views: t.optional(t.number, 0),
// author: Author,
tags: t.optional(t.string, ''), // TODO: ArrayOf Tag
comments: t.optional(t.string, ''), // TODO: ArrayOf comments
favoritedCount: t.optional(t.number, 0),
starredCount: t.optional(t.number, 0),
viewerHasFavorited: t.optional(t.boolean, false),
viewerHasStarred: t.optional(t.boolean, false),
insertedAt: t.optional(t.string, ''),
updatedAt: t.optional(t.string, ''),
})
const ArticleViwerStore = t
.model('ArticleViwerStore', {
type: t.optional(
t.enumeration('type', [
TYPE.POST,
TYPE.JOB,
// ...
]),
TYPE.POST
),
post: t.optional(Post, {}),
postLoading: t.optional(t.boolean, false),
})
.views(self => ({
get root() {
return getParent(self)
},
get curPost() {
return self.post.toJSON()
},
const Message = t.model('Message', {
message: t.string,
key: t.optional(t.string, ''),
code: t.optional(t.number, 0),
})
const ChangesetError = t.model('ChangesetError', {
code: t.maybeNull(t.number),
message: t.array(Message),
})
const ErrorBox = t
.model('ErrorBox', {
show: t.optional(t.boolean, false),
type: t.optional(
t.enumeration('type', [ERR.GRAPHQL, ERR.NETWORK, ERR.TIMEOUT]),
ERR.GRAPHQL
),
operation: t.optional(t.string, '--'),
path: t.maybeNull(t.string),
timeoutError: t.optional(t.string, '--'),
// spec type of ERR.GRAPHQL
graphqlType: t.optional(
t.enumeration('graphqlType', ['changeset', 'parse', 'custom']),
'changeset'
),
customError: t.maybeNull(t.array(Message)),
parseError: t.maybeNull(t.array(Message)),
changesetError: t.maybeNull(t.array(ChangesetError)),
})
.views(self => ({
import R from 'ramda'
import { TYPE } from '@constant'
import { markStates, buildLog, stripMobx, nilOrEmpty } from '@utils'
import { PagedJobs, Tag, ContentFilter, emptyPagiData } from '@model'
/* eslint-disable-next-line */
const log = buildLog('S:JobsThreadStore')
const JobsThreadStore = t
.model('JobsThreadStore', {
pagedJobs: t.optional(PagedJobs, emptyPagiData),
filters: t.optional(ContentFilter, {}),
activeTag: t.maybeNull(Tag),
curView: t.optional(
t.enumeration('curView', [
TYPE.RESULT,
TYPE.LOADING,
TYPE.NOT_FOUND,
TYPE.RESULT_EMPTY,
]),
TYPE.RESULT
),
showPublishNote: t.optional(t.boolean, false),
// runtime: ..
// data: ...
// TODO: rename to activeArticle
})
.views(self => ({
get root() {
return getParent(self)
},
import { markStates, buildLog, stripMobx } from '@utils'
import {
PagedPosts,
PagedJobs,
PagedVideos,
PagedRepos,
emptyPagiData,
} from '@model'
/* eslint-disable-next-line */
const log = buildLog('S:UserPublished')
const UserPublished = t
.model('UserPublished', {
curThread: t.optional(
t.enumeration('curThread', [
THREAD.POST,
THREAD.JOB,
THREAD.VIDEO,
THREAD.REPO,
]),
THREAD.POST
),
curView: t.optional(
t.enumeration('curView', [
TYPE.RESULT,
TYPE.LOADING,
TYPE.NOT_FOUND,
TYPE.RESULT_EMPTY,
]),
TYPE.LOADING
t.enumeration('descType', ['text', 'component']),
'text'
),
})
const DoraemonStore = t
.model('DoraemonStore', {
visible: t.optional(t.boolean, false),
searching: t.optional(t.boolean, false),
showAlert: t.optional(t.boolean, false),
showUtils: t.optional(t.boolean, false),
showThreadSelector: t.optional(t.boolean, false),
searchedTotalCount: t.optional(t.number, 0),
searchThread: t.optional(
t.enumeration('searchThread', [...R.values(THREAD), 'community']),
'community'
),
inputValue: t.optional(t.string, ''),
suggestions: t.optional(t.array(Suggestion), []),
activeRaw: t.maybeNull(t.string),
// TODO: prefix -> cmdPrefix, and prefix be a getter
prefix: t.optional(t.string, ''),
// for log config, input login/password ... etc
inputForOtherUse: t.optional(t.boolean, false),
cmdChain: t.maybeNull(t.array(t.string)),
})
.views(self => ({
get root() {
return getParent(self)
},
import { types } from 'mobx-state-tree';
export default {
selectedSandboxes: types.array(types.string),
trashSandboxIds: types.array(types.string),
isDragging: types.boolean,
orderBy: types.model({
order: types.enumeration('order', ['desc', 'asc']),
field: types.string,
}),
filters: types.model({
blacklistedTemplates: types.array(types.string),
search: types.string,
}),
};
import { types } from 'mobx-state-tree'
import Tool from '../Tool'
import { Point } from '../../marks'
const PointTool = types.model('Point', {
marks: types.map(Point),
size: types.optional(types.enumeration(['large', 'small']), 'large'),
type: types.literal('point')
})
.actions(self => {
function createMark (mark) {
const newMark = Point.create(mark)
self.marks.put(newMark)
return newMark
}
return {
createMark
}
})
export default types.compose('PointTool', Tool, PointTool)
import { types as t } from "mobx-state-tree"
import { v4 as uuid } from "uuid"
const Format = t.enumeration(["markdown", "html", "text"])
export const Note = t
.model({
id: t.optional(t.maybe(t.identifier(t.string)), uuid),
format: Format,
content: t.optional(t.string, ""),
placement: t.enumeration(["side", "main"]),
})
.actions(self => ({
setContent(content: string) {
self.content = content
},
}))
export type INote = typeof Note.Type
export type INoteFormat = typeof Format.Type
}
if (Platform.OS === 'ios') {
font['American Typewriter'] = 'American Typewriter';
font['Avenir Next'] = 'Avenir Next';
font['Georgia'] = 'Georgia';
font['Iowan Old Style'] = 'Iowan';
font['Palatino'] = 'Palatino';
font['Times New Roman'] = 'Times New Roman';
}
export const formatFont = (key: string) => {
return font[key];
};
export default types.enumeration('Font', Object.keys(font));
export const typeFromEnum = (name, enumz) => types.enumeration(name, map(enumz, e => e));