Skip to content

Commit 6b83406

Browse files
committed
add description for mutation and update default prefernces
1 parent 2db7d5a commit 6b83406

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

packages/data-context/src/actions/LocalSettingsActions.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { AllowedState, Editor } from '@packages/types'
1+
import { AllowedState, defaultPreferences, Editor } from '@packages/types'
22
import pDefer from 'p-defer'
33

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

4040
this.ctx.coreData.localSettings.availableEditors = availableEditors
41-
this.ctx.coreData.localSettings.preferences = await this.ctx._apis.localSettingsApi.getPreferences()
41+
this.ctx.coreData.localSettings.preferences = {
42+
...defaultPreferences,
43+
...(await this.ctx._apis.localSettingsApi.getPreferences()),
44+
}
4245

43-
dfd.resolve(availableEditors)
46+
dfd.resolve()
4447
}
4548
}

packages/data-context/src/data/coreDataShape.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BUNDLERS, FoundBrowser, FoundSpec, FullConfig, Preferences, defaultPreferences, Editor, Warning, AllowedState } from '@packages/types'
1+
import { BUNDLERS, FoundBrowser, FoundSpec, FullConfig, Preferences, Editor, Warning, AllowedState } from '@packages/types'
22
import type { NexusGenEnums, TestingTypeEnum } from '@packages/graphql/src/gen/nxs.gen'
33
import type { BrowserWindow } from 'electron'
44
import type { ChildProcess } from 'child_process'
@@ -117,7 +117,7 @@ export function makeCoreData (): CoreDataShape {
117117
},
118118
localSettings: {
119119
availableEditors: [],
120-
preferences: defaultPreferences,
120+
preferences: {},
121121
refreshing: null,
122122
},
123123
isAuthBrowserOpened: false,

packages/graphql/src/schemaTypes/objectTypes/gql-Mutation.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,15 @@ export const mutation = mutationType({
299299

300300
t.liveMutation('setPreferences', {
301301
type: 'Boolean',
302+
description: `
303+
Update local preferences (also known as appData).
304+
The payload, \`value\`, should be a JSON.stirngified
305+
object of the new values you'd like to persist.
306+
307+
Example usage:
308+
mutation setPreferences (value: JSON.stringify({ firstTimeOpening: Date.now(), specListOpen: true })
309+
`,
302310
args: {
303-
// Stringify JSON, eg JSON.stringify({ firstTimeOpening: Date.now() })
304311
value: nonNull(stringArg()),
305312
},
306313
resolve: async (_, args, ctx) => {

0 commit comments

Comments
 (0)