-
Notifications
You must be signed in to change notification settings - Fork 13k
refactor: Phase-out async state API #37944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
85879ee
refactor: remove `useAsyncState` hook
tassoevan 4b1968a
refactor: add marketplace query keys
tassoevan d881673
refactor: decompose some `AppsContext` fields
tassoevan 114948f
refactor: remove async state from `AppsContext`
tassoevan 3ca8dd9
refactor: remove async state handling from `OmnichannelRoomIcon` comp…
tassoevan 409800d
refactor: replace record list with infinite query in `useTeamsChannel…
tassoevan c2d7299
refactor: replace record list with infinite query in `useVideoConfList`
tassoevan a8d9194
refactor: replace record list with infinite query in `useFilesList`
tassoevan 883ae2e
refactor: replace record list with infinite query in `useImagesList`
tassoevan 3abd947
refactor: replace record list with infinite query in `useCannedRespon…
tassoevan 337fb24
refactor: replace record list with infinite query in `useRoomsList`
tassoevan 8ab7644
refactor: replace record list with infinite query in `useHistoryMessa…
tassoevan ce750c5
refactor: remove async state API
tassoevan 273394a
fix: change query key to match query function closure
tassoevan 54cec61
fix: incorrect spreading object
tassoevan bfbff5e
refactor: ease type for possibly undefined value
tassoevan c2a4308
fix: correct broken reference
tassoevan a788c82
refactor: replace `.sort` with `.toSorted`
tassoevan ed17b72
refactor: simplify `AppsContext`
tassoevan 02b93e0
refactor: breakdown redundant boolean expressions
tassoevan 38becef
refactor: handle mutation idle state
tassoevan 4ac4b7b
chore: add TODO
tassoevan b9d4383
fix: handle item count inconsistencies
tassoevan 2991c9b
refactor: replace `.sort` with `.toSorted`
tassoevan b7d6dc6
fix: escape regexp
tassoevan 47f1531
refactor: remove unused field from type
tassoevan ebff6b8
refactor: simplify filters
tassoevan d1284a3
refactor: fix `useAsyncImage` error handling
tassoevan 22c5b17
refactor: remove unnecessary type assertion
tassoevan 1390960
refactor: handle default value for route parameter
tassoevan 49124fd
refactor: review
tassoevan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
16 changes: 3 additions & 13 deletions
16
...eor/client/components/RoomIcon/OmnichannelRoomIcon/context/OmnichannelRoomIconContext.tsx
This file contains hidden or 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 hidden or 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 hidden or 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
45 changes: 22 additions & 23 deletions
45
apps/meteor/client/components/message/content/location/hooks/useAsyncImage.ts
This file contains hidden or 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,26 +1,25 @@ | ||
| import { useEffect } from 'react'; | ||
| import { useQuery } from '@tanstack/react-query'; | ||
|
|
||
| import { useAsyncState } from '../../../../../hooks/useAsyncState'; | ||
| export const useAsyncImage = (src: string | undefined) => { | ||
| return useQuery({ | ||
| queryKey: ['async-image', src], | ||
| queryFn: () => | ||
| new Promise<string>((resolve, reject) => { | ||
| if (!src) { | ||
| reject(new Error('No src provided')); | ||
| return; | ||
| } | ||
|
|
||
| export const useAsyncImage = (src: string | undefined): string | undefined => { | ||
| const { value, resolve, reject, reset } = useAsyncState<string>(); | ||
|
|
||
| useEffect(() => { | ||
| reset(); | ||
|
|
||
| if (!src) { | ||
| return; | ||
| } | ||
|
|
||
| const image = new Image(); | ||
| image.addEventListener('load', () => { | ||
| resolve(image.src); | ||
| }); | ||
| image.addEventListener('error', (e) => { | ||
| reject(e.error); | ||
| }); | ||
| image.src = src; | ||
| }, [src, resolve, reject, reset]); | ||
|
|
||
| return value; | ||
| const image = new Image(); | ||
| image.addEventListener('load', () => { | ||
| resolve(image.src); | ||
| }); | ||
| image.addEventListener('error', () => { | ||
| reject(new Error(`Failed to load image: ${src}`)); | ||
| }); | ||
| image.src = src; | ||
| }), | ||
| enabled: Boolean(src), | ||
| retry: false, | ||
| }); | ||
| }; |
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
apps/meteor/client/hooks/lists/useScrollableMessageList.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.