Page MenuHomePhabricator

D5595.id18317.diff
No OneTemporary

D5595.id18317.diff

diff --git a/web/input/input-state-container.react.js b/web/input/input-state-container.react.js
--- a/web/input/input-state-container.react.js
+++ b/web/input/input-state-container.react.js
@@ -118,11 +118,13 @@
[threadID: string]: { [localUploadID: string]: PendingMultimediaUpload },
},
+drafts: { [threadID: string]: string },
+ +textCursorPositions: { [threadID: string]: number },
};
class InputStateContainer extends React.PureComponent<Props, State> {
state: State = {
pendingUploads: {},
drafts: {},
+ textCursorPositions: {},
};
replyCallbacks: Array<(message: string) => void> = [];
pendingThreadCreations = new Map<string, Promise<string>>();
@@ -153,6 +155,10 @@
state.pendingUploads,
props,
);
+ const textCursorPositions = InputStateContainer.reassignToRealizedThreads(
+ state.pendingUploads,
+ props,
+ );
if (!drafts && !pendingUploads) {
return null;
@@ -165,6 +171,9 @@
if (pendingUploads) {
stateUpdate.pendingUploads = pendingUploads;
}
+ if (textCursorPositions) {
+ stateUpdate.pendingUploads = textCursorPositions;
+ }
return stateUpdate;
}
@@ -451,9 +460,11 @@
createSelector(
(state: State) => state.pendingUploads[threadID],
(state: State) => state.drafts[threadID],
+ (state: State) => state.textCursorPositions[threadID],
(
pendingUploads: ?{ [localUploadID: string]: PendingMultimediaUpload },
draft: ?string,
+ textCursorPosition: ?number,
) => {
let threadPendingUploads = [];
const assignedUploads = {};
@@ -474,6 +485,7 @@
pendingUploads: threadPendingUploads,
assignedUploads,
draft: draft ? draft : '',
+ textCursorPosition: textCursorPosition ? textCursorPosition : 0,
appendFiles: (files: $ReadOnlyArray<File>) =>
this.appendFiles(threadID, files),
cancelPendingUpload: (localUploadID: string) =>
@@ -485,6 +497,8 @@
createMultimediaMessage: (localID: number, threadInfo: ThreadInfo) =>
this.createMultimediaMessage(localID, threadInfo),
setDraft: (newDraft: string) => this.setDraft(threadID, newDraft),
+ setTextCursorPosition: (newPosition: number) =>
+ this.setTextCursorPosition(threadID, newPosition),
messageHasUploadFailure: (localMessageID: string) =>
this.messageHasUploadFailure(assignedUploads[localMessageID]),
retryMultimediaMessage: (
@@ -1066,6 +1080,18 @@
});
}
+ setTextCursorPosition(threadID: string, newPosition: number) {
+ this.setState(prevState => {
+ const newThreadID = this.getRealizedOrPendingThreadID(threadID);
+ return {
+ textCursorPositions: {
+ ...prevState.textCursorPositions,
+ [newThreadID]: newPosition,
+ },
+ };
+ });
+ }
+
setProgress(
threadID: string,
localUploadID: string,
diff --git a/web/input/input-state.js b/web/input/input-state.js
--- a/web/input/input-state.js
+++ b/web/input/input-state.js
@@ -41,6 +41,7 @@
[messageID: string]: $ReadOnlyArray<PendingMultimediaUpload>,
},
draft: string,
+ textCursorPosition: number,
appendFiles: (files: $ReadOnlyArray<File>) => Promise<boolean>,
cancelPendingUpload: (localUploadID: string) => void,
sendTextMessage: (
@@ -49,6 +50,7 @@
) => Promise<void>,
createMultimediaMessage: (localID: number, threadInfo: ThreadInfo) => void,
setDraft: (draft: string) => void,
+ setTextCursorPosition: (newPosition: number) => void,
messageHasUploadFailure: (localMessageID: string) => boolean,
retryMultimediaMessage: (
localMessageID: string,

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 29, 12:26 PM (21 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2596976
Default Alt Text
D5595.id18317.diff (3 KB)

Event Timeline