[FIX] Read receipts showing first messages of the room as read even if not read by everyone (#24508)
Co-authored-by: dougfabris <devfabris@gmail.com>pull/24532/head
parent
a1095a464b
commit
9fd4c04d74
@ -1,24 +0,0 @@ |
||||
import moment from 'moment'; |
||||
import { useCallback } from 'react'; |
||||
|
||||
import { useSetting } from '../contexts/SettingsContext'; |
||||
import { useUserPreference } from '../contexts/UserContext'; |
||||
|
||||
export const useFormatDateAndTime = () => { |
||||
const clockMode = useUserPreference('clockMode', false); |
||||
const format = useSetting('Message_TimeAndDateFormat'); |
||||
|
||||
return useCallback( |
||||
(time) => { |
||||
switch (clockMode) { |
||||
case 1: |
||||
return moment(time).format('MMMM D, Y h:mm A'); |
||||
case 2: |
||||
return moment(time).format('MMMM D, Y H:mm'); |
||||
default: |
||||
return moment(time).format(format); |
||||
} |
||||
}, |
||||
[clockMode, format], |
||||
); |
||||
}; |
||||
@ -0,0 +1,29 @@ |
||||
import moment, { MomentInput } from 'moment'; |
||||
import { useCallback } from 'react'; |
||||
|
||||
import { useSetting } from '../contexts/SettingsContext'; |
||||
import { useUserPreference } from '../contexts/UserContext'; |
||||
|
||||
type UseFormatDateAndTimeParams = { |
||||
withSeconds?: boolean; |
||||
}; |
||||
|
||||
export const useFormatDateAndTime = ({ withSeconds }: UseFormatDateAndTimeParams = {}): ((input: MomentInput) => string) => { |
||||
const clockMode = useUserPreference('clockMode'); |
||||
const format = useSetting('Message_TimeAndDateFormat') as string; |
||||
|
||||
return useCallback( |
||||
(time) => { |
||||
switch (clockMode) { |
||||
case 1: |
||||
return moment(time).format(withSeconds ? 'MMMM D, Y h:mm:ss A' : 'MMMM D, Y h:mm A'); |
||||
case 2: |
||||
return moment(time).format(withSeconds ? 'MMMM D, Y H:mm:ss' : 'MMMM D, Y H:mm'); |
||||
|
||||
default: |
||||
return moment(time).format(withSeconds ? 'L LTS' : format); |
||||
} |
||||
}, |
||||
[clockMode, format, withSeconds], |
||||
); |
||||
}; |
||||
Loading…
Reference in new issue