-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[review-changes] Squashed commit with initial spike
- Loading branch information
Showing
144 changed files
with
5,286 additions
and
1,581 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
declare module 'part:*' | ||
declare module 'all:part:*' | ||
declare module 'part:@sanity/base/client' { | ||
const client: import('@sanity/client').SanityClient | ||
export default client | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/@sanity/base/src/datastores/document/document-pair/remoteMutations.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import {merge, Observable} from 'rxjs' | ||
import {filter, publishReplay, refCount, switchMap} from 'rxjs/operators' | ||
import {DocumentRemoteMutationEvent} from '../buffered-doc/types' | ||
import {IdPair} from '../types' | ||
import {memoize} from '../utils/createMemoizer' | ||
import {memoizedPair} from './memoizedPair' | ||
import {DocumentVersion} from './checkoutPair' | ||
|
||
export type RemoteMutationWithVersion = DocumentRemoteMutationEvent & { | ||
version: 'published' | 'draft' | ||
} | ||
|
||
function withRemoteMutation(version: DocumentVersion) { | ||
return version.events.pipe( | ||
filter((ev): ev is RemoteMutationWithVersion => ev.type === 'remoteMutation'), | ||
publishReplay(1), | ||
refCount() | ||
) | ||
} | ||
|
||
export const remoteMutations = memoize( | ||
(idPair: IdPair): Observable<RemoteMutationWithVersion> => { | ||
return memoizedPair(idPair).pipe( | ||
switchMap(({published, draft}) => | ||
merge(withRemoteMutation(published), withRemoteMutation(draft)) | ||
), | ||
publishReplay(1), | ||
refCount() | ||
) | ||
}, | ||
idPair => idPair.publishedId | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.