-
Notifications
You must be signed in to change notification settings - Fork 144
Fix/UI kit 3053/modify issues on voice message #405
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
HoonBaek
merged 91 commits into
develop/Voice-message
from
fix/UIKIT-3053/Modify-issues-on-voice-message
Feb 22, 2023
Merged
Changes from all commits
Commits
Show all changes
91 commits
Select commit
Hold shift + click to select a range
ad84356
Create ProgressBar component
HoonBaek 899e3ca
Create UI component PlaybackTime
HoonBaek 1742d72
Modify ProgressBar and update snapshot
HoonBaek 463d882
Create UI comp VoiceMessageInput
HoonBaek 59fb8c1
Create VoiceMessageItemBody component
HoonBaek e8b0392
Change the playback time unit to millisec
HoonBaek c208bb4
Add new icon color PRIMARY_2
HoonBaek a99e969
Accept labelColor in the PlaybackTime comp
HoonBaek 5fd0d39
Apply color type to the ProgressBar comp
HoonBaek 04a049a
Set progress bar height to 40px on the VoiceMessageInput comp
HoonBaek 9a4845b
Use seconds unit in VoicePlayer
HoonBaek 28385a0
Remove the empty storybook of PlayTime comp
HoonBaek 249fb79
fix: Apply string set into the moderation section (#391)
HoonBaek e1090a4
fix: Use same word break and URL activation logic on messages (#392)
HoonBaek b605b6e
fix: Migrate the outdated ChannelListQuery interface (#393)
HoonBaek 489a513
Set height of ProgressBar in the storybook sample
HoonBaek ff065dd
Put string value to enum definition
HoonBaek 4130e41
Add props for global option of voice recoring
HoonBaek a12c5d8
Create VoiceMessageInputWrapper component
HoonBaek 33da86b
Modify the VoiceMessageInput clear state logic
HoonBaek 13dc596
Add props for voice message to the MessageInput component
HoonBaek f157bb3
Modify the playback time calculation logic
HoonBaek cd5d38a
Send voice message on Channel
HoonBaek 04ff001
Create useSendVoiceMessageCallback hook in Channel
HoonBaek 52ed1c2
Put VoiceRecorderProvider and VoicePlayerProvider into SendbirdProvider
HoonBaek 6f73f03
Add type definitions for voice message
HoonBaek 9a2dc2d
Apply voice message to the MessageContent
HoonBaek 8e30c93
Appear the border radius of VoiceMessageItemBody
HoonBaek dfcd878
Set file name, Voice message when recording voice
HoonBaek 7f9d133
Apply audio duration to VoiceMessageInput and VoiceMessageItem
HoonBaek efcebd0
Rename file name VoiceMessageWrapper to VoiceMessageInputWrapper
HoonBaek 67fdd20
Stop recording automatically when clicking send button
HoonBaek d0fafb9
Apply VoiceMessageInput and VoiceMessageItem to the Thread
HoonBaek 746ab93
Activate ProgressBar in play mode of VoiceMessageInput
HoonBaek 547349b
Modify the VoiceMessageInput ProgressBar progress frame
HoonBaek ceac501
Stop recording when out of maxRecordingTime
HoonBaek a7d5351
Change the voice message internal protocol
HoonBaek 301717f
Add a file extension to the file name when sending voice message
HoonBaek 51067e8
Add new icon AudioOnLined & Migrate Icon util functions to TS
HoonBaek 412ff5d
Apply the audio icon into the MessageInput component
HoonBaek c876648
Modify PlaybackTime comp to round down with time
HoonBaek 18242c7
Replace the AudioOnLined icon with same width and height size
HoonBaek c77d4f4
Add a storybook of PlaybackTime component
HoonBaek 28c8414
Make playback time to count down when playing audio
HoonBaek cdd7f19
Remove unexpected use of file extension & Add missing return type
HoonBaek 51ebf0a
Disable the send button by minRecordingTime of VoiceMessageInput
HoonBaek 045f2b7
Apply minRecordingTime to the VoiceMessageInput behavior
HoonBaek 2758d05
Add string set for voice message input disabled status
HoonBaek 1e342c8
Manage the voice message disabled state
HoonBaek be4d4e0
Provide context recordingLimit from VoiceRecorderProvider
HoonBaek 53e3750
Migrate VoiceMessageInput comp to have only UI functions
HoonBaek 4949948
Rename useVoiceRecorder hook to VoiceRecorder
HoonBaek 30b7b9c
Rename useVoicePlayer hook to VoicePlayer
HoonBaek 05e3696
Refactor VoiceRecorder and VoicePlayer to use globally
HoonBaek c41f885
Remove legacy files of VoicePlayer
HoonBaek cf30c7b
Check in and out using voice player in Channel and Thread
HoonBaek e232db9
Rename VoiceMessageInputControlTypes to VoiceMessageInputStatus
HoonBaek 7953d04
Set the playbackTime to 0 when playing is finished
HoonBaek d432e3b
Modify VoiceMessageInput component using the refactored voice recorde…
HoonBaek bdb1501
Apply changed mimeType policy to the VoiceMessageItemBody component
HoonBaek 8a2b5c6
Put voice message item into the ParentMessageInfoItem
HoonBaek 1244c05
Change the on record flicker time to 1sec
HoonBaek 7b04862
Modify the text overflow issue in the text message item
HoonBaek a682c4a
Fix the voice message width
HoonBaek 36eebed
Apply OpenChannel to the storybook sample
HoonBaek f993e66
Apply minRecordTime to the VoiceMessageInput comp
HoonBaek af8f4d0
Fix: Make a recorded file playable in iOS by encoding to mp3
HoonBaek 6629936
Install lamejs for encoding audio file to mp3 in local
HoonBaek 983f91d
Chore: make the code prettier in WebAudioUtils file
HoonBaek ce50f03
Refactor logic of voice player to manage the player events
HoonBaek bc6605c
Remove legacy of previous voice player logic
HoonBaek 52d09e0
Include metaArray when fetching message list
HoonBaek 1b916ac
Fix: entire message list is re-rendered when one message property cha…
HoonBaek f0bf35e
Add string set 'Voice Message' and apply to ChannelList, QuoteMessage…
HoonBaek 07cd116
Add interface to pause with groupKey of voice player
HoonBaek 241a0b2
Reverse the on record flicker animation
HoonBaek 23f3cfe
Remove the legacy logic check in/out channel in storybook sample
HoonBaek ed2aed0
Install lamejs for transcoding audio file to mp3
HoonBaek 65d40b8
Merge branch 'develop/Voice-message' into fix/UIKIT-3053/Modify-issue…
HoonBaek c545c93
Use reply and thread in broadcast channel
HoonBaek fe2f7d3
Add option of voice message in the sample app
HoonBaek c9fb603
Modify sendbird RestrictionType error
HoonBaek 662118f
feat: options to render icons on MessageInput (#406)
220a001
Export isVoiceMessage util function
HoonBaek eb388ae
Add type definitions for voice message & Export the modules
HoonBaek 5edba64
Add new line to the end of file, voicePlayerEvent
HoonBaek bd32fd0
Convert a negative number to natural number in PlaybackTime comp
HoonBaek 31ef428
Remove unnecessary lines and rename a variable
HoonBaek dcaf946
Modify the type of the return type of setInterval
HoonBaek e4f4a4e
Make variables to const within voice message feature
HoonBaek 8aada4e
Rename const variables name to be capitalized
HoonBaek 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import React, { createContext, useCallback, useContext, useState } from 'react'; | ||
import { | ||
VoicePlayerEvent, | ||
VoicePlayerEventParams, | ||
VoicePlayerEventStorage, | ||
VoicePlayerEventTypes, | ||
} from './voicePlayerEvent'; | ||
|
||
const noop = () => {/* noop */ }; | ||
|
||
// VoicePlayerProvider interface | ||
export interface VoicePlayerProps { | ||
children: React.ReactElement; | ||
} | ||
export interface VoicePlayerPlayProps { | ||
audioFile: File; | ||
playbackTime: number; | ||
groupKey: string; | ||
} | ||
export interface VoicePlayerContext { | ||
play: (props: VoicePlayerPlayProps) => void; | ||
stop: (groupKey?: string) => void; | ||
addEventHandler: (props: VoicePlayerEvent) => void; | ||
removeEventHandler: (groupKey: string, handlerId: string) => void; | ||
} | ||
|
||
const VoicePlayerContext = createContext<VoicePlayerContext>({ | ||
play: noop, | ||
stop: noop, | ||
addEventHandler: noop, | ||
removeEventHandler: noop, | ||
}); | ||
|
||
export const VoicePlayerProvider = ({ | ||
children, | ||
}: VoicePlayerProps): React.ReactElement => { | ||
const [eventStorage, setEventStorage] = useState<VoicePlayerEventStorage>({}); | ||
const [currentPlayer, setAudioPlayer] = useState<HTMLAudioElement>(null); | ||
const [currentGroupKey, setCurrentGroupKey] = useState<string>(''); | ||
|
||
const addEventHandler = (event: VoicePlayerEvent): void => { | ||
HoonBaek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const { groupKey } = event; | ||
setEventStorage((storage) => { | ||
if (!storage?.[groupKey]) { | ||
storage[groupKey] = []; | ||
} | ||
storage?.[groupKey].push(event); | ||
return storage; | ||
}); | ||
}; | ||
const removeEventHandler = (groupKey: string, handlerId: string): void => { | ||
setEventStorage((storage) => { | ||
if (!Array.isArray(storage?.[groupKey])) { | ||
return storage; | ||
} | ||
return ({ | ||
...storage, | ||
[groupKey]: storage[groupKey].filter(({ id }) => id !== handlerId), | ||
}); | ||
}); | ||
}; | ||
const triggerEvent = useCallback((eventType: VoicePlayerEventTypes, payload: VoicePlayerEventParams): void => { | ||
const { groupKey } = payload; | ||
if (Array.isArray(eventStorage?.[groupKey])) { | ||
eventStorage[groupKey].map((playerEvent) => { | ||
playerEvent?.[eventType]?.(payload); | ||
}); | ||
} | ||
}, [eventStorage]); | ||
const clearStates = (): void => { | ||
setAudioPlayer(null); | ||
setCurrentGroupKey(''); | ||
}; | ||
|
||
const stop = useCallback((groupKey?: string): void => { | ||
if (groupKey === undefined || (groupKey?.length > 0 && groupKey === currentGroupKey)) { | ||
currentPlayer?.pause(); | ||
clearStates(); | ||
} | ||
}, [currentPlayer, currentGroupKey]); | ||
const play = ({ | ||
audioFile, | ||
playbackTime, | ||
groupKey, | ||
}: VoicePlayerPlayProps): void => { | ||
if (currentPlayer || currentGroupKey) { | ||
stop(); | ||
} | ||
|
||
const audioPlayer = new Audio(URL?.createObjectURL?.(audioFile)); | ||
audioPlayer.currentTime = playbackTime; | ||
audioPlayer.volume = 1; | ||
audioPlayer.loop = false; | ||
audioPlayer.onplaying = () => { | ||
triggerEvent(VoicePlayerEventTypes.STARTED, { | ||
groupKey, | ||
playbackTime: audioPlayer?.currentTime, | ||
duration: audioPlayer?.duration, | ||
}); | ||
}; | ||
audioPlayer.onpause = () => { | ||
triggerEvent(VoicePlayerEventTypes.STOPPED, { | ||
groupKey, | ||
playbackTime: audioPlayer?.currentTime, | ||
duration: audioPlayer?.duration, | ||
}); | ||
}; | ||
audioPlayer.ontimeupdate = () => { | ||
triggerEvent(VoicePlayerEventTypes.TIME_UPDATED, { | ||
groupKey, | ||
playbackTime: audioPlayer?.currentTime, | ||
duration: audioPlayer?.duration, | ||
}); | ||
}; | ||
audioPlayer?.play(); | ||
setAudioPlayer(audioPlayer); | ||
setCurrentGroupKey(groupKey); | ||
}; | ||
|
||
return ( | ||
<VoicePlayerContext.Provider value={{ | ||
play, | ||
stop, | ||
addEventHandler, | ||
removeEventHandler, | ||
}}> | ||
{children} | ||
</VoicePlayerContext.Provider> | ||
); | ||
}; | ||
|
||
export const useVoicePlayerContext = (): VoicePlayerContext => useContext(VoicePlayerContext); |
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.