Skip to content

Commit 6d4eb94

Browse files
authored
Replace deprecated MutableRefObject (#5492)
1 parent a9f6274 commit 6d4eb94

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

packages/frontend/src/components/composer/Composer.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ const Composer = forwardRef<
6161
{
6262
isContactRequest: boolean
6363
selectedChat: Type.FullChat
64-
regularMessageInputRef: React.MutableRefObject<ComposerMessageInput | null>
65-
editMessageInputRef: React.MutableRefObject<ComposerMessageInput | null>
64+
regularMessageInputRef: React.RefObject<ComposerMessageInput | null>
65+
editMessageInputRef: React.RefObject<ComposerMessageInput | null>
6666
draftState: DraftObject
6767
onSelectReplyToShortcut: ReturnType<
6868
typeof useDraft
@@ -766,7 +766,7 @@ export function useDraft(
766766
chatId: number | null,
767767
isContactRequest: boolean,
768768
canSend: boolean, // no draft needed in chats we can't send messages
769-
inputRef: React.MutableRefObject<ComposerMessageInput | null>
769+
inputRef: React.RefObject<ComposerMessageInput | null>
770770
): {
771771
draftState: DraftObject
772772
onSelectReplyToShortcut: (
@@ -1075,7 +1075,7 @@ export function useDraft(
10751075
function useMessageEditing(
10761076
accountId: number,
10771077
chatId: T.BasicChat['id'],
1078-
editMessageInputRef: React.MutableRefObject<ComposerMessageInput | null>
1078+
editMessageInputRef: React.RefObject<ComposerMessageInput | null>
10791079
) {
10801080
const tx = useTranslationFunction()
10811081
const { userFeedback } = useContext(ScreenContext)

packages/frontend/src/components/dialogs/FullscreenAvatar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ export default function FullscreenAvatar(
1616
const tx = useTranslationFunction()
1717
const { onClose, imagePath } = props
1818

19-
const resetImageZoom = useRef<(() => void) | null>(
20-
null
21-
) as React.MutableRefObject<(() => void) | null>
19+
const resetImageZoom = useRef<(() => void) | null>(null) as React.RefObject<
20+
(() => void) | null
21+
>
2222

2323
const saveAs = () => {
2424
runtime.downloadFile(imagePath, basename(imagePath))

packages/frontend/src/components/dialogs/FullscreenMedia.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ export default function FullscreenMedia(props: Props & DialogProps) {
4949
const { onClose } = props
5050

5151
const [msg, setMsg] = useState(props.msg)
52-
const resetImageZoom = useRef<(() => void) | null>(
53-
null
54-
) as React.MutableRefObject<(() => void) | null>
52+
const resetImageZoom = useRef<(() => void) | null>(null) as React.RefObject<
53+
(() => void) | null
54+
>
5555
const previousNextMessageId = useRef<[number | null, number | null]>([
5656
null,
5757
null,

packages/frontend/src/components/helpers/hooks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MutableRefObject, useEffect, useRef, useState } from 'react'
1+
import { RefObject, useEffect, useRef, useState } from 'react'
22
import { debounce } from 'debounce'
33

44
/** debounce workaround so it can be useful in useFunctions that are used from multiple places at once
@@ -26,7 +26,7 @@ export function useRefLock(): {
2626
setLock: (lock: boolean) => {
2727
return (lockRef.current = lock)
2828
},
29-
}) as MutableRefObject<any>
29+
}) as RefObject<any>
3030

3131
return stableRef.current
3232
}

packages/frontend/src/components/message/MessageList.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, {
22
useRef,
33
useCallback,
44
useLayoutEffect,
5-
MutableRefObject,
5+
RefObject,
66
useEffect,
77
useState,
88
useMemo,
@@ -219,7 +219,7 @@ export default function MessageList({ accountId, chat, refComposer }: Props) {
219219
}
220220
})
221221
}
222-
const unreadMessageInViewIntersectionObserver: MutableRefObject<IntersectionObserver> =
222+
const unreadMessageInViewIntersectionObserver: RefObject<IntersectionObserver> =
223223
useRef(
224224
new IntersectionObserver(onUnreadMessageInView, {
225225
root: null,
@@ -744,10 +744,10 @@ export const MessageListInner = React.memo(
744744
messageListItems: T.MessageListItem[]
745745
activeView: T.MessageListItem[]
746746
messageCache: { [msgId: number]: T.MessageLoadResult | undefined }
747-
messageListRef: React.MutableRefObject<HTMLDivElement | null>
747+
messageListRef: React.RefObject<HTMLDivElement | null>
748748
chat: T.FullChat
749749
loaded: boolean
750-
unreadMessageInViewIntersectionObserver: React.MutableRefObject<IntersectionObserver | null>
750+
unreadMessageInViewIntersectionObserver: React.RefObject<IntersectionObserver | null>
751751
loadMissingMessages: () => Promise<void>
752752
}) => {
753753
const tx = useTranslationFunction()

packages/frontend/src/components/message/MessageWrapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type RenderMessageProps = {
1212
chat: T.FullChat
1313
message: T.Message
1414
conversationType: ConversationType
15-
unreadMessageInViewIntersectionObserver: React.MutableRefObject<IntersectionObserver | null>
15+
unreadMessageInViewIntersectionObserver: React.RefObject<IntersectionObserver | null>
1616
}
1717

1818
const log = getLogger('renderer/message/MessageWrapper')

packages/frontend/src/contexts/ChatContext.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ActionEmitter, KeybindAction } from '../keybindings'
44
import { markChatAsSeen, saveLastChatId } from '../backend/chat'
55
import { BackendRemote } from '../backend-com'
66

7-
import type { MutableRefObject, PropsWithChildren } from 'react'
7+
import type { RefObject, PropsWithChildren } from 'react'
88
import type { T } from '@deltachat/jsonrpc-client'
99
import { useRpcFetch } from '../hooks/useFetch'
1010
import { getLogger } from '@deltachat-desktop/shared/logger'
@@ -63,7 +63,7 @@ type Props = {
6363
* the ref gives us a handle to reset the component without moving it up in the hierarchy.
6464
* a class component would give us the option to call methods on the component,
6565
* but we are using a functional component here so we need to pass this as a property instead*/
66-
unselectChatRef: MutableRefObject<UnselectChat | null>
66+
unselectChatRef: RefObject<UnselectChat | null>
6767
}
6868

6969
export const ChatContext = React.createContext<ChatContextValue | null>(null)

0 commit comments

Comments
 (0)