Skip to content

Commit be1976d

Browse files
authored
fix message drop (keybase#25189)
1 parent 7d41adf commit be1976d

7 files changed

Lines changed: 126 additions & 81 deletions

File tree

‎shared/chat/conversation/list-area/index.native.tsx‎

Lines changed: 22 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as Container from '../../../util/container'
22
import * as Chat2Gen from '../../../actions/chat2-gen'
3-
import * as RouteTreeGen from '../../../actions/route-tree-gen'
43
import * as Constants from '../../../constants/chat2'
54
import * as Kb from '../../../common-adapters/mobile.native'
65
import * as React from 'react'
@@ -15,7 +14,6 @@ import type {ItemType} from '.'
1514
import {mobileTypingContainerHeight} from '../input-area/normal/typing'
1615
import * as Hooks from './hooks'
1716
import sortedIndexOf from 'lodash/sortedIndexOf'
18-
import DropView, {type DropItems} from '../../../common-adapters/drop-view.native'
1917

2018
// Bookkeep whats animating so it finishes and isn't replaced, if we've animated it we keep the key and use null
2119
const animatingMap = new Map<string, null | React.ReactElement>()
@@ -299,70 +297,30 @@ const ConversationList = React.memo(function ConversationList(p: {
299297
[conversationIDKey]
300298
)
301299

302-
const dispatch = Container.useDispatch()
303-
const onDropped = React.useCallback(
304-
(items: DropItems) => {
305-
const {attach, texts} = items.reduce(
306-
(obj, i) => {
307-
const {texts, attach} = obj
308-
if (i.content) {
309-
texts.push(i.content)
310-
} else if (i.originalPath) {
311-
attach.push({outboxID: null, path: i.originalPath})
312-
}
313-
return obj
314-
},
315-
{attach: new Array<{outboxID: null; path: string}>(), texts: new Array<string>()}
316-
)
317-
318-
if (texts.length) {
319-
dispatch(
320-
Chat2Gen.createSetUnsentText({
321-
conversationIDKey,
322-
text: new Container.HiddenString(texts.join('\r')),
323-
})
324-
)
325-
}
326-
327-
if (attach.length) {
328-
dispatch(
329-
RouteTreeGen.createNavigateAppend({
330-
path: [
331-
{props: {conversationIDKey, pathAndOutboxIDs: attach}, selected: 'chatAttachmentGetTitles'},
332-
],
333-
})
334-
)
335-
}
336-
},
337-
[dispatch, conversationIDKey]
338-
)
339-
340300
return (
341301
<Kb.ErrorBoundary>
342-
<DropView style={styles.drop} onDropped={onDropped}>
343-
<Kb.Box style={styles.container}>
344-
<Kb.NativeFlatList
345-
ListHeaderComponent={listHeaderComponent}
346-
ListFooterComponent={listFooterComponent}
347-
overScrollMode="never"
348-
contentContainerStyle={styles.contentContainer}
349-
data={messageOrdinals}
350-
inverted={true}
351-
renderItem={renderItem}
352-
maintainVisibleContentPosition={maintainVisibleContentPosition}
353-
viewabilityConfigCallbackPairs={viewabilityConfigCallbackPairsRef.current}
354-
keyboardDismissMode="on-drag"
355-
keyboardShouldPersistTaps="handled"
356-
keyExtractor={keyExtractor}
357-
// Limit the number of pages rendered ahead of time (which also limits attachment previews loaded)
358-
windowSize={5}
359-
ref={listRef}
360-
onScrollToIndexFailed={onScrollToIndexFailed}
361-
removeClippedSubviews={Styles.isAndroid}
362-
/>
363-
{jumpToRecent}
364-
</Kb.Box>
365-
</DropView>
302+
<Kb.Box style={styles.container}>
303+
<Kb.NativeFlatList
304+
ListHeaderComponent={listHeaderComponent}
305+
ListFooterComponent={listFooterComponent}
306+
overScrollMode="never"
307+
contentContainerStyle={styles.contentContainer}
308+
data={messageOrdinals}
309+
inverted={true}
310+
renderItem={renderItem}
311+
maintainVisibleContentPosition={maintainVisibleContentPosition}
312+
viewabilityConfigCallbackPairs={viewabilityConfigCallbackPairsRef.current}
313+
keyboardDismissMode="on-drag"
314+
keyboardShouldPersistTaps="handled"
315+
keyExtractor={keyExtractor}
316+
// Limit the number of pages rendered ahead of time (which also limits attachment previews loaded)
317+
windowSize={5}
318+
ref={listRef}
319+
onScrollToIndexFailed={onScrollToIndexFailed}
320+
removeClippedSubviews={Styles.isAndroid}
321+
/>
322+
{jumpToRecent}
323+
</Kb.Box>
366324
</Kb.ErrorBoundary>
367325
)
368326
})
@@ -375,7 +333,6 @@ const styles = Styles.styleSheetCreate(
375333
paddingBottom: 0,
376334
paddingTop: mobileTypingContainerHeight,
377335
},
378-
drop: {flexGrow: 1},
379336
} as const)
380337
)
381338

‎shared/chat/conversation/normal/index.native.tsx‎

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import * as Constants from '../../../constants/chat2'
2+
import * as Chat2Gen from '../../../actions/chat2-gen'
3+
import * as RouteTreeGen from '../../../actions/route-tree-gen'
24
import * as WaitingConstants from '../../../constants/waiting'
35
import * as Container from '../../../util/container'
46
import * as Kb from '../../../common-adapters/mobile.native'
57
import * as React from 'react'
68
import * as Styles from '../../../styles'
9+
import DropView, {type DropItems} from '../../../common-adapters/drop-view.native'
710
import Banner from '../bottom-banner/container'
811
import InputArea from '../input-area/container'
912
import InvitationToBlock from '../../blocking/invitation-to-block'
@@ -34,6 +37,7 @@ const LoadingLine = (p: {conversationIDKey: Types.ConversationIDKey}) => {
3437
}
3538

3639
const Conversation = React.memo(function Conversation(props: Props) {
40+
const {conversationIDKey} = props
3741
const [maxInputArea, setMaxInputArea] = React.useState<number | undefined>(undefined)
3842
const onLayout = React.useCallback((e: LayoutEvent) => {
3943
setMaxInputArea(e.nativeEvent.layout.height)
@@ -42,44 +46,86 @@ const Conversation = React.memo(function Conversation(props: Props) {
4246
const innerComponent = (
4347
<Kb.BoxGrow onLayout={onLayout}>
4448
<Kb.Box2 direction="vertical" fullWidth={true} style={styles.innerContainer}>
45-
<ThreadLoadStatus conversationIDKey={props.conversationIDKey} />
46-
<PinnedMessage conversationIDKey={props.conversationIDKey} />
49+
<ThreadLoadStatus conversationIDKey={conversationIDKey} />
50+
<PinnedMessage conversationIDKey={conversationIDKey} />
4751
<ListArea
4852
requestScrollToBottomRef={props.requestScrollToBottomRef}
4953
requestScrollDownRef={props.requestScrollDownRef}
5054
requestScrollUpRef={props.requestScrollUpRef}
5155
onFocusInput={props.onFocusInput}
52-
conversationIDKey={props.conversationIDKey}
56+
conversationIDKey={conversationIDKey}
5357
/>
54-
<LoadingLine conversationIDKey={props.conversationIDKey} />
58+
<LoadingLine conversationIDKey={conversationIDKey} />
5559
</Kb.Box2>
56-
<InvitationToBlock conversationID={props.conversationIDKey} />
57-
<Banner conversationIDKey={props.conversationIDKey} />
60+
<InvitationToBlock conversationID={conversationIDKey} />
61+
<Banner conversationIDKey={conversationIDKey} />
5862
<InputArea
5963
focusInputCounter={props.focusInputCounter}
6064
jumpToRecent={props.jumpToRecent}
6165
onRequestScrollDown={props.onRequestScrollDown}
6266
onRequestScrollToBottom={props.onRequestScrollToBottom}
6367
onRequestScrollUp={props.onRequestScrollUp}
64-
conversationIDKey={props.conversationIDKey}
68+
conversationIDKey={conversationIDKey}
6569
maxInputArea={maxInputArea}
6670
/>
6771
</Kb.BoxGrow>
6872
)
73+
74+
const dispatch = Container.useDispatch()
75+
const onDropped = React.useCallback(
76+
(items: DropItems) => {
77+
const {attach, texts} = items.reduce(
78+
(obj, i) => {
79+
const {texts, attach} = obj
80+
if (i.content) {
81+
texts.push(i.content)
82+
} else if (i.originalPath) {
83+
attach.push({outboxID: null, path: i.originalPath})
84+
}
85+
return obj
86+
},
87+
{attach: new Array<{outboxID: null; path: string}>(), texts: new Array<string>()}
88+
)
89+
90+
if (texts.length) {
91+
dispatch(
92+
Chat2Gen.createSetUnsentText({
93+
conversationIDKey,
94+
text: new Container.HiddenString(texts.join('\r')),
95+
})
96+
)
97+
}
98+
99+
if (attach.length) {
100+
dispatch(
101+
RouteTreeGen.createNavigateAppend({
102+
path: [
103+
{props: {conversationIDKey, pathAndOutboxIDs: attach}, selected: 'chatAttachmentGetTitles'},
104+
],
105+
})
106+
)
107+
}
108+
},
109+
[dispatch, conversationIDKey]
110+
)
111+
69112
return (
70113
<Kb.Box style={styles.innerContainer}>
71-
<Kb.Box2 direction="vertical" fullWidth={true} fullHeight={true}>
72-
{props.threadLoadedOffline && <Offline />}
73-
{innerComponent}
74-
</Kb.Box2>
75-
<PortalHost name="convOverlay" />
114+
<DropView style={styles.dropView} onDropped={onDropped}>
115+
<Kb.Box2 direction="vertical" fullWidth={true} fullHeight={true}>
116+
{props.threadLoadedOffline && <Offline />}
117+
{innerComponent}
118+
</Kb.Box2>
119+
<PortalHost name="convOverlay" />
120+
</DropView>
76121
</Kb.Box>
77122
)
78123
})
79124

80125
const styles = Styles.styleSheetCreate(
81126
() =>
82127
({
128+
dropView: {flexGrow: 1},
83129
innerContainer: {
84130
flex: 1,
85131
position: 'relative',

‎shared/ios/Keybase.xcodeproj/project.pbxproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@
573573
);
574574
runOnlyForDeploymentPostprocessing = 0;
575575
shellPath = /bin/sh;
576-
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n";
576+
shellScript = "export ____SKIP_BUNDLING=1\nexport NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh\n";
577577
showEnvVarsInLog = 0;
578578
};
579579
/* End PBXShellScriptBuildPhase section */

‎shared/ios/Keybase/ItemProviderHelper.m‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ @implementation ItemProviderHelper
2424

2525
- (void) completeProcessingItemAlreadyInMainThread {
2626
if(--self.unprocessed > 0) { return; }
27-
dispatch_async(dispatch_get_main_queue(), ^{
2827
[self writeManifest];
2928
self.completionHandler();
30-
});
3129
}
3230

3331
- (NSURL *)getIncomingShareFolder {

‎shared/ios/Podfile‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ target 'Keybase' do
2323
post_install do |installer|
2424
react_native_post_install(installer)
2525
__apply_Xcode_12_5_M1_post_install_workaround(installer)
26+
27+
# fix pods xcode 14 losing signing team
28+
installer.pods_project.targets.each do |target|
29+
target.build_configurations.each do |config|
30+
config.build_settings['CODE_SIGN_IDENTITY'] = ''
31+
end
32+
end
2633
end
2734
end
2835

‎shared/ios/Podfile.lock‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,6 @@ SPEC CHECKSUMS:
704704
Yoga: 90dcd029e45d8a7c1ff059e8b3c6612ff409061a
705705
ZXingObjC: fdbb269f25dd2032da343e06f10224d62f537bdb
706706

707-
PODFILE CHECKSUM: 10e5305767c71eb1180c627a4184905b4adda954
707+
PODFILE CHECKSUM: 3c1dad393b36bbb6b367f4849b009561cb49f9ec
708708

709709
COCOAPODS: 1.11.3

‎shared/patches/@mattermost+react-native-paste-input+0.5.0.patch‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,43 @@ index 73ed099..51b082c 100644
4747
}
4848
}
4949

50+
diff --git a/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.h b/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.h
51+
index be73123..900fd06 100644
52+
--- a/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.h
53+
+++ b/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.h
54+
@@ -10,7 +10,7 @@
55+
56+
NS_ASSUME_NONNULL_BEGIN
57+
58+
-@interface PasteInputView : RCTMultilineTextInputView
59+
+@interface PasteInputView : RCTMultilineTextInputView<UIDropInteractionDelegate>
60+
@property (nonatomic, assign) BOOL disableCopyPaste;
61+
@property (nonatomic, copy, nullable) RCTDirectEventBlock onPaste;
62+
@end
63+
diff --git a/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.m b/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.m
64+
index 4d3b464..0fe800e 100644
65+
--- a/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.m
66+
+++ b/node_modules/@mattermost/react-native-paste-input/ios/PasteInputView.m
67+
@@ -24,6 +24,7 @@
68+
_backedTextInputView = [[PasteInputTextView alloc] initWithFrame:self.bounds];
69+
_backedTextInputView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
70+
_backedTextInputView.textInputDelegate = self;
71+
+ _backedTextInputView.interactions = @[[[UIDropInteraction alloc] initWithDelegate:self]];
72+
73+
[self addSubview:_backedTextInputView];
74+
}
75+
@@ -31,6 +32,11 @@
76+
return self;
77+
}
78+
79+
+- (BOOL)dropInteraction:(UIDropInteraction *)interaction canHandleSession:(id<UIDropSession>)session
80+
+{
81+
+ return NO;
82+
+}
83+
+
84+
- (id<RCTBackedTextInputViewProtocol>)backedTextInputView
85+
{
86+
return _backedTextInputView;
5087
diff --git a/node_modules/@mattermost/react-native-paste-input/ios/UIPasteboard+GetImageInfo.m b/node_modules/@mattermost/react-native-paste-input/ios/UIPasteboard+GetImageInfo.m
5188
index df52bb7..a4424b8 100644
5289
--- a/node_modules/@mattermost/react-native-paste-input/ios/UIPasteboard+GetImageInfo.m

0 commit comments

Comments
 (0)