-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Pay the debt of some TODO comments (#30338)
- Loading branch information
Showing
21 changed files
with
161 additions
and
191 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
13 changes: 7 additions & 6 deletions
13
apps/meteor/client/components/GenericTable/GenericTable.tsx
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
18 changes: 0 additions & 18 deletions
18
apps/meteor/client/components/connectionStatus/ConnectionStatusBar.styles.css
This file was deleted.
Oops, something went wrong.
97 changes: 34 additions & 63 deletions
97
apps/meteor/client/components/connectionStatus/ConnectionStatusBar.tsx
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
39 changes: 39 additions & 0 deletions
39
apps/meteor/client/components/connectionStatus/useReconnectCountdown.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,39 @@ | ||
import { useEffect, useRef, useState } from 'react'; | ||
|
||
const getReconnectCountdown = (retryTime: number): number => { | ||
const timeDiff = retryTime - Date.now(); | ||
return (timeDiff > 0 && Math.round(timeDiff / 1000)) || 0; | ||
}; | ||
|
||
export const useReconnectCountdown = ( | ||
retryTime: number | undefined, | ||
status: 'connected' | 'connecting' | 'failed' | 'waiting' | 'offline', | ||
): number => { | ||
const reconnectionTimerRef = useRef<ReturnType<typeof setInterval>>(); | ||
const [reconnectCountdown, setReconnectCountdown] = useState(() => (retryTime ? getReconnectCountdown(retryTime) : 0)); | ||
|
||
useEffect(() => { | ||
if (status === 'waiting') { | ||
if (reconnectionTimerRef.current) { | ||
return; | ||
} | ||
|
||
reconnectionTimerRef.current = setInterval(() => { | ||
retryTime && setReconnectCountdown(getReconnectCountdown(retryTime)); | ||
}, 500); | ||
return; | ||
} | ||
|
||
reconnectionTimerRef.current && clearInterval(reconnectionTimerRef.current); | ||
reconnectionTimerRef.current = undefined; | ||
}, [retryTime, status]); | ||
|
||
useEffect( | ||
() => (): void => { | ||
reconnectionTimerRef.current && clearInterval(reconnectionTimerRef.current); | ||
}, | ||
[], | ||
); | ||
|
||
return reconnectCountdown; | ||
}; |
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
20 changes: 11 additions & 9 deletions
20
apps/meteor/client/components/message/content/attachments/FileAttachment.tsx
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,23 +1,25 @@ | ||
import type { FileAttachmentProps } from '@rocket.chat/core-typings'; | ||
import { isFileAudioAttachment, isFileImageAttachment, isFileVideoAttachment } from '@rocket.chat/core-typings'; | ||
import type { FC } from 'react'; | ||
import { type FileAttachmentProps, isFileAudioAttachment, isFileImageAttachment, isFileVideoAttachment } from '@rocket.chat/core-typings'; | ||
import React from 'react'; | ||
|
||
import { AudioAttachment } from './file/AudioAttachment'; | ||
import { GenericFileAttachment } from './file/GenericFileAttachment'; | ||
import { ImageAttachment } from './file/ImageAttachment'; | ||
import { VideoAttachment } from './file/VideoAttachment'; | ||
import AudioAttachment from './file/AudioAttachment'; | ||
import GenericFileAttachment from './file/GenericFileAttachment'; | ||
import ImageAttachment from './file/ImageAttachment'; | ||
import VideoAttachment from './file/VideoAttachment'; | ||
|
||
export const FileAttachment: FC<FileAttachmentProps & { id: string | undefined }> = (attachment) => { | ||
const FileAttachment = (attachment: FileAttachmentProps) => { | ||
if (isFileImageAttachment(attachment)) { | ||
return <ImageAttachment {...attachment} />; | ||
} | ||
|
||
if (isFileAudioAttachment(attachment)) { | ||
return <AudioAttachment {...attachment} />; | ||
} | ||
|
||
if (isFileVideoAttachment(attachment)) { | ||
return <VideoAttachment {...attachment} />; | ||
} | ||
|
||
return <GenericFileAttachment {...(attachment as any)} />; // TODO: fix this | ||
return <GenericFileAttachment {...attachment} />; | ||
}; | ||
|
||
export default FileAttachment; |
Oops, something went wrong.