Changeset View
Changeset View
Standalone View
Standalone View
web/chat/edit-message-provider.js
// @flow | // @flow | ||||
import invariant from 'invariant'; | import invariant from 'invariant'; | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import ModalOverlay from 'lib/components/modal-overlay.react.js'; | import ModalOverlay from 'lib/components/modal-overlay.react.js'; | ||||
import type { ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js'; | import type { ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js'; | ||||
import type { ThreadInfo } from 'lib/types/thread-types'; | import type { ThreadInfo } from 'lib/types/thread-types'; | ||||
import { EditTextMessage } from './edit-text-message.react.js'; | |||||
export type ModalPosition = { | export type ModalPosition = { | ||||
+left: number, | +left: number, | ||||
+top: number, | +top: number, | ||||
+width: number, | +width: number, | ||||
+height: number, | +height: number, | ||||
}; | }; | ||||
export type EditState = { | export type EditState = { | ||||
Show All 35 Lines | const clearEditModal = React.useCallback(() => { | ||||
setEditState(null); | setEditState(null); | ||||
}, []); | }, []); | ||||
const renderEditModal = React.useCallback((newEditState: EditState): void => { | const renderEditModal = React.useCallback((newEditState: EditState): void => { | ||||
setEditState(newEditState); | setEditState(newEditState); | ||||
}, []); | }, []); | ||||
const modal = React.useMemo(() => { | const modal = React.useMemo(() => { | ||||
// TODO: Add modal | if (!editState || !editState.position) { | ||||
return null; | return null; | ||||
}, []); | } | ||||
const tooltipNode = ( | |||||
<EditTextMessage | |||||
item={editState.messageInfo} | |||||
threadInfo={editState.threadInfo} | |||||
background={false} | |||||
/> | |||||
); | |||||
const tooltipContainerStyle = { | |||||
position: 'fixed', | |||||
left: editState.position.left, | |||||
top: editState.position.top, | |||||
width: editState.position.width, | |||||
height: editState.position.height, | |||||
}; | |||||
return <div style={tooltipContainerStyle}>{tooltipNode}</div>; | |||||
}, [editState]); | |||||
const setDraft = React.useCallback( | const setDraft = React.useCallback( | ||||
(draft: ?string) => { | (draft: ?string) => { | ||||
if (!editState) { | if (!editState) { | ||||
return; | return; | ||||
} | } | ||||
setEditState({ | setEditState({ | ||||
...editState, | ...editState, | ||||
▲ Show 20 Lines • Show All 69 Lines • Show Last 20 Lines |