Skip to content

Commit

Permalink
[google-maps-input] Use typed diff component resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Oct 6, 2020
1 parent 7ee4ee1 commit a2b98bf
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions packages/@sanity/google-maps-input/src/diff/resolver.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import {ArraySchemaType} from '@sanity/field/diff'
import {GeopointSchemaType} from '../types'
import {DiffComponentResolver} from '@sanity/field/diff'
import {GeopointFieldDiff} from './GeopointFieldDiff'
import {GeopointArrayDiff} from './GeopointArrayDiff'

export default function diffResolver({
schemaType
}: {
schemaType: GeopointSchemaType | ArraySchemaType
}) {
const diffResolver: DiffComponentResolver = function diffResolver({schemaType}) {
if (schemaType.name === 'geopoint') {
return GeopointFieldDiff
}

if (
schemaType.name === 'array' &&
schemaType.jsonType === 'array' &&
schemaType.of.length === 1 &&
schemaType.of[0].name === 'geopoint'
) {
Expand All @@ -22,3 +17,5 @@ export default function diffResolver({

return undefined
}

export default diffResolver

0 comments on commit a2b98bf

Please sign in to comment.