Skip to content

Commit

Permalink
add description for mutation and update default prefernces
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiller1990 committed Nov 29, 2021
1 parent 2db7d5a commit 6b83406
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
9 changes: 6 additions & 3 deletions packages/data-context/src/actions/LocalSettingsActions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AllowedState, Editor } from '@packages/types'
import { AllowedState, defaultPreferences, Editor } from '@packages/types'
import pDefer from 'p-defer'

import type { DataContext } from '..'
Expand Down Expand Up @@ -38,8 +38,11 @@ export class LocalSettingsActions {
const availableEditors = await this.ctx._apis.localSettingsApi.getAvailableEditors()

this.ctx.coreData.localSettings.availableEditors = availableEditors
this.ctx.coreData.localSettings.preferences = await this.ctx._apis.localSettingsApi.getPreferences()
this.ctx.coreData.localSettings.preferences = {
...defaultPreferences,
...(await this.ctx._apis.localSettingsApi.getPreferences()),
}

dfd.resolve(availableEditors)
dfd.resolve()
}
}
4 changes: 2 additions & 2 deletions packages/data-context/src/data/coreDataShape.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BUNDLERS, FoundBrowser, FoundSpec, FullConfig, Preferences, defaultPreferences, Editor, Warning, AllowedState } from '@packages/types'
import { BUNDLERS, FoundBrowser, FoundSpec, FullConfig, Preferences, Editor, Warning, AllowedState } from '@packages/types'
import type { NexusGenEnums, TestingTypeEnum } from '@packages/graphql/src/gen/nxs.gen'
import type { BrowserWindow } from 'electron'
import type { ChildProcess } from 'child_process'
Expand Down Expand Up @@ -117,7 +117,7 @@ export function makeCoreData (): CoreDataShape {
},
localSettings: {
availableEditors: [],
preferences: defaultPreferences,
preferences: {},
refreshing: null,
},
isAuthBrowserOpened: false,
Expand Down
9 changes: 8 additions & 1 deletion packages/graphql/src/schemaTypes/objectTypes/gql-Mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,15 @@ export const mutation = mutationType({

t.liveMutation('setPreferences', {
type: 'Boolean',
description: `
Update local preferences (also known as appData).
The payload, \`value\`, should be a JSON.stirngified
object of the new values you'd like to persist.
Example usage:
mutation setPreferences (value: JSON.stringify({ firstTimeOpening: Date.now(), specListOpen: true })
`,
args: {
// Stringify JSON, eg JSON.stringify({ firstTimeOpening: Date.now() })
value: nonNull(stringArg()),
},
resolve: async (_, args, ctx) => {
Expand Down

0 comments on commit 6b83406

Please sign in to comment.