Composer update (react-query refactor) (#1899)
* Move composer state to a context * Rework composer to use RQ --------- Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
		
							parent
							
								
									c687172de9
								
							
						
					
					
						commit
						0a26e78dcb
					
				
					 32 changed files with 269 additions and 239 deletions
				
			
		|  | @ -82,12 +82,11 @@ interface PostOpts { | |||
|   extLink?: ExternalEmbedDraft | ||||
|   images?: ImageModel[] | ||||
|   labels?: string[] | ||||
|   knownHandles?: Set<string> | ||||
|   onStateChange?: (state: string) => void | ||||
|   langs?: string[] | ||||
| } | ||||
| 
 | ||||
| export async function post(store: RootStoreModel, opts: PostOpts) { | ||||
| export async function post(agent: BskyAgent, opts: PostOpts) { | ||||
|   let embed: | ||||
|     | AppBskyEmbedImages.Main | ||||
|     | AppBskyEmbedExternal.Main | ||||
|  | @ -103,7 +102,7 @@ export async function post(store: RootStoreModel, opts: PostOpts) { | |||
|   ) | ||||
| 
 | ||||
|   opts.onStateChange?.('Processing...') | ||||
|   await rt.detectFacets(store.agent) | ||||
|   await rt.detectFacets(agent) | ||||
|   rt = shortenLinks(rt) | ||||
| 
 | ||||
|   // filter out any mention facets that didn't map to a user
 | ||||
|  | @ -136,7 +135,7 @@ export async function post(store: RootStoreModel, opts: PostOpts) { | |||
|       await image.compress() | ||||
|       const path = image.compressed?.path ?? image.path | ||||
|       const {width, height} = image.compressed || image | ||||
|       const res = await uploadBlob(store.agent, path, 'image/jpeg') | ||||
|       const res = await uploadBlob(agent, path, 'image/jpeg') | ||||
|       images.push({ | ||||
|         image: res.data.blob, | ||||
|         alt: image.altText ?? '', | ||||
|  | @ -186,7 +185,7 @@ export async function post(store: RootStoreModel, opts: PostOpts) { | |||
|         } | ||||
|         if (encoding) { | ||||
|           const thumbUploadRes = await uploadBlob( | ||||
|             store.agent, | ||||
|             agent, | ||||
|             opts.extLink.localThumb.path, | ||||
|             encoding, | ||||
|           ) | ||||
|  | @ -225,7 +224,7 @@ export async function post(store: RootStoreModel, opts: PostOpts) { | |||
|   // add replyTo if post is a reply to another post
 | ||||
|   if (opts.replyTo) { | ||||
|     const replyToUrip = new AtUri(opts.replyTo) | ||||
|     const parentPost = await store.agent.getPost({ | ||||
|     const parentPost = await agent.getPost({ | ||||
|       repo: replyToUrip.host, | ||||
|       rkey: replyToUrip.rkey, | ||||
|     }) | ||||
|  | @ -258,7 +257,7 @@ export async function post(store: RootStoreModel, opts: PostOpts) { | |||
| 
 | ||||
|   try { | ||||
|     opts.onStateChange?.('Posting...') | ||||
|     return await store.agent.post({ | ||||
|     return await agent.post({ | ||||
|       text: rt.text, | ||||
|       facets: rt.facets, | ||||
|       reply, | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ import {LikelyType, LinkMeta} from './link-meta' | |||
| import {convertBskyAppUrlIfNeeded, makeRecordUri} from '../strings/url-helpers' | ||||
| import {RootStoreModel} from 'state/index' | ||||
| import {PostThreadModel} from 'state/models/content/post-thread' | ||||
| import {ComposerOptsQuote} from 'state/models/ui/shell' | ||||
| import {ComposerOptsQuote} from 'state/shell/composer' | ||||
| 
 | ||||
| // TODO
 | ||||
| // import {Home} from 'view/screens/Home'
 | ||||
|  |  | |||
|  | @ -3,7 +3,6 @@ import { | |||
|   openCropper as openCropperFn, | ||||
|   Image as RNImage, | ||||
| } from 'react-native-image-crop-picker' | ||||
| import {RootStoreModel} from 'state/index' | ||||
| import {CameraOpts, CropperOptions} from './types' | ||||
| export {openPicker} from './picker.shared' | ||||
| 
 | ||||
|  | @ -16,10 +15,7 @@ export {openPicker} from './picker.shared' | |||
|  * -prf | ||||
|  */ | ||||
| 
 | ||||
| export async function openCamera( | ||||
|   _store: RootStoreModel, | ||||
|   opts: CameraOpts, | ||||
| ): Promise<RNImage> { | ||||
| export async function openCamera(opts: CameraOpts): Promise<RNImage> { | ||||
|   const item = await openCameraFn({ | ||||
|     width: opts.width, | ||||
|     height: opts.height, | ||||
|  | @ -39,10 +35,7 @@ export async function openCamera( | |||
|   } | ||||
| } | ||||
| 
 | ||||
| export async function openCropper( | ||||
|   _store: RootStoreModel, | ||||
|   opts: CropperOptions, | ||||
| ) { | ||||
| export async function openCropper(opts: CropperOptions) { | ||||
|   const item = await openCropperFn({ | ||||
|     ...opts, | ||||
|     forceJpg: true, // ios only
 | ||||
|  |  | |||
|  | @ -1,23 +1,16 @@ | |||
| /// <reference lib="dom" />
 | ||||
| 
 | ||||
| import {CameraOpts, CropperOptions} from './types' | ||||
| import {RootStoreModel} from 'state/index' | ||||
| import {Image as RNImage} from 'react-native-image-crop-picker' | ||||
| export {openPicker} from './picker.shared' | ||||
| import {unstable__openModal} from '#/state/modals' | ||||
| 
 | ||||
| export async function openCamera( | ||||
|   _store: RootStoreModel, | ||||
|   _opts: CameraOpts, | ||||
| ): Promise<RNImage> { | ||||
| export async function openCamera(_opts: CameraOpts): Promise<RNImage> { | ||||
|   // const mediaType = opts.mediaType || 'photo' TODO
 | ||||
|   throw new Error('TODO') | ||||
| } | ||||
| 
 | ||||
| export async function openCropper( | ||||
|   _store: RootStoreModel, | ||||
|   opts: CropperOptions, | ||||
| ): Promise<RNImage> { | ||||
| export async function openCropper(opts: CropperOptions): Promise<RNImage> { | ||||
|   // TODO handle more opts
 | ||||
|   return new Promise((resolve, reject) => { | ||||
|     unstable__openModal({ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue