author int64 658 755k | date stringlengths 19 19 | timezone int64 -46,800 43.2k | hash stringlengths 40 40 | message stringlengths 5 490 | mods list | language stringclasses 20 values | license stringclasses 3 values | repo stringlengths 5 68 | original_message stringlengths 12 491 |
|---|---|---|---|---|---|---|---|---|---|
129,187 | 20.02.2019 15:30:01 | 18,000 | 82fd578c705c8d766feee0eb650b634006e5ca51 | [lib] Reducer support for sendMultimediaMessageActionTypes | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/local-id-reducer.js",
"new_path": "lib/reducers/local-id-reducer.js",
"diff": "@@ -11,6 +11,7 @@ import {\nimport { rehydrateActionType } from '../types/redux-types';\nimport {\nsendTextMessageActionTypes,\n+ sendMultimediaMessageActionTypes,\ncreateLocalMultimediaMessageActionType,\n} from '../actions/message-actions';\nimport { createLocalEntryActionType } from '../actions/entry-actions';\n@@ -21,6 +22,7 @@ export default function reduceNextLocalID(state: number, action: BaseAction) {\nnewCandidate = highestLocalIDSelector(action.payload) + 1;\n} else if (\naction.type === sendTextMessageActionTypes.started ||\n+ action.type === sendMultimediaMessageActionTypes.started ||\naction.type === createLocalEntryActionType ||\naction.type === createLocalMultimediaMessageActionType\n) {\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/reducers/message-reducer.js",
"new_path": "lib/reducers/message-reducer.js",
"diff": "@@ -69,6 +69,7 @@ import {\nfetchMessagesBeforeCursorActionTypes,\nfetchMostRecentMessagesActionTypes,\nsendTextMessageActionTypes,\n+ sendMultimediaMessageActionTypes,\nsaveMessagesActionType,\nprocessMessagesActionType,\nmessageStorePruneActionType,\n@@ -175,9 +176,9 @@ function mergeNewMessages(\n} else if (currentLocalMessageInfo && currentLocalMessageInfo.localID) {\n// If the client has a RawMessageInfo with this localID, but not with\n// the serverID, that means the message creation succeeded but the\n- // sendTextMessageActionTypes.success never got processed. We set a\n- // key in localIDsToServerIDs here to fix the messageIDs for the rest\n- // of the MessageStore too.\n+ // success action never got processed. We set a key in\n+ // localIDsToServerIDs here to fix the messageIDs for the rest of the\n+ // MessageStore too.\ninvariant(inputLocalID, \"should be set\");\nlocalIDsToServerIDs.set(inputLocalID, inputID);\nmessageInfo = {\n@@ -587,7 +588,10 @@ function reduceMessageStore(\nnewThreadInfos,\naction.type,\n);\n- } else if (action.type === sendTextMessageActionTypes.started) {\n+ } else if (\n+ action.type === sendTextMessageActionTypes.started ||\n+ action.type === sendMultimediaMessageActionTypes.started\n+ ) {\nconst { payload } = action;\nconst { localID, threadID } = payload;\ninvariant(localID, `localID should be set on ${action.type}`);\n@@ -635,7 +639,10 @@ function reduceMessageStore(\nlocal: messageStore.local,\ncurrentAsOf: messageStore.currentAsOf,\n};\n- } else if (action.type === sendTextMessageActionTypes.failed) {\n+ } else if (\n+ action.type === sendTextMessageActionTypes.failed ||\n+ action.type === sendMultimediaMessageActionTypes.failed\n+ ) {\nconst { localID } = action.payload;\nreturn {\nmessages: messageStore.messages,\n@@ -646,8 +653,11 @@ function reduceMessageStore(\n},\ncurrentAsOf: messageStore.currentAsOf,\n};\n- } else if (action.type === sendTextMessageActionTypes.success) {\n- const payload = action.payload;\n+ } else if (\n+ action.type === sendTextMessageActionTypes.success ||\n+ action.type === sendMultimediaMessageActionTypes.success\n+ ) {\n+ const { payload } = action;\nconst replaceMessageKey =\n(messageKey: string) => messageKey === payload.localID\n? payload.serverID\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/types/redux-types.js",
"new_path": "lib/types/redux-types.js",
"diff": "@@ -461,7 +461,7 @@ export type BaseAction =\n|} | {|\ntype: \"SEND_MULTIMEDIA_MESSAGE_STARTED\",\nloadingInfo: LoadingInfo,\n- payload?: void,\n+ payload: RawMultimediaMessageInfo,\n|} | {|\ntype: \"SEND_MULTIMEDIA_MESSAGE_FAILED\",\nerror: true,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Reducer support for sendMultimediaMessageActionTypes |
129,187 | 20.02.2019 15:30:18 | 18,000 | be2adff1131a4d0719e8e041b798e3973a25384e | [lib] Filter out uncommitted messageTypes.MULTIMEDIA on REHYDRATE
(Only applies to native.) | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/message-reducer.js",
"new_path": "lib/reducers/message-reducer.js",
"diff": "@@ -11,7 +11,7 @@ import {\nmessageTypes,\ndefaultNumberPerThread,\n} from '../types/message-types';\n-import type { BaseAction } from '../types/redux-types';\n+import { type BaseAction, rehydrateActionType } from '../types/redux-types';\nimport { type RawThreadInfo, threadPermissions } from '../types/thread-types';\nimport {\nupdateTypes,\n@@ -840,6 +840,43 @@ function reduceMessageStore(\n},\n},\n};\n+ } else if (action.type === rehydrateActionType) {\n+ // When starting the app on native, we filter out any local-only MULTIMEDIA\n+ // messages because the relevant context is no longer available\n+ const { messages, threads, local } = messageStore;\n+\n+ const newMessages = {};\n+ let newThreads = threads, newLocal = local;\n+ for (let messageID in messages) {\n+ const message = messages[messageID];\n+ if (message.type !== messageTypes.MULTIMEDIA || message.id) {\n+ newMessages[messageID] = message;\n+ continue;\n+ }\n+ const { threadID } = message;\n+ newThreads = {\n+ ...newThreads,\n+ [threadID]: {\n+ ...newThreads[threadID],\n+ messageIDs: newThreads[threadID].messageIDs.filter(\n+ curMessageID => curMessageID !== messageID,\n+ ),\n+ },\n+ };\n+ newLocal = _pickBy(\n+ (localInfo: LocalMessageInfo, key: string) => key !== messageID,\n+ )(newLocal);\n+ }\n+\n+ if (newThreads === threads) {\n+ return messageStore;\n+ }\n+ return {\n+ ...messageStore,\n+ messages: newMessages,\n+ threads: newThreads,\n+ local: newLocal,\n+ };\n}\nreturn messageStore;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Filter out uncommitted messageTypes.MULTIMEDIA on REHYDRATE
(Only applies to native.) |
129,187 | 20.02.2019 16:27:57 | 18,000 | 3f7e34470ea9276a81f47891a39bd8ae2656c602 | [lib] Fix accidental entity text in web MessagePreview | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -24,6 +24,7 @@ import _maxBy from 'lodash/fp/maxBy';\nimport { prettyDate } from '../utils/date-utils';\nimport { userIDsToRelativeUserInfos } from '../selectors/user-selectors';\nimport { contentStringForMediaArray } from './media-utils';\n+import { stringForUser } from './user-utils';\n// Prefers localID\nfunction messageKey(messageInfo: MessageInfo | RawMessageInfo): string {\n@@ -605,7 +606,7 @@ function messagePreviewText(\nthreadInfo: ThreadInfo,\n): string {\nif (messageInfo.type === messageTypes.MULTIMEDIA) {\n- const creator = robotextForUser(messageInfo.creator);\n+ const creator = stringForUser(messageInfo.creator);\nconst mediaContentString = contentStringForMediaArray(messageInfo.media);\nreturn `${creator} sent ${mediaContentString}`;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Fix accidental entity text in web MessagePreview |
129,187 | 20.02.2019 16:29:03 | 18,000 | e9959ee997ec10f8cdc1dce63654fe9d89e8e7c9 | [web] Actually call sendMultimediaMessage from MultimediaMessage | [
{
"change_type": "MODIFY",
"old_path": "web/chat/multimedia-message.react.js",
"new_path": "web/chat/multimedia-message.react.js",
"diff": "@@ -4,13 +4,19 @@ import {\ntype ChatMessageInfoItem,\nchatMessageItemPropType,\n} from 'lib/selectors/chat-selectors';\n-import { messageTypes } from 'lib/types/message-types';\n+import {\n+ messageTypes,\n+ type SendMessageResult,\n+ type RawMultimediaMessageInfo,\n+} from 'lib/types/message-types';\nimport {\nchatInputStatePropType,\ntype ChatInputState,\n} from './chat-input-state';\nimport type { MessagePositionInfo } from './message.react';\nimport { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\n+import type { AppState } from '../redux-setup';\n+import type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport * as React from 'react';\nimport invariant from 'invariant';\n@@ -18,6 +24,12 @@ import PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { messageKey } from 'lib/shared/message-utils';\n+import { connect } from 'lib/utils/redux-utils';\n+import {\n+ sendMultimediaMessageActionTypes,\n+ sendMultimediaMessage,\n+} from 'lib/actions/message-actions';\n+import { messageID } from 'lib/shared/message-utils';\nimport css from './chat-message-list.css';\nimport Multimedia from './multimedia.react';\n@@ -28,6 +40,16 @@ type Props = {|\nthreadInfo: ThreadInfo,\nsetMouseOver: (messagePositionInfo: MessagePositionInfo) => void,\nchatInputState: ChatInputState,\n+ // Redux state\n+ rawMessageInfo: RawMultimediaMessageInfo,\n+ // Redux dispatch functions\n+ dispatchActionPromise: DispatchActionPromise,\n+ // async functions that hit server APIs\n+ sendMultimediaMessage: (\n+ threadID: string,\n+ localID: string,\n+ mediaIDs: $ReadOnlyArray<string>,\n+ ) => Promise<SendMessageResult>,\n|};\nclass MultimediaMessage extends React.PureComponent<Props> {\n@@ -36,6 +58,9 @@ class MultimediaMessage extends React.PureComponent<Props> {\nthreadInfo: threadInfoPropType.isRequired,\nsetMouseOver: PropTypes.func.isRequired,\nchatInputState: chatInputStatePropType.isRequired,\n+ rawMessageInfo: PropTypes.object.isRequired,\n+ dispatchActionPromise: PropTypes.func.isRequired,\n+ sendMultimediaMessage: PropTypes.func.isRequired,\n};\nconstructor(props: Props) {\n@@ -46,6 +71,19 @@ class MultimediaMessage extends React.PureComponent<Props> {\n);\n}\n+ componentDidMount() {\n+ const { rawMessageInfo } = this.props;\n+ if (rawMessageInfo.id) {\n+ return;\n+ }\n+ this.props.dispatchActionPromise(\n+ sendMultimediaMessageActionTypes,\n+ this.sendMultimediaMessageAction(rawMessageInfo),\n+ undefined,\n+ rawMessageInfo,\n+ );\n+ }\n+\ncomponentWillReceiveProps(nextProps: Props) {\ninvariant(\nnextProps.item.messageInfo.type === messageTypes.MULTIMEDIA,\n@@ -105,6 +143,47 @@ class MultimediaMessage extends React.PureComponent<Props> {\n);\n}\n+ async sendMultimediaMessageAction(messageInfo: RawMultimediaMessageInfo) {\n+ try {\n+ const { localID } = messageInfo;\n+ invariant(\n+ localID !== null && localID !== undefined,\n+ \"localID should be set\",\n+ );\n+ const result = await this.props.sendMultimediaMessage(\n+ messageInfo.threadID,\n+ localID,\n+ messageInfo.media.map(({ id }) => id),\n+ );\n+ return {\n+ localID,\n+ serverID: result.id,\n+ threadID: messageInfo.threadID,\n+ time: result.time,\n+ };\n+ } catch (e) {\n+ e.localID = messageInfo.localID;\n+ e.threadID = messageInfo.threadID;\n+ throw e;\n+ }\n+ }\n+\n}\n-export default MultimediaMessage;\n+export default connect(\n+ (state: AppState, ownProps: { item: ChatMessageInfoItem }) => {\n+ const { messageInfo } = ownProps.item;\n+ invariant(\n+ messageInfo.type === messageTypes.MULTIMEDIA,\n+ \"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n+ );\n+ const id = messageID(messageInfo);\n+ const rawMessageInfo = state.messageStore.messages[id];\n+ invariant(\n+ rawMessageInfo.type === messageTypes.MULTIMEDIA,\n+ \"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n+ );\n+ return { rawMessageInfo };\n+ },\n+ { sendMultimediaMessage },\n+)(MultimediaMessage);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Actually call sendMultimediaMessage from MultimediaMessage |
129,187 | 20.02.2019 17:53:21 | 18,000 | 88de5f57e025d78de624dc8e0ea48134cb99a4c2 | [web] Detect MultimediaMessage failures correctly | [
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-input-state-container.react.js",
"new_path": "web/chat/chat-input-state-container.react.js",
"diff": "@@ -97,6 +97,8 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nsetDraft: (draft: string) => this.setDraft(threadID, draft),\nsetProgress: (localUploadID: string, percent: number) =>\nthis.setProgress(threadID, localUploadID, percent),\n+ messageHasUploadFailure: (localMessageID: string) =>\n+ this.messageHasUploadFailure(threadAssignedUploads[localMessageID]),\n};\n},\n));\n@@ -439,6 +441,15 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n});\n}\n+ messageHasUploadFailure(\n+ pendingUploads: ?$ReadOnlyArray<PendingMultimediaUpload>,\n+ ) {\n+ if (!pendingUploads) {\n+ return false;\n+ }\n+ return pendingUploads.some(upload => upload.failed);\n+ }\n+\nrender() {\nconst { activeChatThreadID } = this.props;\nconst chatInputState = activeChatThreadID\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-input-state.js",
"new_path": "web/chat/chat-input-state.js",
"diff": "@@ -49,6 +49,7 @@ export type ChatInputState = {|\nassignPendingUploads: (localMessageID: string) => void,\nsetDraft: (draft: string) => void,\nsetProgress: (localUploadID: string, percent: number) => void,\n+ messageHasUploadFailure: (localMessageID: string) => bool,\n|};\nconst arrayOfUploadsPropType =\nPropTypes.arrayOf(pendingMultimediaUploadPropType);\n@@ -61,4 +62,5 @@ export const chatInputStatePropType = PropTypes.shape({\nassignPendingUploads: PropTypes.func.isRequired,\nsetDraft: PropTypes.func.isRequired,\nsetProgress: PropTypes.func.isRequired,\n+ messageHasUploadFailure: PropTypes.func.isRequired,\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/multimedia-message.react.js",
"new_path": "web/chat/multimedia-message.react.js",
"diff": "@@ -63,15 +63,22 @@ class MultimediaMessage extends React.PureComponent<Props> {\nsendMultimediaMessage: PropTypes.func.isRequired,\n};\n- constructor(props: Props) {\n- super(props);\n- invariant(\n- props.item.messageInfo.type === messageTypes.MULTIMEDIA,\n- \"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n- );\n+ componentDidMount() {\n+ if (MultimediaMessage.multimediaUploadComplete(this.props)) {\n+ this.sendMultimediaMessage();\n+ }\n}\n- componentDidMount() {\n+ componentDidUpdate(prevProps: Props) {\n+ if (\n+ !MultimediaMessage.multimediaUploadComplete(prevProps) &&\n+ MultimediaMessage.multimediaUploadComplete(this.props)\n+ ) {\n+ this.sendMultimediaMessage();\n+ }\n+ }\n+\n+ sendMultimediaMessage() {\nconst { rawMessageInfo } = this.props;\nif (rawMessageInfo.id) {\nreturn;\n@@ -84,33 +91,69 @@ class MultimediaMessage extends React.PureComponent<Props> {\n);\n}\n- componentWillReceiveProps(nextProps: Props) {\n+ static multimediaUploadComplete(props: Props) {\n+ const { messageInfo } = props.item;\n+ invariant(\n+ messageInfo.type === messageTypes.MULTIMEDIA,\n+ \"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n+ );\n+ if (messageInfo.id) {\n+ return true;\n+ }\n+ if (MultimediaMessage.multimediaUploadFailed(props)) {\n+ return false;\n+ }\n+ const { localID, media } = messageInfo;\n+ const pendingUploads = localID\n+ ? props.chatInputState.assignedUploads[localID]\n+ : null;\n+ if (!pendingUploads) {\n+ return true;\n+ }\n+ return messageInfo.media.every(media => {\n+ const pendingUpload = pendingUploads.find(\n+ upload => upload.localID === media.id,\n+ );\n+ return !pendingUpload || pendingUpload.serverID;\n+ });\n+ }\n+\n+ static multimediaUploadFailed(props: Props) {\n+ const { messageInfo } = props.item;\ninvariant(\n- nextProps.item.messageInfo.type === messageTypes.MULTIMEDIA,\n+ messageInfo.type === messageTypes.MULTIMEDIA,\n\"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n);\n+ const { id, localID, media } = messageInfo;\n+ if (id) {\n+ return false;\n+ }\n+ invariant(localID, \"localID should be set if serverID is not\");\n+ return props.chatInputState.messageHasUploadFailure(localID);\n}\nrender() {\n+ const { item } = this.props;\ninvariant(\n- this.props.item.messageInfo.type === messageTypes.MULTIMEDIA,\n+ item.messageInfo.type === messageTypes.MULTIMEDIA,\n\"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n);\n- const { localID, media } = this.props.item.messageInfo;\n+ const { id, localID, media } = item.messageInfo;\n+ const { isViewer } = item.messageInfo.creator;\n+\n+ const sendFailed =\n+ isViewer &&\n+ (id === null || id === undefined) &&\n+ (MultimediaMessage.multimediaUploadFailed(this.props) ||\n+ (item.localMessageInfo && item.localMessageInfo.sendFailed));\n+\nconst pendingUploads = localID\n? this.props.chatInputState.assignedUploads[localID]\n: null;\n- let sendFailed = false;\nconst multimedia = media.map(singleMedia => {\n- let pendingUpload;\n- if (pendingUploads) {\n- pendingUpload = pendingUploads.find(\n- upload => upload.localID === singleMedia.id,\n- );\n- }\n- if (pendingUpload && pendingUpload.failed) {\n- sendFailed = true;\n- }\n+ const pendingUpload = pendingUploads\n+ ? pendingUploads.find(upload => upload.localID === singleMedia.id)\n+ : null;\nreturn (\n<Multimedia\nuri={singleMedia.uri}\n@@ -119,6 +162,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\n/>\n);\n});\n+\ninvariant(\nmultimedia.length > 0,\n\"should be at least one multimedia...\",\n@@ -129,11 +173,12 @@ class MultimediaMessage extends React.PureComponent<Props> {\nconst className = multimedia.length > 1\n? css.fullWidthMessageBox\n: css.halfWidthMessageBox;\n+\nreturn (\n<ComposedMessage\n- item={this.props.item}\n+ item={item}\nthreadInfo={this.props.threadInfo}\n- sendFailed={sendFailed}\n+ sendFailed={!!sendFailed}\nsetMouseOver={this.props.setMouseOver}\nclassName={className}\nborderRadius={16}\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/text-message.react.js",
"new_path": "web/chat/text-message.react.js",
"diff": "@@ -76,7 +76,7 @@ class TextMessage extends React.PureComponent<Props> {\nconst sendFailed =\nisViewer &&\n- id !== null && id !== undefined &&\n+ (id === null || id === undefined) &&\nthis.props.item.localMessageInfo &&\nthis.props.item.localMessageInfo.sendFailed;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Detect MultimediaMessage failures correctly |
129,187 | 20.02.2019 19:26:20 | 18,000 | 248dc627a7186674c744c0f404e60dbb2a0cbaa0 | Support retrying failed multimedia sends on web | [
{
"change_type": "MODIFY",
"old_path": "lib/types/message-types.js",
"new_path": "lib/types/message-types.js",
"diff": "@@ -232,7 +232,7 @@ export type RawMultimediaMessageInfo = {|\n...MultimediaMessageData,\nid?: string, // null if local copy without ID yet\n|};\n-type RawComposableMessageInfo =\n+export type RawComposableMessageInfo =\n| RawTextMessageInfo\n| RawMultimediaMessageInfo;\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-input-state-container.react.js",
"new_path": "web/chat/chat-input-state-container.react.js",
"diff": "@@ -99,6 +99,8 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nthis.setProgress(threadID, localUploadID, percent),\nmessageHasUploadFailure: (localMessageID: string) =>\nthis.messageHasUploadFailure(threadAssignedUploads[localMessageID]),\n+ retryUploads: (localMessageID: string) =>\n+ this.retryUploads(threadID, threadAssignedUploads[localMessageID]),\n};\n},\n));\n@@ -310,14 +312,16 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nlocalUploadID: string,\ne: any,\n) {\n- const failed = e instanceof Error ? e.message : \"failed\";\nthis.setState(prevState => {\nconst uploads = prevState.pendingUploads[threadID];\nconst upload = uploads[localUploadID];\n- if (!upload) {\n- // The upload has been cancelled before it failed\n+ if (!upload || !upload.abort || upload.serverID) {\n+ // The upload has been cancelled or completed before it failed\nreturn {};\n}\n+ const failed = (e instanceof Error && e.message)\n+ ? e.message\n+ : \"failed\";\nreturn {\npendingUploads: {\n...prevState.pendingUploads,\n@@ -450,6 +454,56 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\nreturn pendingUploads.some(upload => upload.failed);\n}\n+ retryUploads(\n+ threadID: string,\n+ pendingUploads: ?$ReadOnlyArray<PendingMultimediaUpload>,\n+ ) {\n+ if (!pendingUploads) {\n+ return;\n+ }\n+ const uploadIDsToRetry = new Set();\n+ const uploadsToRetry = [];\n+ for (let pendingUpload of pendingUploads) {\n+ if (pendingUpload.serverID) {\n+ continue;\n+ }\n+ if (pendingUpload.abort) {\n+ pendingUpload.abort();\n+ }\n+ uploadIDsToRetry.add(pendingUpload.localID);\n+ uploadsToRetry.push(pendingUpload);\n+ }\n+\n+ this.setState(prevState => {\n+ const pendingUploads = prevState.pendingUploads[threadID];\n+ if (!pendingUploads) {\n+ return {};\n+ }\n+ const newPendingUploads = {};\n+ for (let localID in pendingUploads) {\n+ const pendingUpload = pendingUploads[localID];\n+ if (uploadIDsToRetry.has(localID) && !pendingUpload.serverID) {\n+ newPendingUploads[localID] = {\n+ ...pendingUpload,\n+ failed: null,\n+ progressPercent: 0,\n+ abort: null,\n+ };\n+ } else {\n+ newPendingUploads[localID] = pendingUpload;\n+ }\n+ }\n+ return {\n+ pendingUploads: {\n+ ...prevState.pendingUploads,\n+ [threadID]: newPendingUploads,\n+ },\n+ };\n+ });\n+\n+ this.uploadFiles(threadID, uploadsToRetry);\n+ }\n+\nrender() {\nconst { activeChatThreadID } = this.props;\nconst chatInputState = activeChatThreadID\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-input-state.js",
"new_path": "web/chat/chat-input-state.js",
"diff": "@@ -50,6 +50,7 @@ export type ChatInputState = {|\nsetDraft: (draft: string) => void,\nsetProgress: (localUploadID: string, percent: number) => void,\nmessageHasUploadFailure: (localMessageID: string) => bool,\n+ retryUploads: (localMessageID: string) => void,\n|};\nconst arrayOfUploadsPropType =\nPropTypes.arrayOf(pendingMultimediaUploadPropType);\n@@ -63,4 +64,5 @@ export const chatInputStatePropType = PropTypes.shape({\nsetDraft: PropTypes.func.isRequired,\nsetProgress: PropTypes.func.isRequired,\nmessageHasUploadFailure: PropTypes.func.isRequired,\n+ retryUploads: PropTypes.func.isRequired,\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/composed-message.react.js",
"new_path": "web/chat/composed-message.react.js",
"diff": "@@ -7,6 +7,10 @@ import {\nimport { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\nimport { assertComposableMessageType } from 'lib/types/message-types';\nimport type { MessagePositionInfo } from './message.react';\n+import {\n+ chatInputStatePropType,\n+ type ChatInputState,\n+} from './chat-input-state';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n@@ -28,6 +32,7 @@ type Props = {|\nchildren: React.Node,\nclassName?: string,\nborderRadius: number,\n+ chatInputState: ChatInputState,\n|};\nclass ComposedMessage extends React.PureComponent<Props> {\n@@ -39,6 +44,7 @@ class ComposedMessage extends React.PureComponent<Props> {\nchildren: PropTypes.node.isRequired,\nclassName: PropTypes.string,\nborderRadius: PropTypes.number.isRequired,\n+ chatInputState: chatInputStatePropType.isRequired,\n};\nstatic defaultProps = {\nborderRadius: 8,\n@@ -55,7 +61,7 @@ class ComposedMessage extends React.PureComponent<Props> {\nrender() {\nassertComposableMessageType(this.props.item.messageInfo.type);\n- const { borderRadius, item, threadInfo } = this.props;\n+ const { borderRadius, item, threadInfo, chatInputState } = this.props;\nconst { id, creator } = item.messageInfo;\nconst threadColor = threadInfo.color;\n@@ -99,6 +105,7 @@ class ComposedMessage extends React.PureComponent<Props> {\n<FailedSend\nitem={item}\nthreadInfo={threadInfo}\n+ chatInputState={chatInputState}\n/>\n);\n} else {\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/failed-send.react.js",
"new_path": "web/chat/failed-send.react.js",
"diff": "@@ -7,12 +7,18 @@ import {\nimport {\nmessageTypes,\ntype SendMessageResult,\n+ type RawComposableMessageInfo,\ntype RawTextMessageInfo,\n- type RawMessageInfo,\n+ type RawMultimediaMessageInfo,\n+ assertComposableMessageType,\n} from 'lib/types/message-types';\nimport { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\nimport type { AppState } from '../redux-setup';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\n+import {\n+ chatInputStatePropType,\n+ type ChatInputState,\n+} from './chat-input-state';\nimport * as React from 'react';\nimport invariant from 'invariant';\n@@ -23,6 +29,8 @@ import { connect } from 'lib/utils/redux-utils';\nimport {\nsendTextMessageActionTypes,\nsendTextMessage,\n+ sendMultimediaMessageActionTypes,\n+ sendMultimediaMessage,\n} from 'lib/actions/message-actions';\nimport css from './chat-message-list.css';\n@@ -30,8 +38,9 @@ import css from './chat-message-list.css';\ntype Props = {|\nitem: ChatMessageInfoItem,\nthreadInfo: ThreadInfo,\n+ chatInputState: ChatInputState,\n// Redux state\n- rawMessageInfo: RawMessageInfo,\n+ rawMessageInfo: RawComposableMessageInfo,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -40,58 +49,32 @@ type Props = {|\nlocalID: string,\ntext: string,\n) => Promise<SendMessageResult>,\n+ sendMultimediaMessage: (\n+ threadID: string,\n+ localID: string,\n+ mediaIDs: $ReadOnlyArray<string>,\n+ ) => Promise<SendMessageResult>,\n|};\nclass FailedSend extends React.PureComponent<Props> {\nstatic propTypes = {\nitem: chatMessageItemPropType.isRequired,\nthreadInfo: threadInfoPropType.isRequired,\n+ chatInputState: chatInputStatePropType.isRequired,\nrawMessageInfo: PropTypes.object.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nsendTextMessage: PropTypes.func.isRequired,\n+ sendMultimediaMessage: PropTypes.func.isRequired,\n};\n- constructor(props: Props) {\n- super(props);\n- invariant(\n- props.item.messageInfo.type === messageTypes.TEXT,\n- \"TextMessage should only be used for messageTypes.TEXT\",\n- );\n- }\n-\n- componentWillReceiveProps(nextProps: Props) {\n- invariant(\n- nextProps.item.messageInfo.type === messageTypes.TEXT,\n- \"TextMessage should only be used for messageTypes.TEXT\",\n- );\n- }\n-\nrender() {\n- invariant(\n- this.props.item.messageInfo.type === messageTypes.TEXT,\n- \"TextMessage should only be used for messageTypes.TEXT\",\n- );\n- const { isViewer } = this.props.item.messageInfo.creator;\n- if (!isViewer) {\n- return null;\n- }\n- const { id } = this.props.item.messageInfo;\n- if (id !== null && id !== undefined) {\n- return null;\n- }\n- const sendFailed = this.props.item.localMessageInfo\n- ? this.props.item.localMessageInfo.sendFailed\n- : null;\n- if (!sendFailed) {\n- return null;\n- }\nreturn (\n<div className={css.failedSend}>\n<span>\nDelivery failed.\n</span>\n<a onClick={this.retrySend} className={css.retrySend}>\n- Retry?\n+ {\"Retry?\"}\n</a>\n</div>\n);\n@@ -101,23 +84,32 @@ class FailedSend extends React.PureComponent<Props> {\nevent.stopPropagation();\nconst { rawMessageInfo } = this.props;\n- invariant(\n- rawMessageInfo.type === messageTypes.TEXT,\n- \"TextMessage should only be used for messageTypes.TEXT\",\n- );\n- const newRawMessageInfo = {\n- ...rawMessageInfo,\n- time: Date.now(),\n- };\n+ if (rawMessageInfo.type === messageTypes.TEXT) {\n+ const newRawMessageInfo = { ...rawMessageInfo, time: Date.now() };\nthis.props.dispatchActionPromise(\nsendTextMessageActionTypes,\n- this.sendMessageAction(newRawMessageInfo),\n+ this.sendTextMessageAction(newRawMessageInfo),\nundefined,\nnewRawMessageInfo,\n);\n+ } else if (rawMessageInfo.type === messageTypes.MULTIMEDIA) {\n+ const newRawMessageInfo = { ...rawMessageInfo, time: Date.now() };\n+ const { localID } = newRawMessageInfo;\n+ invariant(localID, \"failed RawMessageInfo should have localID\");\n+ if (this.props.chatInputState.messageHasUploadFailure(localID)) {\n+ this.props.chatInputState.retryUploads(localID);\n+ } else {\n+ this.props.dispatchActionPromise(\n+ sendMultimediaMessageActionTypes,\n+ this.sendMultimediaMessageAction(newRawMessageInfo),\n+ undefined,\n+ newRawMessageInfo,\n+ );\n+ }\n+ }\n}\n- async sendMessageAction(messageInfo: RawTextMessageInfo) {\n+ async sendTextMessageAction(messageInfo: RawTextMessageInfo) {\ntry {\nconst { localID } = messageInfo;\ninvariant(\n@@ -142,19 +134,46 @@ class FailedSend extends React.PureComponent<Props> {\n}\n}\n+ async sendMultimediaMessageAction(messageInfo: RawMultimediaMessageInfo) {\n+ try {\n+ const { localID } = messageInfo;\n+ invariant(\n+ localID !== null && localID !== undefined,\n+ \"localID should be set\",\n+ );\n+ const result = await this.props.sendMultimediaMessage(\n+ messageInfo.threadID,\n+ localID,\n+ messageInfo.media.map(({ id }) => id),\n+ );\n+ return {\n+ localID,\n+ serverID: result.id,\n+ threadID: messageInfo.threadID,\n+ time: result.time,\n+ };\n+ } catch (e) {\n+ e.localID = messageInfo.localID;\n+ e.threadID = messageInfo.threadID;\n+ throw e;\n+ }\n+ }\n+\n}\nexport default connect(\n(state: AppState, ownProps: { item: ChatMessageInfoItem }) => {\nconst { messageInfo } = ownProps.item;\n+ assertComposableMessageType(messageInfo.type);\n+ const id = messageID(messageInfo);\n+ const rawMessageInfo = state.messageStore.messages[id];\n+ assertComposableMessageType(rawMessageInfo.type);\ninvariant(\n- messageInfo.type === messageTypes.TEXT,\n- \"TextMessage should only be used for messageTypes.TEXT\",\n+ rawMessageInfo.type === messageTypes.TEXT ||\n+ rawMessageInfo.type === messageTypes.MULTIMEDIA,\n+ \"FailedSend should only be used for composable message types\",\n);\n- const id = messageID(messageInfo);\n- return {\n- rawMessageInfo: state.messageStore.messages[id],\n- };\n+ return { rawMessageInfo };\n},\n- { sendTextMessage },\n+ { sendTextMessage, sendMultimediaMessage },\n)(FailedSend);\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/message.react.js",
"new_path": "web/chat/message.react.js",
"diff": "@@ -70,6 +70,7 @@ class Message extends React.PureComponent<Props> {\nitem={this.props.item}\nthreadInfo={this.props.threadInfo}\nsetMouseOver={this.props.setMouseOver}\n+ chatInputState={this.props.chatInputState}\n/>\n);\n} else if (this.props.item.messageInfo.type === messageTypes.MULTIMEDIA) {\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/multimedia-message.react.js",
"new_path": "web/chat/multimedia-message.react.js",
"diff": "@@ -182,6 +182,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\nsetMouseOver={this.props.setMouseOver}\nclassName={className}\nborderRadius={16}\n+ chatInputState={this.props.chatInputState}\n>\n{content}\n</ComposedMessage>\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/text-message.react.js",
"new_path": "web/chat/text-message.react.js",
"diff": "@@ -7,6 +7,10 @@ import {\nimport { messageTypes } from 'lib/types/message-types';\nimport { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\nimport type { MessagePositionInfo } from './message.react';\n+import {\n+ chatInputStatePropType,\n+ type ChatInputState,\n+} from './chat-input-state';\nimport * as React from 'react';\nimport invariant from 'invariant';\n@@ -24,6 +28,7 @@ type Props = {|\nitem: ChatMessageInfoItem,\nthreadInfo: ThreadInfo,\nsetMouseOver: (messagePositionInfo: MessagePositionInfo) => void,\n+ chatInputState: ChatInputState,\n|};\nclass TextMessage extends React.PureComponent<Props> {\n@@ -31,6 +36,7 @@ class TextMessage extends React.PureComponent<Props> {\nitem: chatMessageItemPropType.isRequired,\nthreadInfo: threadInfoPropType.isRequired,\nsetMouseOver: PropTypes.func.isRequired,\n+ chatInputState: chatInputStatePropType.isRequired,\n};\nconstructor(props: Props) {\n@@ -86,6 +92,7 @@ class TextMessage extends React.PureComponent<Props> {\nthreadInfo={this.props.threadInfo}\nsendFailed={!!sendFailed}\nsetMouseOver={this.props.setMouseOver}\n+ chatInputState={this.props.chatInputState}\n>\n<div className={messageClassName} style={messageStyle}>\n<Linkify>{text}</Linkify>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Support retrying failed multimedia sends on web |
129,187 | 20.02.2019 20:10:01 | 18,000 | 66d116b02eaa2a58a4710b80183d07e3367d0cd7 | [web] Add support for displaying MessageTimestampTooltip at the bottom | [
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-message-list.css",
"new_path": "web/chat/chat-message-list.css",
"diff": "@@ -127,6 +127,7 @@ div.messageTimestampTooltip {\npadding: 5px;\nborder-radius: 5px;\nfont-size: 14px;\n+ z-index: 1;\n}\ndiv.messageTimestampTooltip:after {\ncontent: \"\";\n@@ -156,6 +157,16 @@ div.messageTimestampTopRightTooltip:after {\nright: 4px;\nborder-color: black transparent transparent transparent;\n}\n+div.messageTimestampBottomLeftTooltip:after {\n+ top: -14px;\n+ left: 4px;\n+ border-color: transparent transparent black transparent;\n+}\n+div.messageTimestampBottomRightTooltip:after {\n+ top: -14px;\n+ right: 4px;\n+ border-color: transparent transparent black transparent;\n+}\ndiv.textMessage {\npadding: 6px 12px;\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/message-timestamp-tooltip.react.js",
"new_path": "web/chat/message-timestamp-tooltip.react.js",
"diff": "@@ -28,18 +28,27 @@ function MessageTimestampTooltip(props: Props) {\n'\"Helvetica Neue\", sans-serif';\nconst textWidth = calculateTextWidth(text, font);\nconst width = textWidth + 10; // 10px padding\n- const widthWithArrow = width + 10; // 7px arrow + 3px extra\n+ const sizeOfArrow = 10; // 7px arrow + 3px extra\n+ const widthWithArrow = width + sizeOfArrow;\nconst height = 27; // 17px line-height + 10px padding\n- const heightWithArrow = height + 10; // 7px arrow + 3px extra\n+ const heightWithArrow = height + sizeOfArrow;\nconst { isViewer } = item.messageInfo.creator;\nconst isComposed = isComposableMessageType(item.messageInfo.type);\nlet align = isComposed && isViewer ? \"right\" : \"left\";\n- if (align === \"right\" && messagePosition.right + width > window.innerWidth) {\n+ if (align === \"right\") {\n+ if (messagePosition.top < 0) {\n+ align = \"bottom-right\";\n+ } else if (messagePosition.right + width > window.innerWidth) {\nalign = \"top-right\";\n- } else if (align === \"left\" && messagePosition.left - width < 0) {\n+ }\n+ } else if (align === \"left\") {\n+ if (messagePosition.top < 0) {\n+ align = \"bottom-left\";\n+ } else if (messagePosition.left - width < 0) {\nalign = \"top-left\";\n}\n+ }\nlet style, className;\nif (align === \"left\") {\n@@ -71,6 +80,18 @@ function MessageTimestampTooltip(props: Props) {\ntop: messagePosition.top - heightWithArrow,\n};\nclassName = css.messageTimestampTopRightTooltip;\n+ } else if (align === \"bottom-left\") {\n+ style = {\n+ left: messagePosition.left,\n+ top: messagePosition.top + messagePosition.height + sizeOfArrow,\n+ };\n+ className = css.messageTimestampBottomLeftTooltip;\n+ } else if (align === \"bottom-right\") {\n+ style = {\n+ left: messagePosition.right - width,\n+ top: messagePosition.top + messagePosition.height + sizeOfArrow,\n+ };\n+ className = css.messageTimestampBottomRightTooltip;\n}\ninvariant(style, \"should be set\");\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Add support for displaying MessageTimestampTooltip at the bottom |
129,187 | 20.02.2019 20:31:32 | 18,000 | 6f9409023640d1392e57c47ab24cd1b7ec00029f | [lib] Shim multimedia messages to non-web platforms | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/media-utils.js",
"new_path": "lib/shared/media-utils.js",
"diff": "// @flow\nimport type { Media } from '../types/media-types';\n+import type {\n+ MultimediaMessageInfo,\n+ RawMultimediaMessageInfo,\n+} from '../types/message-types';\nimport invariant from 'invariant';\n@@ -24,6 +28,14 @@ function contentStringForMediaArray(media: $ReadOnlyArray<Media>): string {\nreturn `some ${firstType}s`;\n}\n+function multimediaMessagePreview(\n+ messageInfo: MultimediaMessageInfo | RawMultimediaMessageInfo,\n+): string {\n+ const mediaContentString = contentStringForMediaArray(messageInfo.media);\n+ return `sent ${mediaContentString}`;\n+}\n+\nexport {\ncontentStringForMediaArray,\n+ multimediaMessagePreview,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -7,6 +7,7 @@ import {\ntype PreviewableMessageInfo,\ntype TextMessageInfo,\ntype MultimediaMessageInfo,\n+ type RawMultimediaMessageInfo,\ntype MessageData,\ntype MessageType,\ntype MessageTruncationStatus,\n@@ -23,7 +24,7 @@ import _maxBy from 'lodash/fp/maxBy';\nimport { prettyDate } from '../utils/date-utils';\nimport { userIDsToRelativeUserInfos } from '../selectors/user-selectors';\n-import { contentStringForMediaArray } from './media-utils';\n+import { multimediaMessagePreview } from './media-utils';\nimport { stringForUser } from './user-utils';\n// Prefers localID\n@@ -598,8 +599,26 @@ function shimUnsupportedRawMessageInfos(\nrawMessageInfos: $ReadOnlyArray<RawMessageInfo>,\nplatformDetails: ?PlatformDetails,\n): RawMessageInfo[] {\n+ if (platformDetails && platformDetails.platform === \"web\") {\nreturn [ ...rawMessageInfos ];\n}\n+ return rawMessageInfos.map(rawMessageInfo => {\n+ if (rawMessageInfo.type !== messageTypes.MULTIMEDIA) {\n+ return rawMessageInfo;\n+ }\n+ const { id } = rawMessageInfo;\n+ invariant(id !== null && id !== undefined, \"id should be set on server\");\n+ return {\n+ type: messageTypes.UNSUPPORTED,\n+ id,\n+ threadID: rawMessageInfo.threadID,\n+ creatorID: rawMessageInfo.creatorID,\n+ time: rawMessageInfo.time,\n+ robotext: multimediaMessagePreview(rawMessageInfo),\n+ unsupportedMessageInfo: rawMessageInfo,\n+ };\n+ });\n+}\nfunction messagePreviewText(\nmessageInfo: PreviewableMessageInfo,\n@@ -607,8 +626,8 @@ function messagePreviewText(\n): string {\nif (messageInfo.type === messageTypes.MULTIMEDIA) {\nconst creator = stringForUser(messageInfo.creator);\n- const mediaContentString = contentStringForMediaArray(messageInfo.media);\n- return `${creator} sent ${mediaContentString}`;\n+ const preview = multimediaMessagePreview(messageInfo);\n+ return `${creator} ${preview}`;\n}\nreturn robotextToRawString(robotextForMessageInfo(messageInfo, threadInfo));\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Shim multimedia messages to non-web platforms |
129,187 | 20.02.2019 20:41:41 | 18,000 | 29d86bdf72161406eb462142867597bee9fc2604 | [lib] Get rid of " character in all shimmed robotext
( this means all current native clients will see random " characters at the end of unsupported `MessageInfo`s. Oh well. | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -161,7 +161,7 @@ function robotextForMessageInfo(\nreturn `${creator} restored an event scheduled for ${date}: ` +\n`\"${messageInfo.text}\"`;\n} else if (messageInfo.type === messageTypes.UNSUPPORTED) {\n- return `${creator} ${messageInfo.robotext}\"`;\n+ return `${creator} ${messageInfo.robotext}`;\n}\ninvariant(false, `we're not aware of messageType ${messageInfo.type}`);\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Get rid of " character in all shimmed robotext
:( this means all current native clients will see random " characters at the end of unsupported `MessageInfo`s. Oh well. |
129,187 | 20.02.2019 20:45:41 | 18,000 | 42cc9948e1f525787bb4c5a2f3e55a971109d564 | [web] Ungate multimedia support on web | [
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-input-bar.react.js",
"new_path": "web/chat/chat-input-bar.react.js",
"diff": "@@ -47,7 +47,6 @@ import {\n} from 'lib/actions/thread-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\nimport { threadHasPermission, viewerIsMember } from 'lib/shared/thread-utils';\n-import { isStaff } from 'lib/shared/user-utils';\nimport css from './chat-message-list.css';\nimport LoadingIndicator from '../loading-indicator.react';\n@@ -188,9 +187,16 @@ class ChatInputBar extends React.PureComponent<Props> {\nlet content;\nif (threadHasPermission(this.props.threadInfo, threadPermissions.VOICED)) {\n- let multimediaUpload = null;\n- if (this.props.viewerID && isStaff(this.props.viewerID)) {\n- multimediaUpload = (\n+ content = (\n+ <div className={css.inputBarTextInput}>\n+ <textarea\n+ rows=\"1\"\n+ placeholder=\"Send a message...\"\n+ value={this.props.chatInputState.draft}\n+ onChange={this.onChangeMessageText}\n+ onKeyDown={this.onKeyDown}\n+ ref={this.textareaRef}\n+ />\n<a className={css.multimediaUpload} onClick={this.onMultimediaClick}>\n<input\ntype=\"file\"\n@@ -203,19 +209,6 @@ class ChatInputBar extends React.PureComponent<Props> {\nicon={faFileImage}\n/>\n</a>\n- );\n- }\n- content = (\n- <div className={css.inputBarTextInput}>\n- <textarea\n- rows=\"1\"\n- placeholder=\"Send a message...\"\n- value={this.props.chatInputState.draft}\n- onChange={this.onChangeMessageText}\n- onKeyDown={this.onKeyDown}\n- ref={this.textareaRef}\n- />\n- {multimediaUpload}\n<a className={css.send} onClick={this.onSend}>\n<FontAwesomeIcon\nicon={faChevronRight}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Ungate multimedia support on web |
129,187 | 22.02.2019 16:44:06 | 18,000 | 1f6c86ba711f34c0b31717f5fddbf4cf671b0446 | [web] MultimediaModal | [
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-input-state-container.react.js",
"new_path": "web/chat/chat-input-state-container.react.js",
"diff": "@@ -505,7 +505,7 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n}\nrender() {\n- const { activeChatThreadID } = this.props;\n+ const { activeChatThreadID, setModal } = this.props;\nconst chatInputState = activeChatThreadID\n? this.chatInputStateSelector(activeChatThreadID)(this.state)\n: null;\n@@ -513,6 +513,7 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n<ChatMessageList\nactiveChatThreadID={activeChatThreadID}\nchatInputState={chatInputState}\n+ setModal={setModal}\n/>\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-message-list.css",
"new_path": "web/chat/chat-message-list.css",
"diff": "@@ -287,6 +287,9 @@ span.multimedia > span.multimediaImage {\nmin-height: 50px;\nmin-width: 50px;\n}\n+span.clickable {\n+ cursor: pointer;\n+}\ndiv.previews > span.multimedia > span.multimediaImage > img {\nmax-height: 200px;\nmax-width: 200px;\n@@ -391,3 +394,37 @@ div.imageGrid > span.multimedia:nth-last-child(n+5):first-child,\ndiv.imageGrid > span.multimedia:nth-last-child(n+5):first-child ~ * {\ngrid-column-end: span 2;\n}\n+\n+div.multimediaModalOverlay {\n+ position: fixed;\n+ left: 0;\n+ top: 0;\n+ z-index: 4;\n+ width: 100%;\n+ height: 100%;\n+ background-color: rgba(0,0,0,0.9);\n+ overflow: auto;\n+ padding: 10px;\n+ box-sizing: border-box;\n+ display: flex;\n+ justify-content: center;\n+}\n+div.multimediaModalOverlay > img {\n+ object-fit: scale-down;\n+ width: auto;\n+ height: auto;\n+ max-width: 100%;\n+ max-height: 100%;\n+}\n+svg.closeMultimediaModal {\n+ position: absolute;\n+ cursor: pointer;\n+ top: 15px;\n+ right: 15px;\n+ color: white;\n+ border-radius: 50%;\n+ box-shadow: inset 0px 0px 5px rgba(0,0,0,0.5);\n+ background-color: rgba(34,34,34,0.67);\n+ height: 36px;\n+ width: 36px;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-message-list.react.js",
"new_path": "web/chat/chat-message-list.react.js",
"diff": "@@ -56,6 +56,7 @@ const usingFlexDirectionColumnReverse = browser && browser.name === \"chrome\";\ntype PassedProps = {|\nactiveChatThreadID: ?string,\nchatInputState: ?ChatInputState,\n+ setModal: (modal: ?React.Node) => void,\n// Redux state\nthreadInfo: ?ThreadInfo,\nmessageListData: ?$ReadOnlyArray<ChatMessageItem>,\n@@ -87,6 +88,7 @@ class ChatMessageList extends React.PureComponent<Props, State> {\nstatic propTypes = {\nactiveChatThreadID: PropTypes.string,\nchatInputState: chatInputStatePropType,\n+ setModal: PropTypes.func.isRequired,\nthreadInfo: threadInfoPropType,\nmessageListData: PropTypes.arrayOf(chatMessageItemPropType),\nstartReached: PropTypes.bool.isRequired,\n@@ -228,7 +230,7 @@ class ChatMessageList extends React.PureComponent<Props, State> {\n</div>\n);\n}\n- const { threadInfo, chatInputState } = this.props;\n+ const { threadInfo, chatInputState, setModal } = this.props;\ninvariant(chatInputState, \"ChatInputState should be set\");\ninvariant(threadInfo, \"ThreadInfo should be set if messageListData is\");\nreturn (\n@@ -237,6 +239,7 @@ class ChatMessageList extends React.PureComponent<Props, State> {\nthreadInfo={threadInfo}\nsetMouseOver={this.setTimestampTooltip}\nchatInputState={chatInputState}\n+ setModal={setModal}\nkey={ChatMessageList.keyExtractor(item)}\n/>\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/message.react.js",
"new_path": "web/chat/message.react.js",
"diff": "@@ -44,6 +44,7 @@ type Props = {|\nthreadInfo: ThreadInfo,\nsetMouseOver: (messagePositionInfo: MessagePositionInfo) => void,\nchatInputState: ChatInputState,\n+ setModal: (modal: ?React.Node) => void,\n|};\nclass Message extends React.PureComponent<Props> {\n@@ -52,6 +53,7 @@ class Message extends React.PureComponent<Props> {\nthreadInfo: threadInfoPropType.isRequired,\nsetMouseOver: PropTypes.func.isRequired,\nchatInputState: chatInputStatePropType.isRequired,\n+ setModal: PropTypes.func.isRequired,\n};\nrender() {\n@@ -80,6 +82,7 @@ class Message extends React.PureComponent<Props> {\nthreadInfo={this.props.threadInfo}\nsetMouseOver={this.props.setMouseOver}\nchatInputState={this.props.chatInputState}\n+ setModal={this.props.setModal}\n/>\n);\n} else {\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/multimedia-message.react.js",
"new_path": "web/chat/multimedia-message.react.js",
"diff": "@@ -40,6 +40,7 @@ type Props = {|\nthreadInfo: ThreadInfo,\nsetMouseOver: (messagePositionInfo: MessagePositionInfo) => void,\nchatInputState: ChatInputState,\n+ setModal: (modal: ?React.Node) => void,\n// Redux state\nrawMessageInfo: RawMultimediaMessageInfo,\n// Redux dispatch functions\n@@ -58,6 +59,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\nthreadInfo: threadInfoPropType.isRequired,\nsetMouseOver: PropTypes.func.isRequired,\nchatInputState: chatInputStatePropType.isRequired,\n+ setModal: PropTypes.func.isRequired,\nrawMessageInfo: PropTypes.object.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nsendMultimediaMessage: PropTypes.func.isRequired,\n@@ -133,7 +135,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\n}\nrender() {\n- const { item } = this.props;\n+ const { item, setModal } = this.props;\ninvariant(\nitem.messageInfo.type === messageTypes.MULTIMEDIA,\n\"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n@@ -158,6 +160,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\n<Multimedia\nuri={singleMedia.uri}\npendingUpload={pendingUpload}\n+ setModal={setModal}\nkey={singleMedia.id}\n/>\n);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "web/chat/multimedia-modal.react.js",
"diff": "+// @flow\n+\n+import * as React from 'react';\n+import PropTypes from 'prop-types';\n+import invariant from 'invariant';\n+import XCircleIcon from 'react-feather/dist/icons/x-circle';\n+\n+import css from './chat-message-list.css';\n+\n+type Props = {|\n+ uri: string,\n+ setModal: (modal: ?React.Node) => void,\n+|};\n+class MultimediaModal extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ uri: PropTypes.string.isRequired,\n+ setModal: PropTypes.func.isRequired,\n+ };\n+ overlay: ?HTMLDivElement;\n+\n+ componentDidMount() {\n+ invariant(this.overlay, \"overlay ref unset\");\n+ this.overlay.focus();\n+ }\n+\n+ render() {\n+ return (\n+ <div\n+ className={css.multimediaModalOverlay}\n+ ref={this.overlayRef}\n+ onClick={this.onBackgroundClick}\n+ tabIndex={0}\n+ onKeyDown={this.onKeyDown}\n+ >\n+ <img src={this.props.uri} />\n+ <XCircleIcon\n+ onClick={this.close}\n+ className={css.closeMultimediaModal}\n+ />\n+ </div>\n+ );\n+ }\n+\n+ overlayRef = (overlay: ?HTMLDivElement) => {\n+ this.overlay = overlay;\n+ }\n+\n+ onBackgroundClick = (event: SyntheticEvent<HTMLDivElement>) => {\n+ if (event.target === this.overlay) {\n+ this.close();\n+ }\n+ }\n+\n+ onKeyDown = (event: SyntheticKeyboardEvent<HTMLDivElement>) => {\n+ if (event.keyCode === 27) {\n+ this.close();\n+ }\n+ }\n+\n+ close = () => {\n+ this.props.setModal(null);\n+ }\n+\n+}\n+\n+export default MultimediaModal;\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/multimedia.react.js",
"new_path": "web/chat/multimedia.react.js",
"diff": "@@ -12,13 +12,16 @@ import XCircleIcon from 'react-feather/dist/icons/x-circle';\nimport AlertCircleIcon from 'react-feather/dist/icons/alert-circle';\nimport CircularProgressbar from 'react-circular-progressbar';\nimport 'react-circular-progressbar/dist/styles.css';\n+import classNames from 'classnames';\nimport css from './chat-message-list.css';\n+import MultimediaModal from './multimedia-modal.react';\ntype Props = {|\nuri: string,\npendingUpload?: ?PendingMultimediaUpload,\nremove?: (uploadID: string) => void,\n+ setModal?: (modal: ?React.Node) => void,\n|};\nclass Multimedia extends React.PureComponent<Props> {\n@@ -26,6 +29,7 @@ class Multimedia extends React.PureComponent<Props> {\nuri: PropTypes.string.isRequired,\npendingUpload: pendingMultimediaUploadPropType,\nremove: PropTypes.func,\n+ setModal: PropTypes.func,\n};\ncomponentDidUpdate(prevProps: Props) {\n@@ -44,7 +48,7 @@ class Multimedia extends React.PureComponent<Props> {\nrender() {\nlet progressIndicator, errorIndicator, removeButton;\n- const { pendingUpload, remove } = this.props;\n+ const { pendingUpload, remove, setModal } = this.props;\nif (pendingUpload) {\nconst { progressPercent, failed } = pendingUpload;\n@@ -78,9 +82,16 @@ class Multimedia extends React.PureComponent<Props> {\n}\n}\n+ const imageContainerClasses = [ css.multimediaImage ];\n+ let onClick;\n+ if (setModal) {\n+ imageContainerClasses.push(css.clickable);\n+ onClick = this.onClick;\n+ }\n+\nreturn (\n<span className={css.multimedia}>\n- <span className={css.multimediaImage}>\n+ <span className={classNames(imageContainerClasses)} onClick={onClick}>\n<img src={this.props.uri} />\n{removeButton}\n</span>\n@@ -100,6 +111,14 @@ class Multimedia extends React.PureComponent<Props> {\nremove(pendingUpload.localID);\n}\n+ onClick = (event: SyntheticEvent<HTMLSpanElement>) => {\n+ event.stopPropagation();\n+\n+ const { setModal, uri } = this.props;\n+ invariant(setModal, \"should be set\");\n+ setModal(<MultimediaModal uri={uri} setModal={setModal} />);\n+ }\n+\n}\nexport default Multimedia;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] MultimediaModal |
129,187 | 22.02.2019 19:10:03 | 18,000 | 3795a0c6af4ca02f2c50f1865d821bc195914344 | Unshim RawMessageInfos on the client
Any client that includes this commit will unshim `MULTIMEDIA` messages. | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/message-reducer.js",
"new_path": "lib/reducers/message-reducer.js",
"diff": "@@ -80,6 +80,7 @@ import {\nassignMediaServerIDToMessageActionType,\nassignMediaServerURIToMessageActionType,\n} from '../actions/upload-actions';\n+import { unshimMessageInfos } from '../shared/unshim-utils';\n// Input must already be ordered!\nfunction threadsToMessageIDsFromMessageInfos(\n@@ -153,6 +154,7 @@ function mergeNewMessages(\nthreadInfos: {[threadID: string]: RawThreadInfo},\nactionType: *,\n): MessageStore {\n+ const unshimmed = unshimMessageInfos(newMessageInfos);\nconst localIDsToServerIDs: Map<string, string> = new Map();\nconst orderedNewMessageInfos = _flow(\n_map((messageInfo: RawMessageInfo) => {\n@@ -198,7 +200,7 @@ function mergeNewMessages(\n: messageInfo;\n}),\n_orderBy('time')('desc'),\n- )([...newMessageInfos]);\n+ )(unshimmed);\nconst threadsToMessageIDs = threadsToMessageIDsFromMessageInfos(\norderedNewMessageInfos,\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "lib/shared/unshim-utils.js",
"diff": "+// @flow\n+\n+import {\n+ type MessageStore,\n+ type RawMessageInfo,\n+ type MessageType,\n+ messageTypes,\n+} from '../types/message-types';\n+\n+import _mapValues from 'lodash/fp/mapValues';\n+\n+function unshimFunc(\n+ messageInfo: RawMessageInfo,\n+ unshimTypes: Set<MessageType>,\n+): RawMessageInfo {\n+ if (messageInfo.type !== messageTypes.UNSUPPORTED) {\n+ return messageInfo;\n+ }\n+ if (!unshimTypes.has(messageInfo.unsupportedMessageInfo.type)) {\n+ return messageInfo;\n+ }\n+ return messageInfo.unsupportedMessageInfo;\n+}\n+\n+function unshimMessageStore(\n+ messageStore: MessageStore,\n+ unshimTypes: $ReadOnlyArray<MessageType>,\n+): MessageStore {\n+ const set = new Set(unshimTypes);\n+ const messages = _mapValues(\n+ (messageInfo: RawMessageInfo) => unshimFunc(messageInfo, set),\n+ )(messageStore.messages);\n+ return { ...messageStore, messages };\n+}\n+\n+const localUnshimTypes = new Set([\n+ messageTypes.MULTIMEDIA,\n+]);\n+function unshimMessageInfos(\n+ messageInfos: $ReadOnlyArray<RawMessageInfo>,\n+): RawMessageInfo[] {\n+ return messageInfos.map(\n+ (messageInfo: RawMessageInfo) => unshimFunc(messageInfo, localUnshimTypes),\n+ );\n+}\n+\n+export {\n+ unshimMessageStore,\n+ unshimMessageInfos,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/persist.js",
"new_path": "native/persist.js",
"diff": "import type { AppState } from './redux-setup';\nimport { defaultCalendarFilters } from 'lib/types/filter-types';\nimport { defaultConnectionInfo } from 'lib/types/socket-types';\n+import { messageTypes } from 'lib/types/message-types';\nimport storage from 'redux-persist/lib/storage';\nimport { createMigrate } from 'redux-persist';\n@@ -10,6 +11,7 @@ import invariant from 'invariant';\nimport { Platform } from 'react-native';\nimport { highestLocalIDSelector } from 'lib/selectors/local-id-selectors';\n+import { unshimMessageStore } from 'lib/shared/unshim-utils';\nimport { nativeCalendarQuery } from './selectors/nav-selectors';\nimport { defaultNotifPermissionAlertInfo } from './push/alerts';\n@@ -115,6 +117,13 @@ const migrations = {\nlocal: {},\n},\n}),\n+ [11]: (state: AppState) => ({\n+ ...state,\n+ messageStore: unshimMessageStore(\n+ state.messageStore,\n+ [ messageTypes.MULTIMEDIA ],\n+ ),\n+ }),\n};\nconst persistConfig = {\n@@ -122,7 +131,7 @@ const persistConfig = {\nstorage,\nblacklist,\ndebug: __DEV__,\n- version: 10,\n+ version: 11,\nmigrate: createMigrate(migrations, { debug: __DEV__ }),\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Unshim RawMessageInfos on the client
Any client that includes this commit will unshim `MULTIMEDIA` messages. |
129,187 | 02.03.2019 22:10:20 | 28,800 | 8482241b5e70896bf6f5e23da9fc6537506f0ae9 | [native] Work around Android 9 cleartext network policy for Metro | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/android/app/src/debug/res/xml/network_security_config.xml",
"diff": "+<?xml version=\"1.0\" encoding=\"utf-8\"?>\n+<network-security-config>\n+ <!-- allow cleartext traffic for React Native packager ips in debug -->\n+ <domain-config cleartextTrafficPermitted=\"true\">\n+ <domain includeSubdomains=\"false\">localhost</domain>\n+ <domain includeSubdomains=\"false\">10.0.2.2</domain>\n+ <domain includeSubdomains=\"false\">10.0.3.2</domain>\n+ </domain-config>\n+</network-security-config>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/app/src/main/AndroidManifest.xml",
"new_path": "native/android/app/src/main/AndroidManifest.xml",
"diff": "android:label=\"@string/app_name\"\nandroid:icon=\"@mipmap/ic_launcher\"\nandroid:theme=\"@style/AppTheme\"\n+ android:networkSecurityConfig=\"@xml/network_security_config\"\n>\n<receiver android:name=\"com.evollu.react.fcm.FIRLocalMessagingPublisher\"/>\n<receiver android:enabled=\"true\" android:exported=\"true\" android:name=\"com.evollu.react.fcm.FIRSystemBootEventReceiver\">\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/android/app/src/release/res/xml/network_security_config.xml",
"diff": "+<?xml version=\"1.0\" encoding=\"utf-8\"?>\n+<network-security-config>\n+ <!-- deny cleartext traffic for React Native packager ips in release -->\n+ <domain-config cleartextTrafficPermitted=\"false\">\n+ <domain includeSubdomains=\"false\">localhost</domain>\n+ <domain includeSubdomains=\"false\">10.0.2.2</domain>\n+ <domain includeSubdomains=\"false\">10.0.3.2</domain>\n+ </domain-config>\n+</network-security-config>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Work around Android 9 cleartext network policy for Metro |
129,187 | 05.03.2019 17:17:51 | 18,000 | caf7fe97feb5234eb5bc6c41b99424810fcb6346 | [native] MessageList textHeight -> contentHeight | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -75,7 +75,7 @@ export type RobotextChatMessageInfoItemWithHeight = {|\nstartsCluster: bool,\nendsCluster: bool,\nrobotext: string,\n- textHeight: number,\n+ contentHeight: number,\n|};\nexport type ChatMessageInfoItemWithHeight =\n@@ -87,7 +87,7 @@ export type ChatMessageInfoItemWithHeight =\nstartsConversation: bool,\nstartsCluster: bool,\nendsCluster: bool,\n- textHeight: number,\n+ contentHeight: number,\n|};\ntype ChatMessageItemWithHeight =\n{| itemType: \"loader\" |} |\n@@ -336,7 +336,7 @@ class InnerMessageList extends React.PureComponent<Props, State> {\nstartsConversation: item.startsConversation,\nstartsCluster: item.startsCluster,\nendsCluster: item.endsCluster,\n- textHeight,\n+ contentHeight: textHeight,\n};\n} else {\ninvariant(\n@@ -351,7 +351,7 @@ class InnerMessageList extends React.PureComponent<Props, State> {\nstartsCluster: item.startsCluster,\nendsCluster: item.endsCluster,\nrobotext: item.robotext,\n- textHeight,\n+ contentHeight: textHeight,\n};\n}\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/robotext-message.react.js",
"new_path": "native/chat/robotext-message.react.js",
"diff": "@@ -31,7 +31,7 @@ function robotextMessageItemHeight(\nitem: ChatMessageInfoItemWithHeight,\nviewerID: ?string,\n) {\n- return 17 + item.textHeight; // for padding, margin, and text\n+ return 17 + item.contentHeight; // for padding, margin, and text\n}\ntype Props = {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/text-message.react.js",
"new_path": "native/chat/text-message.react.js",
"diff": "@@ -27,10 +27,10 @@ function textMessageItemHeight(\nitem: ChatMessageInfoItemWithHeight,\nviewerID: ?string,\n) {\n- const { messageInfo, textHeight, startsCluster, endsCluster } = item;\n+ const { messageInfo, contentHeight, startsCluster, endsCluster } = item;\nconst { id, creator } = messageInfo;\nconst { isViewer } = creator;\n- let height = 17 + textHeight; // for padding, margin, and text\n+ let height = 17 + contentHeight; // for padding, margin, and text\nif (!isViewer && startsCluster) {\nheight += 25; // for username\n}\n@@ -128,7 +128,7 @@ class TextMessage extends React.PureComponent<Props> {\nmessageStyle.backgroundColor =\nColor(messageStyle.backgroundColor).darken(0.15).hex();\n}\n- textCustomStyle.height = this.props.item.textHeight;\n+ textCustomStyle.height = this.props.item.contentHeight;\nlet deliveryIcon = null;\nlet failedSendInfo = null;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] MessageList textHeight -> contentHeight |
129,187 | 08.03.2019 10:37:01 | 18,000 | dc61c6bc8c7acc712ce338fb49badd0d56e7322c | [native] Avoid using arrow function for canReset
They are slightly less performant | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-screen-registry.js",
"new_path": "native/chat/chat-screen-registry.js",
"diff": "@@ -8,7 +8,7 @@ import React from 'react';\nconst chatSceenRegistry: {[key: string]: ?ChatScreen} = {};\n-export type ChatScreen = React.Component<*, *> & { canReset: () => bool };\n+export type ChatScreen = React.Component<*, *> & { +canReset: bool };\nfunction registerChatScreen(key: string, screen: ?ChatScreen) {\nchatSceenRegistry[key] = screen;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat-thread-list.react.js",
"new_path": "native/chat/chat-thread-list.react.js",
"diff": "@@ -114,7 +114,9 @@ class InnerChatThreadList extends React.PureComponent<Props, State> {\n}\n}\n- canReset = () => false;\n+ get canReset() {\n+ return false;\n+ }\nrenderItem = (row: { item: Item }) => {\nconst item = row.item;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/chat.react.js",
"new_path": "native/chat/chat.react.js",
"diff": "@@ -67,7 +67,7 @@ Chat.navigationOptions = ({ navigation }) => ({\nif (!chatScreen) {\nreturn;\n}\n- if (chatScreen.canReset()) {\n+ if (chatScreen.canReset) {\nnavigation.goBack(state.routes[1].key);\n}\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/compose-thread.react.js",
"new_path": "native/chat/compose-thread.react.js",
"diff": "@@ -203,7 +203,9 @@ class InnerComposeThread extends React.PureComponent<Props, State> {\nsetOnPressCreateThread(null);\n}\n- canReset = () => false;\n+ get canReset() {\n+ return false;\n+ }\ncomponentWillReceiveProps(nextProps: Props) {\nif (!this.mounted) {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -194,7 +194,9 @@ class InnerMessageList extends React.PureComponent<Props, State> {\n}\n}\n- canReset = () => true;\n+ get canReset() {\n+ return true;\n+ }\nstatic textToMeasureFromListData(listData: $ReadOnlyArray<ChatMessageItem>) {\nconst textToMeasure = [];\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "@@ -292,7 +292,7 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\n}\n}\n- canReset = () => {\n+ get canReset() {\nreturn this.props.tabActive &&\n(this.state.nameEditValue === null ||\nthis.state.nameEditValue === undefined) &&\n@@ -302,7 +302,7 @@ class InnerThreadSettings extends React.PureComponent<Props, State> {\nrender() {\nconst threadInfo = InnerThreadSettings.getThreadInfo(this.props);\n- const canStartEditing = this.canReset();\n+ const canStartEditing = this.canReset;\nconst canEditThread = threadHasPermission(\nthreadInfo,\nthreadPermissions.EDIT_THREAD,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Avoid using arrow function for canReset
They are slightly less performant |
129,187 | 08.03.2019 12:19:51 | 18,000 | f53d805f4b3f751edb3c97188cd7a17692c251e0 | [native] MessageListContainer
Separate content height measurement and navigation screen set-up into a separate component. | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat.react.js",
"new_path": "native/chat/chat.react.js",
"diff": "@@ -11,7 +11,7 @@ import { createStackNavigator } from 'react-navigation';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\nimport ChatThreadList from './chat-thread-list.react';\n-import MessageList from './message-list.react';\n+import MessageListContainer from './message-list-container.react';\nimport ComposeThread from './compose-thread.react';\nimport ThreadSettings from './settings/thread-settings.react';\nimport { getChatScreen } from './chat-screen-registry';\n@@ -31,7 +31,7 @@ import KeyboardAvoidingView from '../components/keyboard-avoiding-view.react';\nconst Chat = createStackNavigator(\n{\n[ChatThreadListRouteName]: ChatThreadList,\n- [MessageListRouteName]: MessageList,\n+ [MessageListRouteName]: MessageListContainer,\n[ComposeThreadRouteName]: ComposeThread,\n[ThreadSettingsRouteName]: ThreadSettings,\n[DeleteThreadRouteName]: DeleteThread,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/failed-send.react.js",
"new_path": "native/chat/failed-send.react.js",
"diff": "// @flow\n-import type { ChatMessageInfoItemWithHeight } from './message-list.react';\n+import type {\n+ ChatMessageInfoItemWithHeight,\n+} from './message-list-container.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport {\nmessageTypes,\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/message-list-container.react.js",
"diff": "+// @flow\n+\n+import type { AppState } from '../redux-setup';\n+import {\n+ type ComposableMessageInfo,\n+ type RobotextMessageInfo,\n+ type LocalMessageInfo,\n+ type FetchMessageInfosPayload,\n+ messageTypes,\n+} from 'lib/types/message-types';\n+import {\n+ type ChatMessageItem,\n+ chatMessageItemPropType,\n+} from 'lib/selectors/chat-selectors';\n+import { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\n+import type {\n+ NavigationScreenProp,\n+ NavigationLeafRoute,\n+} from 'react-navigation';\n+import type { TextToMeasure } from '../text-height-measurer.react';\n+\n+import * as React from 'react';\n+import PropTypes from 'prop-types';\n+import { View, Platform, StyleSheet, ActivityIndicator } from 'react-native';\n+import _isEqual from 'lodash/fp/isEqual';\n+import _differenceWith from 'lodash/fp/differenceWith';\n+import invariant from 'invariant';\n+\n+import { connect } from 'lib/utils/redux-utils';\n+import { threadInfoSelector } from 'lib/selectors/thread-selectors';\n+import { messageListData } from 'lib/selectors/chat-selectors';\n+import { messageKey, robotextToRawString } from 'lib/shared/message-utils';\n+import { onlyEmojiRegex } from 'lib/shared/emojis';\n+\n+import MessageList from './message-list.react';\n+import MessageListHeaderTitle from './message-list-header-title.react';\n+import ThreadSettingsButton from './thread-settings-button.react';\n+import { registerChatScreen } from './chat-screen-registry';\n+import TextHeightMeasurer from '../text-height-measurer.react';\n+import ChatInputBar from './chat-input-bar.react';\n+\n+export type ChatMessageInfoItemWithHeight =\n+ | {|\n+ itemType: \"message\",\n+ messageInfo: RobotextMessageInfo,\n+ threadInfo: ThreadInfo,\n+ startsConversation: bool,\n+ startsCluster: bool,\n+ endsCluster: bool,\n+ robotext: string,\n+ contentHeight: number,\n+ |}\n+ | {|\n+ itemType: \"message\",\n+ messageInfo: ComposableMessageInfo,\n+ localMessageInfo: ?LocalMessageInfo,\n+ threadInfo: ThreadInfo,\n+ startsConversation: bool,\n+ startsCluster: bool,\n+ endsCluster: bool,\n+ contentHeight: number,\n+ |};\n+export type ChatMessageItemWithHeight =\n+ {| itemType: \"loader\" |} |\n+ ChatMessageInfoItemWithHeight;\n+\n+type NavProp = NavigationScreenProp<{|\n+ ...NavigationLeafRoute,\n+ params: {|\n+ threadInfo: ThreadInfo,\n+ |},\n+|}>;\n+\n+type Props = {|\n+ navigation: NavProp,\n+ // Redux state\n+ threadInfo: ?ThreadInfo,\n+ messageListData: $ReadOnlyArray<ChatMessageItem>,\n+|};\n+type State = {|\n+ textToMeasure: TextToMeasure[],\n+ listDataWithHeights: ?$ReadOnlyArray<ChatMessageItemWithHeight>,\n+|};\n+class MessageListContainer extends React.PureComponent<Props, State> {\n+\n+ static propTypes = {\n+ navigation: PropTypes.shape({\n+ state: PropTypes.shape({\n+ key: PropTypes.string.isRequired,\n+ params: PropTypes.shape({\n+ threadInfo: threadInfoPropType.isRequired,\n+ }).isRequired,\n+ }).isRequired,\n+ navigate: PropTypes.func.isRequired,\n+ setParams: PropTypes.func.isRequired,\n+ }).isRequired,\n+ threadInfo: threadInfoPropType,\n+ messageListData: PropTypes.arrayOf(chatMessageItemPropType).isRequired,\n+ };\n+ static navigationOptions = ({ navigation }) => ({\n+ headerTitle: (\n+ <MessageListHeaderTitle\n+ threadInfo={navigation.state.params.threadInfo}\n+ navigate={navigation.navigate}\n+ />\n+ ),\n+ headerRight:\n+ Platform.OS === \"android\"\n+ ? (\n+ <ThreadSettingsButton\n+ threadInfo={navigation.state.params.threadInfo}\n+ navigate={navigation.navigate}\n+ />\n+ )\n+ : null,\n+ headerBackTitle: \"Back\",\n+ });\n+\n+ constructor(props: Props) {\n+ super(props);\n+ const textToMeasure = props.messageListData\n+ ? MessageListContainer.textToMeasureFromListData(props.messageListData)\n+ : [];\n+ const listDataWithHeights =\n+ props.messageListData && textToMeasure.length === 0\n+ ? this.mergeHeightsIntoListData()\n+ : null;\n+ this.state = { textToMeasure, listDataWithHeights };\n+ }\n+\n+ static textToMeasureFromListData(listData: $ReadOnlyArray<ChatMessageItem>) {\n+ const textToMeasure = [];\n+ for (let item of listData) {\n+ if (item.itemType !== \"message\") {\n+ continue;\n+ }\n+ const { messageInfo } = item;\n+ if (messageInfo.type === messageTypes.TEXT) {\n+ const { isViewer } = messageInfo.creator;\n+ const style = [\n+ onlyEmojiRegex.test(messageInfo.text)\n+ ? styles.emojiOnlyText\n+ : styles.text,\n+ isViewer ? styles.viewerMargins : styles.nonViewerMargins,\n+ ];\n+ textToMeasure.push({\n+ id: messageKey(messageInfo),\n+ text: messageInfo.text,\n+ style,\n+ });\n+ } else {\n+ invariant(\n+ item.robotext && typeof item.robotext === \"string\",\n+ \"Flow can't handle our fancy types :(\",\n+ );\n+ textToMeasure.push({\n+ id: messageKey(messageInfo),\n+ text: robotextToRawString(item.robotext),\n+ style: styles.robotext,\n+ });\n+ }\n+ }\n+ return textToMeasure;\n+ }\n+\n+ static getThreadInfo(props: Props): ThreadInfo {\n+ return props.navigation.state.params.threadInfo;\n+ }\n+\n+ componentDidMount() {\n+ registerChatScreen(this.props.navigation.state.key, this);\n+ }\n+\n+ componentWillUnmount() {\n+ registerChatScreen(this.props.navigation.state.key, null);\n+ }\n+\n+ get canReset() {\n+ return true;\n+ }\n+\n+ componentDidUpdate(prevProps: Props) {\n+ const oldThreadInfo = MessageListContainer.getThreadInfo(prevProps);\n+ const newThreadInfo = this.props.threadInfo;\n+ const threadInfoChanged = !_isEqual(newThreadInfo)(oldThreadInfo);\n+\n+ if (newThreadInfo && threadInfoChanged) {\n+ this.props.navigation.setParams({ threadInfo: newThreadInfo });\n+ }\n+\n+ const oldListData = prevProps.messageListData;\n+ const newListData = this.props.messageListData;\n+ if (!newListData && oldListData) {\n+ this.setState({\n+ textToMeasure: [],\n+ listDataWithHeights: null,\n+ });\n+ }\n+ if (!newListData) {\n+ return;\n+ }\n+ if (newListData === oldListData && !threadInfoChanged) {\n+ return;\n+ }\n+\n+ const newTextToMeasure =\n+ MessageListContainer.textToMeasureFromListData(newListData);\n+ this.setState({ textToMeasure: newTextToMeasure });\n+ }\n+\n+ render() {\n+ const threadInfo = MessageListContainer.getThreadInfo(this.props);\n+ const { listDataWithHeights } = this.state;\n+\n+ let messageList;\n+ if (listDataWithHeights) {\n+ messageList = (\n+ <MessageList\n+ threadInfo={threadInfo}\n+ messageListData={listDataWithHeights}\n+ />\n+ );\n+ } else {\n+ messageList = (\n+ <View style={styles.loadingIndicatorContainer}>\n+ <ActivityIndicator\n+ color=\"black\"\n+ size=\"large\"\n+ style={styles.loadingIndicator}\n+ />\n+ </View>\n+ );\n+ }\n+\n+ return (\n+ <View style={styles.container}>\n+ <TextHeightMeasurer\n+ textToMeasure={this.state.textToMeasure}\n+ allHeightsMeasuredCallback={this.allHeightsMeasured}\n+ />\n+ {messageList}\n+ <ChatInputBar threadInfo={threadInfo} />\n+ </View>\n+ );\n+ }\n+\n+ allHeightsMeasured = (\n+ textToMeasure: TextToMeasure[],\n+ newTextHeights: Map<string, number>,\n+ ) => {\n+ if (textToMeasure !== this.state.textToMeasure) {\n+ return;\n+ }\n+ if (!this.props.messageListData) {\n+ return;\n+ }\n+ const listDataWithHeights = this.mergeHeightsIntoListData(newTextHeights);\n+ this.setState({ listDataWithHeights });\n+ }\n+\n+ mergeHeightsIntoListData(textHeights?: Map<string, number>) {\n+ const listData = this.props.messageListData;\n+ const threadInfo = MessageListContainer.getThreadInfo(this.props);\n+ const listDataWithHeights = listData.map((item: ChatMessageItem) => {\n+ if (item.itemType !== \"message\") {\n+ return item;\n+ }\n+ const { messageInfo } = item;\n+ invariant(textHeights, \"textHeights not set\");\n+ const id = messageKey(messageInfo);\n+ const textHeight = textHeights.get(id);\n+ invariant(textHeight, `height for ${id} should be set`);\n+ if (\n+ messageInfo.type === messageTypes.TEXT ||\n+ messageInfo.type === messageTypes.MULTIMEDIA\n+ ) {\n+ // Conditional due to Flow...\n+ const localMessageInfo = item.localMessageInfo\n+ ? item.localMessageInfo\n+ : null;\n+ return {\n+ itemType: \"message\",\n+ messageInfo,\n+ localMessageInfo,\n+ threadInfo,\n+ startsConversation: item.startsConversation,\n+ startsCluster: item.startsCluster,\n+ endsCluster: item.endsCluster,\n+ contentHeight: textHeight,\n+ };\n+ } else {\n+ invariant(\n+ typeof item.robotext === \"string\",\n+ \"Flow can't handle our fancy types :(\",\n+ );\n+ return {\n+ itemType: \"message\",\n+ messageInfo,\n+ threadInfo,\n+ startsConversation: item.startsConversation,\n+ startsCluster: item.startsCluster,\n+ endsCluster: item.endsCluster,\n+ robotext: item.robotext,\n+ contentHeight: textHeight,\n+ };\n+ }\n+ });\n+ return listDataWithHeights;\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ container: {\n+ flex: 1,\n+ },\n+ loadingIndicator: {\n+ flex: 1,\n+ },\n+ loadingIndicatorContainer: {\n+ flex: 1,\n+ },\n+ viewerMargins: {\n+ left: 24,\n+ right: 42,\n+ },\n+ nonViewerMargins: {\n+ left: 24,\n+ right: 24,\n+ },\n+ text: {\n+ fontSize: 18,\n+ fontFamily: 'Arial',\n+ },\n+ emojiOnlyText: {\n+ fontSize: 36,\n+ fontFamily: 'Arial',\n+ },\n+ robotext: {\n+ left: 24,\n+ right: 24,\n+ fontSize: 15,\n+ fontFamily: 'Arial',\n+ },\n+});\n+\n+export default connect(\n+ (state: AppState, ownProps: { navigation: NavProp }) => {\n+ const threadID = ownProps.navigation.state.params.threadInfo.id;\n+ return {\n+ threadInfo: threadInfoSelector(state)[threadID],\n+ messageListData: messageListData(threadID)(state),\n+ };\n+ },\n+)(MessageListContainer);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "// @flow\nimport type { AppState } from '../redux-setup';\n-import type { NavigationScreenProp, NavigationRoute } from 'react-navigation';\nimport { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\n-import {\n- type ChatMessageItem,\n- type ChatMessageInfoItem,\n- chatMessageItemPropType,\n-} from 'lib/selectors/chat-selectors';\n+import { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport type { ViewToken } from 'react-native/Libraries/Lists/ViewabilityHelper';\n-import {\n- type ComposableMessageInfo,\n- type RobotextMessageInfo,\n- type LocalMessageInfo,\n- type FetchMessageInfosPayload,\n- messageTypes,\n-} from 'lib/types/message-types';\n+import type { FetchMessageInfosPayload } from 'lib/types/message-types';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\n-import type { TextToMeasure } from '../text-height-measurer.react';\n+import type {\n+ ChatMessageInfoItemWithHeight,\n+ ChatMessageItemWithHeight,\n+} from './message-list-container.react';\n-import React from 'react';\n+import * as React from 'react';\nimport PropTypes from 'prop-types';\n-import {\n- View,\n- StyleSheet,\n- ActivityIndicator,\n- Platform,\n- FlatList,\n- DeviceInfo,\n-} from 'react-native';\n-import invariant from 'invariant';\n+import { View, StyleSheet, FlatList } from 'react-native';\nimport _sum from 'lodash/fp/sum';\n-import _differenceWith from 'lodash/fp/differenceWith';\nimport _find from 'lodash/fp/find';\n-import _isEqual from 'lodash/fp/isEqual';\n-import { messageKey, robotextToRawString } from 'lib/shared/message-utils';\n+import { messageKey } from 'lib/shared/message-utils';\nimport { connect } from 'lib/utils/redux-utils';\nimport {\nfetchMessagesBeforeCursorActionTypes,\n@@ -46,60 +28,16 @@ import {\nimport threadWatcher from 'lib/shared/thread-watcher';\nimport { threadInChatList } from 'lib/shared/thread-utils';\nimport { registerFetchKey } from 'lib/reducers/loading-reducer';\n-import { threadInfoSelector } from 'lib/selectors/thread-selectors';\n-import { onlyEmojiRegex } from 'lib/shared/emojis';\n-import { messageListData } from 'lib/selectors/chat-selectors';\nimport { Message, messageItemHeight } from './message.react';\n-import TextHeightMeasurer from '../text-height-measurer.react';\n-import ChatInputBar from './chat-input-bar.react';\nimport ListLoadingIndicator from '../list-loading-indicator.react';\n-import MessageListHeaderTitle from './message-list-header-title.react';\n-import { registerChatScreen } from './chat-screen-registry';\n-import ThreadSettingsButton from './thread-settings-button.react';\n-\n-type NavProp =\n- & {\n- state: {\n- params: { threadInfo: ThreadInfo },\n- key: string,\n- },\n- }\n- & NavigationScreenProp<NavigationRoute>;\n-\n-export type RobotextChatMessageInfoItemWithHeight = {|\n- itemType: \"message\",\n- messageInfo: RobotextMessageInfo,\n- threadInfo: ThreadInfo,\n- startsConversation: bool,\n- startsCluster: bool,\n- endsCluster: bool,\n- robotext: string,\n- contentHeight: number,\n-|};\n-export type ChatMessageInfoItemWithHeight =\n- RobotextChatMessageInfoItemWithHeight | {|\n- itemType: \"message\",\n- messageInfo: ComposableMessageInfo,\n- localMessageInfo: ?LocalMessageInfo,\n+type Props = {|\nthreadInfo: ThreadInfo,\n- startsConversation: bool,\n- startsCluster: bool,\n- endsCluster: bool,\n- contentHeight: number,\n- |};\n-type ChatMessageItemWithHeight =\n- {| itemType: \"loader\" |} |\n- ChatMessageInfoItemWithHeight;\n-\n-type Props = {\n- navigation: NavProp,\n+ messageListData: $ReadOnlyArray<ChatMessageItemWithHeight>,\n// Redux state\n- messageListData: $ReadOnlyArray<ChatMessageItem>,\nviewerID: ?string,\nstartReached: bool,\n- threadInfo: ?ThreadInfo,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -110,73 +48,28 @@ type Props = {\nfetchMostRecentMessages: (\nthreadID: string,\n) => Promise<FetchMessageInfosPayload>,\n-};\n-type State = {\n- textToMeasure: TextToMeasure[],\n- listDataWithHeights: ?$ReadOnlyArray<ChatMessageItemWithHeight>,\n+|};\n+type State = {|\nfocusedMessageKey: ?string,\n-};\n-class InnerMessageList extends React.PureComponent<Props, State> {\n+|};\n+class MessageList extends React.PureComponent<Props, State> {\nstatic propTypes = {\n- navigation: PropTypes.shape({\n- state: PropTypes.shape({\n- key: PropTypes.string.isRequired,\n- params: PropTypes.shape({\nthreadInfo: threadInfoPropType.isRequired,\n- }).isRequired,\n- }).isRequired,\n- navigate: PropTypes.func.isRequired,\n- setParams: PropTypes.func.isRequired,\n- }).isRequired,\nmessageListData: PropTypes.arrayOf(chatMessageItemPropType).isRequired,\nviewerID: PropTypes.string,\nstartReached: PropTypes.bool.isRequired,\n- threadInfo: threadInfoPropType,\ndispatchActionPromise: PropTypes.func.isRequired,\nfetchMessagesBeforeCursor: PropTypes.func.isRequired,\nfetchMostRecentMessages: PropTypes.func.isRequired,\n};\n- static navigationOptions = ({ navigation }) => ({\n- headerTitle: (\n- <MessageListHeaderTitle\n- threadInfo={navigation.state.params.threadInfo}\n- navigate={navigation.navigate}\n- />\n- ),\n- headerRight:\n- Platform.OS === \"android\"\n- ? (\n- <ThreadSettingsButton\n- threadInfo={navigation.state.params.threadInfo}\n- navigate={navigation.navigate}\n- />\n- )\n- : null,\n- headerBackTitle: \"Back\",\n- });\n- textHeights: ?Map<string, number> = null;\nloadingFromScroll = false;\n-\n- constructor(props: Props) {\n- super(props);\n- const textToMeasure = props.messageListData\n- ? InnerMessageList.textToMeasureFromListData(props.messageListData)\n- : [];\n- this.state = {\n- textToMeasure,\n- listDataWithHeights: null,\n+ state = {\nfocusedMessageKey: null,\n};\n- }\n-\n- static getThreadInfo(props: Props): ThreadInfo {\n- return props.navigation.state.params.threadInfo;\n- }\ncomponentDidMount() {\n- const threadInfo = InnerMessageList.getThreadInfo(this.props);\n- registerChatScreen(this.props.navigation.state.key, this);\n+ const { threadInfo } = this.props;\nif (!threadInChatList(threadInfo)) {\nthreadWatcher.watchID(threadInfo.id);\nthis.props.dispatchActionPromise(\n@@ -187,62 +80,15 @@ class InnerMessageList extends React.PureComponent<Props, State> {\n}\ncomponentWillUnmount() {\n- const threadInfo = InnerMessageList.getThreadInfo(this.props);\n- registerChatScreen(this.props.navigation.state.key, null);\n+ const { threadInfo } = this.props;\nif (!threadInChatList(threadInfo)) {\nthreadWatcher.removeID(threadInfo.id);\n}\n}\n- get canReset() {\n- return true;\n- }\n-\n- static textToMeasureFromListData(listData: $ReadOnlyArray<ChatMessageItem>) {\n- const textToMeasure = [];\n- for (let item of listData) {\n- if (item.itemType !== \"message\") {\n- continue;\n- }\n- const { messageInfo } = item;\n- if (messageInfo.type === messageTypes.TEXT) {\n- const { isViewer } = messageInfo.creator;\n- const style = [\n- onlyEmojiRegex.test(messageInfo.text)\n- ? styles.emojiOnlyText\n- : styles.text,\n- isViewer ? styles.viewerMargins : styles.nonViewerMargins,\n- ];\n- textToMeasure.push({\n- id: messageKey(messageInfo),\n- text: messageInfo.text,\n- style,\n- });\n- } else {\n- invariant(\n- item.robotext && typeof item.robotext === \"string\",\n- \"Flow can't handle our fancy types :(\",\n- );\n- textToMeasure.push({\n- id: messageKey(messageInfo),\n- text: robotextToRawString(item.robotext),\n- style: styles.robotext,\n- });\n- }\n- }\n- return textToMeasure;\n- }\n-\n- componentWillReceiveProps(nextProps: Props) {\n- const oldThreadInfo = InnerMessageList.getThreadInfo(this.props);\n- const newThreadInfo = nextProps.threadInfo;\n-\n- let threadInfoChanged = false;\n- if (newThreadInfo && !_isEqual(newThreadInfo)(oldThreadInfo)) {\n- threadInfoChanged = true;\n- this.props.navigation.setParams({ threadInfo: newThreadInfo });\n- }\n-\n+ componentDidUpdate(prevProps: Props) {\n+ const oldThreadInfo = prevProps.threadInfo;\n+ const newThreadInfo = this.props.threadInfo;\nif (\nthreadInChatList(oldThreadInfo) &&\n!threadInChatList(newThreadInfo)\n@@ -255,109 +101,14 @@ class InnerMessageList extends React.PureComponent<Props, State> {\nthreadWatcher.removeID(oldThreadInfo.id);\n}\n- const oldListData = this.props.messageListData;\n- const newListData = nextProps.messageListData;\n- if (!newListData && oldListData) {\n- this.setState({\n- textToMeasure: [],\n- listDataWithHeights: null,\n- focusedMessageKey: null,\n- });\n- }\n- if (!newListData) {\n- return;\n- }\n-\n- if (newListData === oldListData && !threadInfoChanged) {\n- return;\n- }\n-\n- const newTextToMeasure = InnerMessageList.textToMeasureFromListData(\n- newListData,\n- );\n-\n- let allTextAlreadyMeasured = false;\n- if (this.textHeights) {\n- allTextAlreadyMeasured = true;\n- for (let textToMeasure of newTextToMeasure) {\n- if (!this.textHeights.has(textToMeasure.id)) {\n- allTextAlreadyMeasured = false;\n- break;\n- }\n- }\n- }\n-\n- if (allTextAlreadyMeasured) {\n- this.mergeHeightsIntoListData(newListData);\n- return;\n- }\n-\n- const newText =\n- _differenceWith(_isEqual)(newTextToMeasure)(this.state.textToMeasure);\n- if (newText.length === 0) {\n- // Since we don't have everything in textHeights, but we do have\n- // everything in textToMeasure, we can conclude that we're just\n- // waiting for the measurement to complete and then we'll be good.\n- } else {\n- // We set textHeights to null here since if a future set of text\n- // came in before we completed text measurement that was a subset\n- // of the earlier text, we would end up merging directly there, but\n- // then when the measurement for the middle text came in it would\n- // override the newer text heights.\n- this.textHeights = null;\n- this.setState({ textToMeasure: newTextToMeasure });\n- }\n- }\n-\n- mergeHeightsIntoListData(listData: $ReadOnlyArray<ChatMessageItem>) {\n- const threadInfo = InnerMessageList.getThreadInfo(this.props);\n- const textHeights = this.textHeights;\n- invariant(textHeights, \"textHeights should be set\");\n- const listDataWithHeights = listData.map((item: ChatMessageItem) => {\n- if (item.itemType !== \"message\") {\n- return item;\n- }\n- const textHeight = textHeights.get(messageKey(item.messageInfo));\n- invariant(\n- textHeight,\n- `height for ${messageKey(item.messageInfo)} should be set`,\n- );\n+ const newListData = this.props.messageListData;\n+ const oldListData = prevProps.messageListData;\nif (\n- item.messageInfo.type === messageTypes.TEXT ||\n- item.messageInfo.type === messageTypes.MULTIMEDIA\n+ this.loadingFromScroll &&\n+ (newListData.length > oldListData.length || this.props.startReached)\n) {\n- // Conditional due to Flow...\n- const localMessageInfo = item.localMessageInfo\n- ? item.localMessageInfo\n- : null;\n- return {\n- itemType: \"message\",\n- messageInfo: item.messageInfo,\n- localMessageInfo,\n- threadInfo,\n- startsConversation: item.startsConversation,\n- startsCluster: item.startsCluster,\n- endsCluster: item.endsCluster,\n- contentHeight: textHeight,\n- };\n- } else {\n- invariant(\n- typeof item.robotext === \"string\",\n- \"Flow can't handle our fancy types :(\",\n- );\n- return {\n- itemType: \"message\",\n- messageInfo: item.messageInfo,\n- threadInfo,\n- startsConversation: item.startsConversation,\n- startsCluster: item.startsCluster,\n- endsCluster: item.endsCluster,\n- robotext: item.robotext,\n- contentHeight: textHeight,\n- };\n+ this.loadingFromScroll = false;\n}\n- });\n- this.setState({ listDataWithHeights });\n}\nrenderItem = (row: { item: ChatMessageItemWithHeight }) => {\n@@ -384,20 +135,6 @@ class InnerMessageList extends React.PureComponent<Props, State> {\n}\n}\n- componentDidUpdate(prevProps: Props, prevState: State) {\n- if (!this.loadingFromScroll || !this.state.listDataWithHeights) {\n- return;\n- }\n- if (\n- !prevState.listDataWithHeights ||\n- this.state.listDataWithHeights.length >\n- prevState.listDataWithHeights.length ||\n- this.props.startReached\n- ) {\n- this.loadingFromScroll = false;\n- }\n- }\n-\nstatic keyExtractor(item: ChatMessageItemWithHeight) {\nif (item.itemType === \"loader\") {\nreturn \"loader\";\n@@ -435,67 +172,25 @@ class InnerMessageList extends React.PureComponent<Props, State> {\n}\nrender() {\n- const listDataWithHeights = this.state.listDataWithHeights;\n- let flatList = null;\n- if (listDataWithHeights) {\n- const footer = this.props.startReached\n- ? InnerMessageList.ListFooterComponent\n- : undefined;\n- flatList = (\n+ const { messageListData, startReached } = this.props;\n+ const footer = startReached ? MessageList.ListFooterComponent : undefined;\n+ return (\n+ <View style={styles.container}>\n<FlatList\ninverted={true}\n- data={listDataWithHeights}\n+ data={messageListData}\nrenderItem={this.renderItem}\n- keyExtractor={InnerMessageList.keyExtractor}\n+ keyExtractor={MessageList.keyExtractor}\ngetItemLayout={this.getItemLayout}\nonViewableItemsChanged={this.onViewableItemsChanged}\nListFooterComponent={footer}\nscrollsToTop={false}\nextraData={this.state.focusedMessageKey}\n/>\n- );\n- } else {\n- flatList = (\n- <View style={styles.loadingIndicatorContainer}>\n- <ActivityIndicator\n- color=\"black\"\n- size=\"large\"\n- style={styles.loadingIndicator}\n- />\n</View>\n);\n}\n- const threadInfo = InnerMessageList.getThreadInfo(this.props);\n- const inputBar = <ChatInputBar threadInfo={threadInfo} />;\n-\n- return (\n- <View style={styles.container}>\n- <TextHeightMeasurer\n- textToMeasure={this.state.textToMeasure}\n- allHeightsMeasuredCallback={this.allHeightsMeasured}\n- />\n- <View style={styles.flatListContainer}>\n- {flatList}\n- </View>\n- {inputBar}\n- </View>\n- );\n- }\n-\n- allHeightsMeasured = (\n- textToMeasure: TextToMeasure[],\n- newTextHeights: Map<string, number>,\n- ) => {\n- if (textToMeasure !== this.state.textToMeasure) {\n- return;\n- }\n- this.textHeights = newTextHeights;\n- if (this.props.messageListData) {\n- this.mergeHeightsIntoListData(this.props.messageListData);\n- }\n- }\n-\nonViewableItemsChanged = (info: {\nviewableItems: ViewToken[],\nchanged: ViewToken[],\n@@ -524,7 +219,7 @@ class InnerMessageList extends React.PureComponent<Props, State> {\nconst oldestMessageServerID = this.oldestMessageServerID();\nif (oldestMessageServerID) {\nthis.loadingFromScroll = true;\n- const threadID = InnerMessageList.getThreadInfo(this.props).id;\n+ const threadID = this.props.threadInfo.id;\nthis.props.dispatchActionPromise(\nfetchMessagesBeforeCursorActionTypes,\nthis.props.fetchMessagesBeforeCursor(\n@@ -550,39 +245,8 @@ class InnerMessageList extends React.PureComponent<Props, State> {\nconst styles = StyleSheet.create({\ncontainer: {\nflex: 1,\n- },\n- flatListContainer: {\n- flex: 1,\nbackgroundColor: '#FFFFFF',\n},\n- viewerMargins: {\n- left: 24,\n- right: 42,\n- },\n- nonViewerMargins: {\n- left: 24,\n- right: 24,\n- },\n- text: {\n- fontSize: 18,\n- fontFamily: 'Arial',\n- },\n- emojiOnlyText: {\n- fontSize: 36,\n- fontFamily: 'Arial',\n- },\n- robotext: {\n- left: 24,\n- right: 24,\n- fontSize: 15,\n- fontFamily: 'Arial',\n- },\n- loadingIndicator: {\n- flex: 1,\n- },\n- loadingIndicatorContainer: {\n- flex: 1,\n- },\nheader: {\nheight: 12,\n},\n@@ -591,18 +255,14 @@ const styles = StyleSheet.create({\nregisterFetchKey(fetchMessagesBeforeCursorActionTypes);\nregisterFetchKey(fetchMostRecentMessagesActionTypes);\n-const MessageList = connect(\n- (state: AppState, ownProps: { navigation: NavProp }) => {\n- const threadID = ownProps.navigation.state.params.threadInfo.id;\n+export default connect(\n+ (state: AppState, ownProps: { threadInfo: ThreadInfo }) => {\n+ const threadID = ownProps.threadInfo.id;\nreturn {\n- messageListData: messageListData(threadID)(state),\nviewerID: state.currentUserInfo && state.currentUserInfo.id,\nstartReached: !!(state.messageStore.threads[threadID] &&\nstate.messageStore.threads[threadID].startReached),\n- threadInfo: threadInfoSelector(state)[threadID],\n};\n},\n{ fetchMessagesBeforeCursor, fetchMostRecentMessages },\n-)(InnerMessageList);\n-\n-export default MessageList;\n+)(MessageList);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message.react.js",
"new_path": "native/chat/message.react.js",
"diff": "// @flow\n-import type { ChatMessageInfoItemWithHeight } from './message-list.react';\n+import type {\n+ ChatMessageInfoItemWithHeight,\n+} from './message-list-container.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport { messageTypes } from 'lib/types/message-types';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message.react.js",
"new_path": "native/chat/multimedia-message.react.js",
"diff": "// @flow\n-import type { ChatMessageInfoItemWithHeight } from './message-list.react';\n+import type {\n+ ChatMessageInfoItemWithHeight,\n+} from './message-list-container.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport { messageTypes } from 'lib/types/message-types';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/robotext-message.react.js",
"new_path": "native/chat/robotext-message.react.js",
"diff": "// @flow\nimport { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\n-import type { ChatMessageInfoItemWithHeight } from './message-list.react';\n+import type {\n+ ChatMessageInfoItemWithHeight,\n+} from './message-list-container.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport type { Dispatch } from 'lib/types/redux-types';\nimport type { AppState } from '../redux-setup';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/text-message.react.js",
"new_path": "native/chat/text-message.react.js",
"diff": "// @flow\n-import type { ChatMessageInfoItemWithHeight } from './message-list.react';\n+import type {\n+ ChatMessageInfoItemWithHeight,\n+} from './message-list-container.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport type { TooltipItemData } from '../components/tooltip.react';\nimport {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/text-height-measurer.react.js",
"new_path": "native/text-height-measurer.react.js",
"diff": "@@ -13,13 +13,13 @@ import _isEqual from 'lodash/fp/isEqual';\nconst measureBatchSize = 50;\n-export type TextToMeasure = {\n+export type TextToMeasure = {|\nid: string,\ntext: string,\nstyle?: TextStyle,\n-};\n+|};\ntype TextToHeight = Map<string, number>;\n-type Props = {\n+type Props = {|\ntextToMeasure: TextToMeasure[],\nallHeightsMeasuredCallback: (\ntextToMeasure: TextToMeasure[],\n@@ -27,10 +27,10 @@ type Props = {\n) => void,\nminHeight?: number,\nstyle?: TextStyle,\n-};\n-type State = {\n+|};\n+type State = {|\ncurrentlyMeasuring: ?Set<TextToMeasure>,\n-};\n+|};\nclass TextHeightMeasurer extends React.PureComponent<Props, State> {\nstate = {\n@@ -73,13 +73,13 @@ class TextHeightMeasurer extends React.PureComponent<Props, State> {\nthis.leftToMeasure.add(textToMeasure);\n}\n- const existingTextToMeasure =\n- _intersectionWith(_isEqual)(nextTextToMeasure)(this.props.textToMeasure);\n- for (let textToMeasure of existingTextToMeasure) {\n- const id = textToMeasure.id;\nconst existingTextToHeight = this.nextTextToHeight\n? this.nextTextToHeight\n: this.currentTextToHeight;\n+ const existingTextToMeasure =\n+ _intersectionWith(_isEqual)(nextTextToMeasure)(this.props.textToMeasure);\n+ for (let textToMeasure of existingTextToMeasure) {\n+ const { id } = textToMeasure;\nconst measuredHeight = existingTextToHeight.get(id);\nif (measuredHeight !== undefined) {\nnextNextTextToHeight.set(id, measuredHeight);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] MessageListContainer
Separate content height measurement and navigation screen set-up into a separate component. |
129,187 | 08.03.2019 15:11:18 | 18,000 | 6e14ff9c9cfc0a814c66b96e68303f1eb25c6f3c | [native] Rendering fake shim for MultimediaMessage | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-container.react.js",
"new_path": "native/chat/message-list-container.react.js",
"diff": "@@ -148,11 +148,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\ntext: messageInfo.text,\nstyle,\n});\n- } else {\n- invariant(\n- item.robotext && typeof item.robotext === \"string\",\n- \"Flow can't handle our fancy types :(\",\n- );\n+ } else if (item.robotext && typeof item.robotext === \"string\") {\ntextToMeasure.push({\nid: messageKey(messageInfo),\ntext: robotextToRawString(item.robotext),\n@@ -266,14 +262,30 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nreturn item;\n}\nconst { messageInfo } = item;\n+ if (messageInfo.type === messageTypes.MULTIMEDIA) {\n+ // Conditional due to Flow...\n+ const localMessageInfo = item.localMessageInfo\n+ ? item.localMessageInfo\n+ : null;\n+ return {\n+ itemType: \"message\",\n+ messageInfo,\n+ localMessageInfo,\n+ threadInfo,\n+ startsConversation: item.startsConversation,\n+ startsCluster: item.startsCluster,\n+ endsCluster: item.endsCluster,\n+ contentHeight: 100, // TODO\n+ };\n+ }\ninvariant(textHeights, \"textHeights not set\");\nconst id = messageKey(messageInfo);\nconst textHeight = textHeights.get(id);\n- invariant(textHeight, `height for ${id} should be set`);\n- if (\n- messageInfo.type === messageTypes.TEXT ||\n- messageInfo.type === messageTypes.MULTIMEDIA\n- ) {\n+ invariant(\n+ textHeight !== null && textHeight !== undefined,\n+ `height for ${id} should be set`,\n+ );\n+ if (messageInfo.type === messageTypes.TEXT) {\n// Conditional due to Flow...\nconst localMessageInfo = item.localMessageInfo\n? item.localMessageInfo\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message.react.js",
"new_path": "native/chat/message.react.js",
"diff": "@@ -20,7 +20,10 @@ import {\nRobotextMessage,\nrobotextMessageItemHeight,\n} from './robotext-message.react';\n-import MultimediaMessage from './multimedia-message.react';\n+import {\n+ MultimediaMessage,\n+ multimediaMessageItemHeight,\n+} from './multimedia-message.react';\nfunction messageItemHeight(\nitem: ChatMessageInfoItemWithHeight,\n@@ -29,6 +32,8 @@ function messageItemHeight(\nlet height = 0;\nif (item.messageInfo.type === messageTypes.TEXT) {\nheight += textMessageItemHeight(item, viewerID);\n+ } else if (item.messageInfo.type === messageTypes.MULTIMEDIA) {\n+ height += multimediaMessageItemHeight(item, viewerID);\n} else {\nheight += robotextMessageItemHeight(item, viewerID);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message.react.js",
"new_path": "native/chat/multimedia-message.react.js",
"diff": "@@ -17,6 +17,32 @@ import PropTypes from 'prop-types';\nimport { messageKey } from 'lib/shared/message-utils';\n+function multimediaMessageItemHeight(\n+ item: ChatMessageInfoItemWithHeight,\n+ viewerID: ?string,\n+) {\n+ // TODO\n+ const { messageInfo, contentHeight, startsCluster, endsCluster } = item;\n+ const { id, creator } = messageInfo;\n+ const { isViewer } = creator;\n+ let height = 17 + contentHeight; // for padding, margin, and text\n+ if (!isViewer && startsCluster) {\n+ height += 25; // for username\n+ }\n+ if (endsCluster) {\n+ height += 7; // extra padding at the end of a cluster\n+ }\n+ if (\n+ isViewer &&\n+ id !== null && id !== undefined &&\n+ item.localMessageInfo &&\n+ item.localMessageInfo.sendFailed\n+ ) {\n+ height += 22; // extra padding at the end of a cluster\n+ }\n+ return height;\n+}\n+\ntype Props = {|\nitem: ChatMessageInfoItemWithHeight,\ntoggleFocus: (messageKey: string) => void,\n@@ -69,4 +95,7 @@ const styles = StyleSheet.create({\n},\n});\n-export default MultimediaMessage;\n+export {\n+ MultimediaMessage,\n+ multimediaMessageItemHeight,\n+};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Rendering fake shim for MultimediaMessage |
129,187 | 08.03.2019 15:59:17 | 18,000 | 41e4db85399a47bce03a117fbc8ac9989c198ced | [native] Enable MultimediaMessage to update contentHeight
Still have to write the code to actually calculate it, as well as rendering it.
Also need to make `multimediaMessageLoadingContentHeight` a function that depends on number of multimedia. | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-container.react.js",
"new_path": "native/chat/message-list-container.react.js",
"diff": "@@ -38,6 +38,9 @@ import ThreadSettingsButton from './thread-settings-button.react';\nimport { registerChatScreen } from './chat-screen-registry';\nimport TextHeightMeasurer from '../text-height-measurer.react';\nimport ChatInputBar from './chat-input-bar.react';\n+import {\n+ multimediaMessageLoadingContentHeight,\n+} from './multimedia-message.react';\nexport type ChatMessageInfoItemWithHeight =\n| {|\n@@ -115,6 +118,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n: null,\nheaderBackTitle: \"Back\",\n});\n+ updatedHeights: Map<string, number> = new Map();\nconstructor(props: Props) {\nsuper(props);\n@@ -214,6 +218,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n<MessageList\nthreadInfo={threadInfo}\nmessageListData={listDataWithHeights}\n+ updateHeightForMessage={this.updateHeightForMessage}\n/>\n);\n} else {\n@@ -262,11 +267,17 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nreturn item;\n}\nconst { messageInfo } = item;\n+ const id = messageKey(messageInfo);\nif (messageInfo.type === messageTypes.MULTIMEDIA) {\n// Conditional due to Flow...\nconst localMessageInfo = item.localMessageInfo\n? item.localMessageInfo\n: null;\n+ const updatedHeight = this.updatedHeights.get(id);\n+ const contentHeight =\n+ updatedHeight !== null && updatedHeight !== undefined\n+ ? updatedHeight\n+ : multimediaMessageLoadingContentHeight;\nreturn {\nitemType: \"message\",\nmessageInfo,\n@@ -275,11 +286,10 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nstartsConversation: item.startsConversation,\nstartsCluster: item.startsCluster,\nendsCluster: item.endsCluster,\n- contentHeight: 100, // TODO\n+ contentHeight,\n};\n}\ninvariant(textHeights, \"textHeights not set\");\n- const id = messageKey(messageInfo);\nconst textHeight = textHeights.get(id);\ninvariant(\ntextHeight !== null && textHeight !== undefined,\n@@ -320,6 +330,50 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nreturn listDataWithHeights;\n}\n+ updateHeightForMessage = (id: string, contentHeight: number) => {\n+ this.updatedHeights.set(id, contentHeight);\n+ this.setState((prevState: State) => {\n+ const prevListData = prevState.listDataWithHeights;\n+ if (!prevListData) {\n+ return {};\n+ }\n+ let itemModified = false;\n+ const newListData = prevListData.map(item => {\n+ if (item.itemType !== \"message\") {\n+ return item;\n+ }\n+ const { messageInfo } = item;\n+ const itemID = messageKey(messageInfo);\n+ if (itemID !== id) {\n+ return item;\n+ }\n+ itemModified = true;\n+ // Conditional due to Flow...\n+ const localMessageInfo = item.localMessageInfo\n+ ? item.localMessageInfo\n+ : null;\n+ invariant(\n+ messageInfo.type === messageTypes.MULTIMEDIA,\n+ \"only MULTIMEDIA messages can have height overriden\",\n+ );\n+ return {\n+ itemType: \"message\",\n+ messageInfo,\n+ localMessageInfo,\n+ threadInfo: item.threadInfo,\n+ startsConversation: item.startsConversation,\n+ startsCluster: item.startsCluster,\n+ endsCluster: item.endsCluster,\n+ contentHeight,\n+ };\n+ });\n+ if (!itemModified) {\n+ return {};\n+ }\n+ return { listDataWithHeights: newListData };\n+ });\n+ }\n+\n}\nconst styles = StyleSheet.create({\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -35,6 +35,7 @@ import ListLoadingIndicator from '../list-loading-indicator.react';\ntype Props = {|\nthreadInfo: ThreadInfo,\nmessageListData: $ReadOnlyArray<ChatMessageItemWithHeight>,\n+ updateHeightForMessage: (id: string, contentHeight: number) => void,\n// Redux state\nviewerID: ?string,\nstartReached: bool,\n@@ -57,6 +58,7 @@ class MessageList extends React.PureComponent<Props, State> {\nstatic propTypes = {\nthreadInfo: threadInfoPropType.isRequired,\nmessageListData: PropTypes.arrayOf(chatMessageItemPropType).isRequired,\n+ updateHeightForMessage: PropTypes.func.isRequired,\nviewerID: PropTypes.string,\nstartReached: PropTypes.bool.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\n@@ -123,6 +125,7 @@ class MessageList extends React.PureComponent<Props, State> {\nitem={messageInfoItem}\nfocused={focused}\ntoggleFocus={this.toggleMessageFocus}\n+ updateHeightForMessage={this.props.updateHeightForMessage}\n/>\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message.react.js",
"new_path": "native/chat/message.react.js",
"diff": "@@ -47,6 +47,7 @@ type Props = {\nitem: ChatMessageInfoItemWithHeight,\nfocused: bool,\ntoggleFocus: (messageKey: string) => void,\n+ updateHeightForMessage: (id: string, contentHeight: number) => void,\n};\nclass Message extends React.PureComponent<Props> {\n@@ -54,6 +55,7 @@ class Message extends React.PureComponent<Props> {\nitem: chatMessageItemPropType.isRequired,\nfocused: PropTypes.bool.isRequired,\ntoggleFocus: PropTypes.func.isRequired,\n+ updateHeightForMessage: PropTypes.func.isRequired,\n};\ncomponentWillReceiveProps(nextProps: Props) {\n@@ -88,6 +90,7 @@ class Message extends React.PureComponent<Props> {\n<MultimediaMessage\nitem={this.props.item}\ntoggleFocus={this.props.toggleFocus}\n+ updateHeightForMessage={this.props.updateHeightForMessage}\n/>\n);\n} else {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message.react.js",
"new_path": "native/chat/multimedia-message.react.js",
"diff": "@@ -11,12 +11,16 @@ import {\nText,\nStyleSheet,\nTouchableWithoutFeedback,\n+ View,\n+ ActivityIndicator,\n} from 'react-native';\nimport invariant from 'invariant';\nimport PropTypes from 'prop-types';\nimport { messageKey } from 'lib/shared/message-utils';\n+const multimediaMessageLoadingContentHeight = 100; // TODO\n+\nfunction multimediaMessageItemHeight(\nitem: ChatMessageInfoItemWithHeight,\nviewerID: ?string,\n@@ -46,12 +50,14 @@ function multimediaMessageItemHeight(\ntype Props = {|\nitem: ChatMessageInfoItemWithHeight,\ntoggleFocus: (messageKey: string) => void,\n+ updateHeightForMessage: (id: string, contentHeight: number) => void,\n|};\nclass MultimediaMessage extends React.PureComponent<Props> {\nstatic propTypes = {\nitem: chatMessageItemPropType.isRequired,\ntoggleFocus: PropTypes.func.isRequired,\n+ updateHeightForMessage: PropTypes.func.isRequired,\n};\nconstructor(props: Props) {\n@@ -62,17 +68,25 @@ class MultimediaMessage extends React.PureComponent<Props> {\n);\n}\n- componentWillReceiveProps(nextProps: Props) {\n+ componentDidUpdate() {\ninvariant(\n- nextProps.item.messageInfo.type === messageTypes.MULTIMEDIA,\n+ this.props.item.messageInfo.type === messageTypes.MULTIMEDIA,\n\"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n);\n}\nrender() {\n+ const { contentHeight } = this.props.item;\n+ const style = { height: contentHeight };\nreturn (\n<TouchableWithoutFeedback onPress={this.onPress}>\n- <Text style={styles.robotext}>Blah blah image</Text>\n+ <View>\n+ <ActivityIndicator\n+ color=\"black\"\n+ size=\"large\"\n+ style={style}\n+ />\n+ </View>\n</TouchableWithoutFeedback>\n);\n}\n@@ -84,18 +98,10 @@ class MultimediaMessage extends React.PureComponent<Props> {\n}\nconst styles = StyleSheet.create({\n- robotext: {\n- textAlign: 'center',\n- color: '#333333',\n- paddingVertical: 6,\n- marginBottom: 5,\n- marginHorizontal: 24,\n- fontSize: 15,\n- fontFamily: 'Arial',\n- },\n});\nexport {\n+ multimediaMessageLoadingContentHeight,\nMultimediaMessage,\nmultimediaMessageItemHeight,\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Enable MultimediaMessage to update contentHeight
Still have to write the code to actually calculate it, as well as rendering it.
Also need to make `multimediaMessageLoadingContentHeight` a function that depends on number of multimedia. |
129,187 | 14.03.2019 10:45:57 | 14,400 | 4cafe4f7265bb0cd4fd3a22c1e3927e505930579 | [web] Limit width of chat messages | [
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-message-list.css",
"new_path": "web/chat/chat-message-list.css",
"diff": "@@ -217,12 +217,10 @@ div.messageBox {\ndisplay: flex;\nflex-wrap: wrap;\njustify-content: space-between;\n+ max-width: 68%;\n}\n-div.fullWidthMessageBox {\n- width: 100%;\n-}\n-div.halfWidthMessageBox {\n- max-width: 50%;\n+div.fixedWidthMessageBox {\n+ width: 68%;\n}\ndiv.failedSend {\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/composed-message.react.js",
"new_path": "web/chat/composed-message.react.js",
"diff": "@@ -30,7 +30,7 @@ type Props = {|\nsendFailed: bool,\nsetMouseOver: (messagePositionInfo: MessagePositionInfo) => void,\nchildren: React.Node,\n- className?: string,\n+ className?: ?string,\nborderRadius: number,\nchatInputState: ChatInputState,\n|};\n@@ -50,15 +50,6 @@ class ComposedMessage extends React.PureComponent<Props> {\nborderRadius: 8,\n};\n- constructor(props: Props) {\n- super(props);\n- assertComposableMessageType(props.item.messageInfo.type);\n- }\n-\n- componentDidUpdate(prevProps: Props) {\n- assertComposableMessageType(this.props.item.messageInfo.type);\n- }\n-\nrender() {\nassertComposableMessageType(this.props.item.messageInfo.type);\nconst { borderRadius, item, threadInfo, chatInputState } = this.props;\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/multimedia-message.react.js",
"new_path": "web/chat/multimedia-message.react.js",
"diff": "@@ -173,9 +173,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\nconst content = multimedia.length > 1\n? <div className={css.imageGrid}>{multimedia}</div>\n: multimedia;\n- const className = multimedia.length > 1\n- ? css.fullWidthMessageBox\n- : css.halfWidthMessageBox;\n+ const className = multimedia.length > 1 ? css.fixedWidthMessageBox : null;\nreturn (\n<ComposedMessage\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [web] Limit width of chat messages |
129,187 | 14.03.2019 11:07:05 | 14,400 | c6abeba8d6a72d217b666bd96cb51d335451e685 | [native] Actually render images | [
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message.react.js",
"new_path": "native/chat/multimedia-message.react.js",
"diff": "@@ -5,6 +5,7 @@ import type {\n} from './message-list-container.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport { messageTypes } from 'lib/types/message-types';\n+import type { Media } from 'lib/types/media-types';\nimport * as React from 'react';\nimport {\n@@ -12,12 +13,16 @@ import {\nStyleSheet,\nTouchableWithoutFeedback,\nView,\n+ Image,\nActivityIndicator,\n} from 'react-native';\nimport invariant from 'invariant';\nimport PropTypes from 'prop-types';\nimport { messageKey } from 'lib/shared/message-utils';\n+import { promiseAll } from 'lib/utils/promises';\n+\n+import { type Dimensions, preloadImage } from '../utils/media-utils';\nconst multimediaMessageLoadingContentHeight = 100; // TODO\n@@ -52,45 +57,149 @@ type Props = {|\ntoggleFocus: (messageKey: string) => void,\nupdateHeightForMessage: (id: string, contentHeight: number) => void,\n|};\n-class MultimediaMessage extends React.PureComponent<Props> {\n+type State = {|\n+ dimensions: ?{[id: string]: Dimensions},\n+|};\n+class MultimediaMessage extends React.PureComponent<Props, State> {\nstatic propTypes = {\nitem: chatMessageItemPropType.isRequired,\ntoggleFocus: PropTypes.func.isRequired,\nupdateHeightForMessage: PropTypes.func.isRequired,\n};\n+ state = {\n+ dimensions: null,\n+ };\n- constructor(props: Props) {\n- super(props);\n+ componentDidMount() {\n+ this.calculateDimensions();\n+ }\n+\n+ componentDidUpdate(prevProps: Props) {\n+ const { messageInfo } = this.props.item;\n+ const oldMessageInfo = prevProps.item.messageInfo;\ninvariant(\n- props.item.messageInfo.type === messageTypes.MULTIMEDIA,\n+ messageInfo.type === messageTypes.MULTIMEDIA &&\n+ oldMessageInfo.type === messageTypes.MULTIMEDIA,\n\"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n);\n+ if (messageInfo.media.length !== oldMessageInfo.media.length) {\n+ this.calculateDimensions();\n+ return;\n+ }\n+ for (let i = 0; i < messageInfo.media.length; i++) {\n+ if (messageInfo.media[i].uri !== oldMessageInfo.media[i].uri) {\n+ this.calculateDimensions();\n+ return;\n+ }\n+ }\n}\n- componentDidUpdate() {\n+ async calculateDimensions() {\n+ const { messageInfo } = this.props.item;\ninvariant(\n- this.props.item.messageInfo.type === messageTypes.MULTIMEDIA,\n+ messageInfo.type === messageTypes.MULTIMEDIA,\n\"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n);\n+\n+ const promises = {};\n+ for (let media of messageInfo.media) {\n+ promises[media.id] = preloadImage(media.uri);\n+ }\n+ const dimensions = await promiseAll(promises);\n+ this.setState({ dimensions });\n}\nrender() {\n- const { contentHeight } = this.props.item;\n- const style = { height: contentHeight };\n- return (\n- <TouchableWithoutFeedback onPress={this.onPress}>\n- <View>\n+ const { messageInfo, contentHeight } = this.props.item;\n+ invariant(\n+ messageInfo.type === messageTypes.MULTIMEDIA,\n+ \"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n+ );\n+ const heightStyle = { height: contentHeight };\n+\n+ let content;\n+ if (!this.state.dimensions) {\n+ content = (\n+ <View style={heightStyle}>\n<ActivityIndicator\ncolor=\"black\"\nsize=\"large\"\n- style={style}\n+ style={heightStyle}\n/>\n</View>\n+ );\n+ } else {\n+ content = (\n+ <View style={heightStyle}>\n+ {this.renderContent()}\n+ </View>\n+ );\n+ }\n+\n+ return (\n+ <TouchableWithoutFeedback onPress={this.onPress}>\n+ {content}\n</TouchableWithoutFeedback>\n);\n}\n+ renderContent(): React.Node {\n+ const { messageInfo } = this.props.item;\n+ invariant(\n+ messageInfo.type === messageTypes.MULTIMEDIA,\n+ \"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n+ );\n+ if (messageInfo.media.length === 1) {\n+ return MultimediaMessage.renderImage(messageInfo.media[0]);\n+ } else if (messageInfo.media.length < 4) {\n+ const images = messageInfo.media.map(MultimediaMessage.renderImage);\n+ return (\n+ <View style={styles.row}>\n+ {images}\n+ </View>\n+ );\n+ } else if (messageInfo.media.length === 4) {\n+ const [ one, two, three, four ] = messageInfo.media;\n+ return (\n+ <View>\n+ <View style={styles.row}>\n+ {MultimediaMessage.renderImage(one)}\n+ {MultimediaMessage.renderImage(two)}\n+ </View>\n+ <View style={styles.row}>\n+ {MultimediaMessage.renderImage(three)}\n+ {MultimediaMessage.renderImage(four)}\n+ </View>\n+ </View>\n+ );\n+ } else {\n+ const rows = [];\n+ for (let i = 0; i < messageInfo.media.length; i += 3) {\n+ const media = messageInfo.media.slice(i, i + 3);\n+ const images = media.map(MultimediaMessage.renderImage);\n+ rows.push(\n+ <View style={styles.row} key={i}>\n+ {images}\n+ </View>\n+ );\n+ }\n+ return <View>{rows}</View>;\n+ }\n+ }\n+\n+ static renderImage(media: Media): React.Node {\n+ const { id, uri } = media;\n+ const source = { uri };\n+ return (\n+ <Image\n+ source={source}\n+ key={id}\n+ style={styles.image}\n+ />\n+ );\n+ }\n+\nonPress = () => {\nthis.props.toggleFocus(messageKey(this.props.item.messageInfo));\n}\n@@ -98,6 +207,13 @@ class MultimediaMessage extends React.PureComponent<Props> {\n}\nconst styles = StyleSheet.create({\n+ row: {\n+ flex: 1,\n+ flexDirection: 'row',\n+ },\n+ image: {\n+ flex: 1,\n+ },\n});\nexport {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/utils/media-utils.js",
"diff": "+// @flow\n+\n+import { Image } from 'react-native';\n+\n+export type Dimensions = {|\n+ height: number,\n+ width: number,\n+|};\n+async function preloadImage(uri: string): Promise<Dimensions> {\n+ const [ dimensions ] = await Promise.all([\n+ fetchSize(uri),\n+ Image.prefetch(uri),\n+ ]);\n+ return dimensions;\n+}\n+\n+function fetchSize(uri: string): Promise<Dimensions> {\n+ return new Promise((resolve, reject) => {\n+ const success = (width, height) => resolve({ height, width });\n+ Image.getSize(uri, success, reject);\n+ });\n+}\n+\n+export {\n+ preloadImage,\n+};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Actually render images |
129,187 | 14.03.2019 12:33:22 | 14,400 | 3f68f07ac584e4a84f8b41fe8cc3dc7967f1ac11 | [native] ComposedMessage | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/composed-message.react.js",
"diff": "+// @flow\n+\n+import type {\n+ ChatMessageInfoItemWithHeight,\n+} from './message-list-container.react';\n+import { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\n+import { assertComposableMessageType } from 'lib/types/message-types';\n+\n+import * as React from 'react';\n+import PropTypes from 'prop-types';\n+import { Text, StyleSheet, View } from 'react-native';\n+import Icon from 'react-native-vector-icons/Feather';\n+\n+import { stringForUser } from 'lib/shared/user-utils';\n+\n+import FailedSend from './failed-send.react';\n+\n+type Props = {|\n+ item: ChatMessageInfoItemWithHeight,\n+ sendFailed: bool,\n+ children: React.Node,\n+ borderRadius: number,\n+|};\n+class ComposedMessage extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ item: chatMessageItemPropType.isRequired,\n+ sendFailed: PropTypes.bool.isRequired,\n+ children: PropTypes.node.isRequired,\n+ borderRadius: PropTypes.number.isRequired,\n+ };\n+ static defaultProps = {\n+ borderRadius: 8,\n+ };\n+\n+ render() {\n+ assertComposableMessageType(this.props.item.messageInfo.type);\n+ const { item, borderRadius } = this.props;\n+ const { id, creator } = item.messageInfo;\n+ const threadColor = item.threadInfo.color;\n+\n+ const { isViewer } = creator;\n+ const alignStyle = isViewer\n+ ? styles.rightChatBubble\n+ : styles.leftChatBubble;\n+ const containerStyle = [\n+ styles.alignment,\n+ { marginBottom: item.endsCluster ? 12 : 5 },\n+ ];\n+ const messageStyle = {\n+ borderTopRightRadius:\n+ isViewer && !item.startsCluster ? 0 : borderRadius,\n+ borderBottomRightRadius:\n+ isViewer && !item.endsCluster ? 0 : borderRadius,\n+ borderTopLeftRadius:\n+ !isViewer && !item.startsCluster ? 0 : borderRadius,\n+ borderBottomLeftRadius:\n+ !isViewer && !item.endsCluster ? 0 : borderRadius,\n+ };\n+\n+ let authorName = null;\n+ if (!isViewer && item.startsCluster) {\n+ authorName = (\n+ <Text style={styles.authorName}>\n+ {stringForUser(creator)}\n+ </Text>\n+ );\n+ }\n+\n+ let deliveryIcon = null;\n+ let failedSendInfo = null;\n+ if (isViewer) {\n+ let deliveryIconName;\n+ let deliveryIconColor = threadColor;\n+ if (id !== null && id !== undefined) {\n+ deliveryIconName = \"check-circle\";\n+ } else if (this.props.sendFailed) {\n+ deliveryIconName = \"x-circle\";\n+ deliveryIconColor = \"FF0000\";\n+ failedSendInfo = <FailedSend item={item} />;\n+ } else {\n+ deliveryIconName = \"circle\";\n+ }\n+ deliveryIcon = (\n+ <View style={styles.iconContainer}>\n+ <Icon\n+ name={deliveryIconName}\n+ style={[styles.icon, { color: `#${deliveryIconColor}` }]}\n+ />\n+ </View>\n+ );\n+ }\n+\n+ return (\n+ <View style={containerStyle}>\n+ {authorName}\n+ <View style={styles.content}>\n+ <View style={[styles.messageBox, alignStyle]}>\n+ <View style={[styles.message, messageStyle]}>\n+ {this.props.children}\n+ </View>\n+ </View>\n+ {deliveryIcon}\n+ </View>\n+ {failedSendInfo}\n+ </View>\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ alignment: {\n+ marginLeft: 12,\n+ marginRight: 7,\n+ },\n+ content: {\n+ flex: 1,\n+ flexDirection: 'row',\n+ alignItems: 'center',\n+ },\n+ messageBox: {\n+ flex: 1,\n+ flexDirection: 'row',\n+ marginRight: 5,\n+ },\n+ message: {\n+ overflow: 'hidden',\n+ },\n+ authorName: {\n+ color: '#777777',\n+ fontSize: 14,\n+ paddingHorizontal: 12,\n+ paddingVertical: 4,\n+ height: 25,\n+ },\n+ leftChatBubble: {\n+ justifyContent: 'flex-start',\n+ },\n+ rightChatBubble: {\n+ justifyContent: 'flex-end',\n+ },\n+ iconContainer: {\n+ marginLeft: 2,\n+ width: 16,\n+ },\n+ icon: {\n+ fontSize: 16,\n+ textAlign: 'center',\n+ },\n+});\n+\n+export default ComposedMessage;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/text-message.react.js",
"new_path": "native/chat/text-message.react.js",
"diff": "@@ -9,21 +9,19 @@ import {\nmessageTypes,\n} from 'lib/types/message-types';\n-import React from 'react';\n-import { Text, StyleSheet, View, Clipboard } from 'react-native';\n+import * as React from 'react';\n+import { Text, StyleSheet, Clipboard } from 'react-native';\nimport invariant from 'invariant';\nimport PropTypes from 'prop-types';\nimport Color from 'color';\nimport Hyperlink from 'react-native-hyperlink';\n-import Icon from 'react-native-vector-icons/Feather';\nimport { colorIsDark } from 'lib/shared/thread-utils';\nimport { messageKey } from 'lib/shared/message-utils';\n-import { stringForUser } from 'lib/shared/user-utils';\nimport { onlyEmojiRegex } from 'lib/shared/emojis';\nimport Tooltip from '../components/tooltip.react';\n-import FailedSend from './failed-send.react';\n+import ComposedMessage from './composed-message.react';\nfunction textMessageItemHeight(\nitem: ChatMessageInfoItemWithHeight,\n@@ -50,11 +48,11 @@ function textMessageItemHeight(\nreturn height;\n}\n-type Props = {\n+type Props = {|\nitem: ChatMessageInfoItemWithHeight,\nfocused: bool,\ntoggleFocus: (messageKey: string) => void,\n-};\n+|};\nclass TextMessage extends React.PureComponent<Props> {\nstatic propTypes = {\n@@ -67,22 +65,11 @@ class TextMessage extends React.PureComponent<Props> {\nconstructor(props: Props) {\nsuper(props);\n- invariant(\n- props.item.messageInfo.type === messageTypes.TEXT,\n- \"TextMessage should only be used for messageTypes.TEXT\",\n- );\nthis.tooltipConfig = [\n{ label: \"Copy\", onPress: this.onPressCopy },\n];\n}\n- componentWillReceiveProps(nextProps: Props) {\n- invariant(\n- nextProps.item.messageInfo.type === messageTypes.TEXT,\n- \"TextMessage should only be used for messageTypes.TEXT\",\n- );\n- }\n-\nrender() {\ninvariant(\nthis.props.item.messageInfo.type === messageTypes.TEXT,\n@@ -92,75 +79,23 @@ class TextMessage extends React.PureComponent<Props> {\nconst threadColor = this.props.item.threadInfo.color;\nconst { isViewer } = creator;\n- let alignStyle = null,\n- messageStyle = {},\n+ let messageStyle = {},\ntextCustomStyle = {},\ndarkColor = false;\nif (isViewer) {\n- alignStyle = styles.rightChatBubble;\nmessageStyle.backgroundColor = `#${threadColor}`;\ndarkColor = colorIsDark(threadColor);\ntextCustomStyle.color = darkColor ? 'white' : 'black';\n} else {\n- alignStyle = styles.leftChatBubble;\nmessageStyle.backgroundColor = \"#DDDDDDBB\";\ntextCustomStyle.color = 'black';\n}\n- const containerStyle = [\n- styles.alignment,\n- { marginBottom: this.props.item.endsCluster ? 12 : 5 },\n- ];\n- let authorName = null;\n- if (!isViewer && this.props.item.startsCluster) {\n- authorName = (\n- <Text style={styles.authorName}>\n- {stringForUser(creator)}\n- </Text>\n- );\n- }\n- messageStyle.borderTopRightRadius =\n- isViewer && !this.props.item.startsCluster ? 0 : 8;\n- messageStyle.borderBottomRightRadius =\n- isViewer && !this.props.item.endsCluster ? 0 : 8;\n- messageStyle.borderTopLeftRadius =\n- !isViewer && !this.props.item.startsCluster ? 0 : 8;\n- messageStyle.borderBottomLeftRadius =\n- !isViewer && !this.props.item.endsCluster ? 0 : 8;\nif (this.props.focused) {\nmessageStyle.backgroundColor =\nColor(messageStyle.backgroundColor).darken(0.15).hex();\n}\ntextCustomStyle.height = this.props.item.contentHeight;\n- let deliveryIcon = null;\n- let failedSendInfo = null;\n- if (isViewer) {\n- let deliveryIconName;\n- let deliveryIconColor = threadColor;\n- if (id !== null && id !== undefined) {\n- deliveryIconName = \"check-circle\";\n- } else {\n- const sendFailed = this.props.item.localMessageInfo\n- ? this.props.item.localMessageInfo.sendFailed\n- : null;\n- if (sendFailed) {\n- deliveryIconName = \"x-circle\";\n- deliveryIconColor = \"FF0000\";\n- failedSendInfo = <FailedSend item={this.props.item} />;\n- } else {\n- deliveryIconName = \"circle\";\n- }\n- }\n- deliveryIcon = (\n- <View style={styles.iconContainer}>\n- <Icon\n- name={deliveryIconName}\n- style={[styles.icon, { color: `#${deliveryIconColor}` }]}\n- />\n- </View>\n- );\n- }\n-\nconst linkStyle = darkColor ? styles.lightLinkText : styles.darkLinkText;\nconst textStyle = onlyEmojiRegex.test(text)\n? styles.emojiOnlyText\n@@ -179,11 +114,17 @@ class TextMessage extends React.PureComponent<Props> {\n</Hyperlink>\n);\n+ const sendFailed =\n+ isViewer &&\n+ (id === null || id === undefined) &&\n+ this.props.item.localMessageInfo &&\n+ this.props.item.localMessageInfo.sendFailed;\n+\nreturn (\n- <View style={containerStyle}>\n- {authorName}\n- <View style={[styles.content, alignStyle]}>\n- <View style={[styles.messageBlobContainer, alignStyle]}>\n+ <ComposedMessage\n+ item={this.props.item}\n+ sendFailed={!!sendFailed}\n+ >\n<Tooltip\nbuttonComponent={messageBlob}\nitems={this.tooltipConfig}\n@@ -192,11 +133,7 @@ class TextMessage extends React.PureComponent<Props> {\nonCloseTooltipMenu={this.onBlur}\nref={this.tooltipRef}\n/>\n- </View>\n- {deliveryIcon}\n- </View>\n- {failedSendInfo}\n- </View>\n+ </ComposedMessage>\n);\n}\n@@ -245,27 +182,11 @@ const styles = StyleSheet.create({\nfontSize: 36,\nfontFamily: 'Arial',\n},\n- alignment: {\n- marginLeft: 12,\n- marginRight: 7,\n- },\nmessage: {\npaddingVertical: 6,\npaddingHorizontal: 12,\n- marginRight: 5,\noverflow: 'hidden',\n},\n- messageBlobContainer: {\n- flex: 1,\n- flexDirection: 'row',\n- },\n- authorName: {\n- color: '#777777',\n- fontSize: 14,\n- paddingHorizontal: 12,\n- paddingVertical: 4,\n- height: 25,\n- },\ndarkLinkText: {\ncolor: \"#036AFF\",\ntextDecorationLine: \"underline\",\n@@ -278,25 +199,6 @@ const styles = StyleSheet.create({\ntextAlign: 'center',\ncolor: '#444',\n},\n- leftChatBubble: {\n- justifyContent: 'flex-start',\n- },\n- rightChatBubble: {\n- justifyContent: 'flex-end',\n- },\n- content: {\n- flex: 1,\n- flexDirection: 'row',\n- alignItems: 'center',\n- },\n- icon: {\n- fontSize: 16,\n- textAlign: 'center',\n- },\n- iconContainer: {\n- marginLeft: 2,\n- width: 16,\n- },\n});\nexport {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] ComposedMessage |
129,187 | 14.03.2019 12:44:55 | 14,400 | 1e614e18d7083b107879cba09516c055e9f1e067 | [native] RoundedMessageContainer
Needs to be recalculated within `TextMessage` so that the corners are preserved in the `Tooltip`. | [
{
"change_type": "MODIFY",
"old_path": "native/chat/composed-message.react.js",
"new_path": "native/chat/composed-message.react.js",
"diff": "@@ -14,6 +14,7 @@ import Icon from 'react-native-vector-icons/Feather';\nimport { stringForUser } from 'lib/shared/user-utils';\nimport FailedSend from './failed-send.react';\n+import RoundedMessageContainer from './rounded-message-container.react';\ntype Props = {|\nitem: ChatMessageInfoItemWithHeight,\n@@ -37,7 +38,6 @@ class ComposedMessage extends React.PureComponent<Props> {\nassertComposableMessageType(this.props.item.messageInfo.type);\nconst { item, borderRadius } = this.props;\nconst { id, creator } = item.messageInfo;\n- const threadColor = item.threadInfo.color;\nconst { isViewer } = creator;\nconst alignStyle = isViewer\n@@ -47,16 +47,6 @@ class ComposedMessage extends React.PureComponent<Props> {\nstyles.alignment,\n{ marginBottom: item.endsCluster ? 12 : 5 },\n];\n- const messageStyle = {\n- borderTopRightRadius:\n- isViewer && !item.startsCluster ? 0 : borderRadius,\n- borderBottomRightRadius:\n- isViewer && !item.endsCluster ? 0 : borderRadius,\n- borderTopLeftRadius:\n- !isViewer && !item.startsCluster ? 0 : borderRadius,\n- borderBottomLeftRadius:\n- !isViewer && !item.endsCluster ? 0 : borderRadius,\n- };\nlet authorName = null;\nif (!isViewer && item.startsCluster) {\n@@ -71,7 +61,7 @@ class ComposedMessage extends React.PureComponent<Props> {\nlet failedSendInfo = null;\nif (isViewer) {\nlet deliveryIconName;\n- let deliveryIconColor = threadColor;\n+ let deliveryIconColor = item.threadInfo.color;\nif (id !== null && id !== undefined) {\ndeliveryIconName = \"check-circle\";\n} else if (this.props.sendFailed) {\n@@ -96,9 +86,12 @@ class ComposedMessage extends React.PureComponent<Props> {\n{authorName}\n<View style={styles.content}>\n<View style={[styles.messageBox, alignStyle]}>\n- <View style={[styles.message, messageStyle]}>\n+ <RoundedMessageContainer\n+ item={item}\n+ borderRadius={borderRadius}\n+ >\n{this.props.children}\n- </View>\n+ </RoundedMessageContainer>\n</View>\n{deliveryIcon}\n</View>\n@@ -124,9 +117,6 @@ const styles = StyleSheet.create({\nflexDirection: 'row',\nmarginRight: 5,\n},\n- message: {\n- overflow: 'hidden',\n- },\nauthorName: {\ncolor: '#777777',\nfontSize: 14,\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/rounded-message-container.react.js",
"diff": "+// @flow\n+\n+import type {\n+ ChatMessageInfoItemWithHeight,\n+} from './message-list-container.react';\n+import { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\n+\n+import * as React from 'react';\n+import PropTypes from 'prop-types';\n+import { StyleSheet, View } from 'react-native';\n+\n+type Props = {|\n+ item: ChatMessageInfoItemWithHeight,\n+ borderRadius: number,\n+ children: React.Node,\n+|};\n+class RoundedMessageContainer extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ item: chatMessageItemPropType.isRequired,\n+ borderRadius: PropTypes.number.isRequired,\n+ children: PropTypes.node.isRequired,\n+ };\n+ static defaultProps = {\n+ borderRadius: 8,\n+ };\n+\n+ render() {\n+ const { item, borderRadius } = this.props;\n+ const { isViewer } = item.messageInfo.creator;\n+\n+ const messageStyle = {\n+ borderTopRightRadius:\n+ isViewer && !item.startsCluster ? 0 : borderRadius,\n+ borderBottomRightRadius:\n+ isViewer && !item.endsCluster ? 0 : borderRadius,\n+ borderTopLeftRadius:\n+ !isViewer && !item.startsCluster ? 0 : borderRadius,\n+ borderBottomLeftRadius:\n+ !isViewer && !item.endsCluster ? 0 : borderRadius,\n+ };\n+\n+ return (\n+ <View style={[styles.message, messageStyle]}>\n+ {this.props.children}\n+ </View>\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ message: {\n+ overflow: 'hidden',\n+ },\n+});\n+\n+export default RoundedMessageContainer;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/text-message.react.js",
"new_path": "native/chat/text-message.react.js",
"diff": "@@ -22,6 +22,7 @@ import { onlyEmojiRegex } from 'lib/shared/emojis';\nimport Tooltip from '../components/tooltip.react';\nimport ComposedMessage from './composed-message.react';\n+import RoundedMessageContainer from './rounded-message-container.react';\nfunction textMessageItemHeight(\nitem: ChatMessageInfoItemWithHeight,\n@@ -71,18 +72,17 @@ class TextMessage extends React.PureComponent<Props> {\n}\nrender() {\n+ const { item } = this.props;\ninvariant(\n- this.props.item.messageInfo.type === messageTypes.TEXT,\n+ item.messageInfo.type === messageTypes.TEXT,\n\"TextMessage should only be used for messageTypes.TEXT\",\n);\n- const { text, id, creator } = this.props.item.messageInfo;\n- const threadColor = this.props.item.threadInfo.color;\n-\n+ const { text, id, creator } = item.messageInfo;\nconst { isViewer } = creator;\n- let messageStyle = {},\n- textCustomStyle = {},\n- darkColor = false;\n+\n+ let messageStyle = {}, textCustomStyle = {}, darkColor = false;\nif (isViewer) {\n+ const threadColor = item.threadInfo.color;\nmessageStyle.backgroundColor = `#${threadColor}`;\ndarkColor = colorIsDark(threadColor);\ntextCustomStyle.color = darkColor ? 'white' : 'black';\n@@ -94,13 +94,14 @@ class TextMessage extends React.PureComponent<Props> {\nmessageStyle.backgroundColor =\nColor(messageStyle.backgroundColor).darken(0.15).hex();\n}\n- textCustomStyle.height = this.props.item.contentHeight;\n+ textCustomStyle.height = item.contentHeight;\nconst linkStyle = darkColor ? styles.lightLinkText : styles.darkLinkText;\nconst textStyle = onlyEmojiRegex.test(text)\n? styles.emojiOnlyText\n: styles.text;\nconst messageBlob = (\n+ <RoundedMessageContainer item={item}>\n<Hyperlink\nlinkDefault={true}\nstyle={[styles.message, messageStyle]}\n@@ -112,17 +113,18 @@ class TextMessage extends React.PureComponent<Props> {\nstyle={[textStyle, textCustomStyle]}\n>{text}</Text>\n</Hyperlink>\n+ </RoundedMessageContainer>\n);\nconst sendFailed =\nisViewer &&\n(id === null || id === undefined) &&\n- this.props.item.localMessageInfo &&\n- this.props.item.localMessageInfo.sendFailed;\n+ item.localMessageInfo &&\n+ item.localMessageInfo.sendFailed;\nreturn (\n<ComposedMessage\n- item={this.props.item}\n+ item={item}\nsendFailed={!!sendFailed}\n>\n<Tooltip\n@@ -185,7 +187,6 @@ const styles = StyleSheet.create({\nmessage: {\npaddingVertical: 6,\npaddingHorizontal: 12,\n- overflow: 'hidden',\n},\ndarkLinkText: {\ncolor: \"#036AFF\",\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] RoundedMessageContainer
Needs to be recalculated within `TextMessage` so that the corners are preserved in the `Tooltip`. |
129,187 | 14.03.2019 13:09:01 | 14,400 | fe5b4a363dcc06481a5690d67b6616c89aa654f0 | [native] Use ComposedMessage from MultimediaMessage | [
{
"change_type": "MODIFY",
"old_path": "native/chat/composed-message.react.js",
"new_path": "native/chat/composed-message.react.js",
"diff": "@@ -5,10 +5,11 @@ import type {\n} from './message-list-container.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport { assertComposableMessageType } from 'lib/types/message-types';\n+import type { ViewStyle } from '../types/styles';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n-import { Text, StyleSheet, View } from 'react-native';\n+import { Text, StyleSheet, View, ViewPropTypes } from 'react-native';\nimport Icon from 'react-native-vector-icons/Feather';\nimport { stringForUser } from 'lib/shared/user-utils';\n@@ -19,16 +20,18 @@ import RoundedMessageContainer from './rounded-message-container.react';\ntype Props = {|\nitem: ChatMessageInfoItemWithHeight,\nsendFailed: bool,\n- children: React.Node,\n+ style?: ViewStyle,\nborderRadius: number,\n+ children: React.Node,\n|};\nclass ComposedMessage extends React.PureComponent<Props> {\nstatic propTypes = {\nitem: chatMessageItemPropType.isRequired,\nsendFailed: PropTypes.bool.isRequired,\n- children: PropTypes.node.isRequired,\n+ style: ViewPropTypes.style,\nborderRadius: PropTypes.number.isRequired,\n+ children: PropTypes.node.isRequired,\n};\nstatic defaultProps = {\nborderRadius: 8,\n@@ -36,7 +39,7 @@ class ComposedMessage extends React.PureComponent<Props> {\nrender() {\nassertComposableMessageType(this.props.item.messageInfo.type);\n- const { item, borderRadius } = this.props;\n+ const { item, borderRadius, style } = this.props;\nconst { id, creator } = item.messageInfo;\nconst { isViewer } = creator;\n@@ -89,6 +92,7 @@ class ComposedMessage extends React.PureComponent<Props> {\n<RoundedMessageContainer\nitem={item}\nborderRadius={borderRadius}\n+ style={style}\n>\n{this.props.children}\n</RoundedMessageContainer>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message.react.js",
"new_path": "native/chat/multimedia-message.react.js",
"diff": "@@ -22,6 +22,7 @@ import PropTypes from 'prop-types';\nimport { messageKey } from 'lib/shared/message-utils';\nimport { promiseAll } from 'lib/utils/promises';\n+import ComposedMessage from './composed-message.react';\nimport { type Dimensions, preloadImage } from '../utils/media-utils';\nconst multimediaMessageLoadingContentHeight = 100; // TODO\n@@ -116,12 +117,14 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\nmessageInfo.type === messageTypes.MULTIMEDIA,\n\"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n);\n+ const { id, creator } = messageInfo;\n+ const { isViewer } = creator;\nconst heightStyle = { height: contentHeight };\nlet content;\nif (!this.state.dimensions) {\ncontent = (\n- <View style={heightStyle}>\n+ <View style={[heightStyle, styles.container]}>\n<ActivityIndicator\ncolor=\"black\"\nsize=\"large\"\n@@ -131,16 +134,29 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\n);\n} else {\ncontent = (\n- <View style={heightStyle}>\n+ <View style={[heightStyle, styles.container]}>\n{this.renderContent()}\n</View>\n);\n}\n+ const sendFailed =\n+ isViewer &&\n+ (id === null || id === undefined) &&\n+ this.props.item.localMessageInfo &&\n+ this.props.item.localMessageInfo.sendFailed;\n+\nreturn (\n+ <ComposedMessage\n+ item={this.props.item}\n+ sendFailed={!!sendFailed}\n+ borderRadius={16}\n+ style={styles.row}\n+ >\n<TouchableWithoutFeedback onPress={this.onPress}>\n{content}\n</TouchableWithoutFeedback>\n+ </ComposedMessage>\n);\n}\n@@ -207,6 +223,11 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\n}\nconst styles = StyleSheet.create({\n+ container: {\n+ flex: 1,\n+ flexDirection: 'row',\n+ justifyContent: 'center',\n+ },\nrow: {\nflex: 1,\nflexDirection: 'row',\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/rounded-message-container.react.js",
"new_path": "native/chat/rounded-message-container.react.js",
"diff": "@@ -4,14 +4,16 @@ import type {\nChatMessageInfoItemWithHeight,\n} from './message-list-container.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\n+import type { ViewStyle } from '../types/styles';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n-import { StyleSheet, View } from 'react-native';\n+import { StyleSheet, View, ViewPropTypes } from 'react-native';\ntype Props = {|\nitem: ChatMessageInfoItemWithHeight,\nborderRadius: number,\n+ style?: ViewStyle,\nchildren: React.Node,\n|};\nclass RoundedMessageContainer extends React.PureComponent<Props> {\n@@ -19,6 +21,7 @@ class RoundedMessageContainer extends React.PureComponent<Props> {\nstatic propTypes = {\nitem: chatMessageItemPropType.isRequired,\nborderRadius: PropTypes.number.isRequired,\n+ style: ViewPropTypes.style,\nchildren: PropTypes.node.isRequired,\n};\nstatic defaultProps = {\n@@ -26,7 +29,7 @@ class RoundedMessageContainer extends React.PureComponent<Props> {\n};\nrender() {\n- const { item, borderRadius } = this.props;\n+ const { item, borderRadius, style } = this.props;\nconst { isViewer } = item.messageInfo.creator;\nconst messageStyle = {\n@@ -41,7 +44,7 @@ class RoundedMessageContainer extends React.PureComponent<Props> {\n};\nreturn (\n- <View style={[styles.message, messageStyle]}>\n+ <View style={[styles.message, messageStyle, style]}>\n{this.props.children}\n</View>\n);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use ComposedMessage from MultimediaMessage |
129,187 | 14.03.2019 13:21:34 | 14,400 | 45a1519bb2cd9f7619e191278e7cf90bf954ddef | [native] Add spacing between images | [
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message.react.js",
"new_path": "native/chat/multimedia-message.react.js",
"diff": "@@ -6,6 +6,7 @@ import type {\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport { messageTypes } from 'lib/types/message-types';\nimport type { Media } from 'lib/types/media-types';\n+import type { ImageStyle } from '../types/styles';\nimport * as React from 'react';\nimport {\n@@ -168,50 +169,80 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\n);\nif (messageInfo.media.length === 1) {\nreturn MultimediaMessage.renderImage(messageInfo.media[0]);\n- } else if (messageInfo.media.length < 4) {\n- const images = messageInfo.media.map(MultimediaMessage.renderImage);\n+ } else if (messageInfo.media.length === 2) {\n+ const [ one, two ] = messageInfo.media;\nreturn (\n<View style={styles.row}>\n- {images}\n+ {MultimediaMessage.renderImage(one, styles.leftImage)}\n+ {MultimediaMessage.renderImage(two, styles.rightImage)}\n+ </View>\n+ );\n+ } else if (messageInfo.media.length === 3) {\n+ const [ one, two, three ] = messageInfo.media;\n+ return (\n+ <View style={styles.row}>\n+ {MultimediaMessage.renderImage(one, styles.leftImage)}\n+ {MultimediaMessage.renderImage(two, styles.centerImage)}\n+ {MultimediaMessage.renderImage(three, styles.rightImage)}\n</View>\n);\n} else if (messageInfo.media.length === 4) {\nconst [ one, two, three, four ] = messageInfo.media;\nreturn (\n- <View>\n+ <React.Fragment>\n<View style={styles.row}>\n- {MultimediaMessage.renderImage(one)}\n- {MultimediaMessage.renderImage(two)}\n+ {MultimediaMessage.renderImage(one, styles.topLeftImage)}\n+ {MultimediaMessage.renderImage(two, styles.topRightImage)}\n</View>\n<View style={styles.row}>\n- {MultimediaMessage.renderImage(three)}\n- {MultimediaMessage.renderImage(four)}\n- </View>\n+ {MultimediaMessage.renderImage(three, styles.bottomLeftImage)}\n+ {MultimediaMessage.renderImage(four, styles.bottomRightImage)}\n</View>\n+ </React.Fragment>\n);\n} else {\nconst rows = [];\nfor (let i = 0; i < messageInfo.media.length; i += 3) {\nconst media = messageInfo.media.slice(i, i + 3);\n- const images = media.map(MultimediaMessage.renderImage);\n+ const [ one, two, three ] = media;\n+ if (i === 0) {\n+ rows.push(\n+ <View style={styles.row} key={i}>\n+ {MultimediaMessage.renderImage(one, styles.topLeftImage)}\n+ {MultimediaMessage.renderImage(two, styles.topCenterImage)}\n+ {MultimediaMessage.renderImage(three, styles.topRightImage)}\n+ </View>\n+ );\n+ } else if (i + 3 >= messageInfo.media.length) {\n+ rows.push(\n+ <View style={styles.row} key={i}>\n+ {MultimediaMessage.renderImage(one, styles.bottomLeftImage)}\n+ {MultimediaMessage.renderImage(two, styles.bottomCenterImage)}\n+ {MultimediaMessage.renderImage(three, styles.bottomRightImage)}\n+ </View>\n+ );\n+ } else {\nrows.push(\n<View style={styles.row} key={i}>\n- {images}\n+ {MultimediaMessage.renderImage(one, styles.leftImage)}\n+ {MultimediaMessage.renderImage(two, styles.centerImage)}\n+ {MultimediaMessage.renderImage(three, styles.rightImage)}\n</View>\n);\n}\n- return <View>{rows}</View>;\n+ }\n+ return rows;\n}\n}\n- static renderImage(media: Media): React.Node {\n+ static renderImage(media: Media, style?: ImageStyle): React.Node {\nconst { id, uri } = media;\nconst source = { uri };\nreturn (\n<Image\nsource={source}\nkey={id}\n- style={styles.image}\n+ style={[styles.image, style]}\n/>\n);\n}\n@@ -235,6 +266,42 @@ const styles = StyleSheet.create({\nimage: {\nflex: 1,\n},\n+ leftImage: {\n+ marginRight: 3,\n+ },\n+ centerImage: {\n+ marginLeft: 3,\n+ marginRight: 3,\n+ },\n+ rightImage: {\n+ marginLeft: 3,\n+ },\n+ topLeftImage: {\n+ marginRight: 3,\n+ marginBottom: 3,\n+ },\n+ topCenterImage: {\n+ marginLeft: 3,\n+ marginRight: 3,\n+ marginBottom: 3,\n+ },\n+ topRightImage: {\n+ marginLeft: 3,\n+ marginBottom: 3,\n+ },\n+ bottomLeftImage: {\n+ marginRight: 3,\n+ marginTop: 3,\n+ },\n+ bottomCenterImage: {\n+ marginLeft: 3,\n+ marginRight: 3,\n+ marginTop: 3,\n+ },\n+ bottomRightImage: {\n+ marginLeft: 3,\n+ marginTop: 3,\n+ },\n});\nexport {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Add spacing between images |
129,187 | 14.03.2019 13:36:56 | 14,400 | 5adc4b75adbedb190018e06de33678d374005629 | [lib] Call unshimMessageInfos from freshMessageStore | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/message-reducer.js",
"new_path": "lib/reducers/message-reducer.js",
"diff": "@@ -113,7 +113,8 @@ function freshMessageStore(\ncurrentAsOf: number,\nthreadInfos: {[threadID: string]: RawThreadInfo},\n): MessageStore {\n- const orderedMessageInfos = _orderBy(\"time\")(\"desc\")(messageInfos);\n+ const unshimmed = unshimMessageInfos(messageInfos);\n+ const orderedMessageInfos = _orderBy(\"time\")(\"desc\")(unshimmed);\nconst messages = _keyBy(messageID)(orderedMessageInfos);\nconst threadsToMessageIDs = threadsToMessageIDsFromMessageInfos(\norderedMessageInfos,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Call unshimMessageInfos from freshMessageStore |
129,187 | 14.03.2019 13:47:47 | 14,400 | aa5b1e711e61823904767428730be120ae37c8ba | [lib] Replace upload URIs for Android localhost | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/message-utils.js",
"new_path": "lib/shared/message-utils.js",
"diff": "@@ -595,6 +595,8 @@ function combineTruncationStatuses(\n}\n}\n+const localhostRegex = /^http:\\/\\/localhost/;\n+\nfunction shimUnsupportedRawMessageInfos(\nrawMessageInfos: $ReadOnlyArray<RawMessageInfo>,\nplatformDetails: ?PlatformDetails,\n@@ -608,6 +610,16 @@ function shimUnsupportedRawMessageInfos(\n}\nconst { id } = rawMessageInfo;\ninvariant(id !== null && id !== undefined, \"id should be set on server\");\n+ let unsupportedMessageInfo = rawMessageInfo;\n+ if (platformDetails && platformDetails.platform === \"android\") {\n+ unsupportedMessageInfo = {\n+ ...unsupportedMessageInfo,\n+ media: unsupportedMessageInfo.media.map(media => ({\n+ ...media,\n+ uri: media.uri.replace(localhostRegex, \"http://10.0.2.2\"),\n+ })),\n+ };\n+ }\nreturn {\ntype: messageTypes.UNSUPPORTED,\nid,\n@@ -615,7 +627,7 @@ function shimUnsupportedRawMessageInfos(\ncreatorID: rawMessageInfo.creatorID,\ntime: rawMessageInfo.time,\nrobotext: multimediaMessagePreview(rawMessageInfo),\n- unsupportedMessageInfo: rawMessageInfo,\n+ unsupportedMessageInfo,\n};\n});\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Replace upload URIs for Android localhost |
129,187 | 14.03.2019 16:53:03 | 14,400 | 4e1e5c28ffa19a79b7855cc7309c59e99c36be7d | [native] Always request iOS device token on first run
This can change without getting updated in Redux, such as if an iOS backup is restored to a new phone. | [
{
"change_type": "MODIFY",
"old_path": "native/push/ios.js",
"new_path": "native/push/ios.js",
"diff": "@@ -5,14 +5,18 @@ import NotificationsIOS from 'react-native-notifications';\ntype PushPermissions = { alert?: bool, badge?: bool, sound?: bool };\nlet currentlyActive = false;\n+let firstRun = true;\nasync function requestIOSPushPermissions(missingDeviceToken: bool) {\n- let permissionNeeded = missingDeviceToken;\n+ let permissionNeeded = firstRun || missingDeviceToken;\n+ firstRun = false;\n+\nif (!permissionNeeded) {\nconst permissions: PushPermissions =\nawait NotificationsIOS.checkPermissions();\npermissionNeeded = permissionMissing(permissions);\n}\n+\nif (permissionNeeded) {\nif (currentlyActive) {\nreturn;\n@@ -20,6 +24,7 @@ async function requestIOSPushPermissions(missingDeviceToken: bool) {\ncurrentlyActive = true;\nawait NotificationsIOS.requestPermissions();\n}\n+\nNotificationsIOS.consumeBackgroundQueue();\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Always request iOS device token on first run
This can change without getting updated in Redux, such as if an iOS backup is restored to a new phone. |
129,187 | 14.03.2019 18:42:05 | 14,400 | e477777d1f31577821f1feca7c2674df578e4709 | [native] Store screen dimensions in Redux | [
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "@@ -86,6 +86,7 @@ import { AppRouteName } from './navigation/route-names';\nimport MessageStorePruner from './chat/message-store-pruner.react';\nimport DisconnectedBarVisibilityHandler\nfrom './navigation/disconnected-bar-visibility-handler.react';\n+import DimensionsUpdater from './dimensions-updater.react';\nimport Socket from './socket.react';\nif (Platform.OS === \"android\") {\n@@ -668,6 +669,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n/>\n<MessageStorePruner />\n<DisconnectedBarVisibilityHandler />\n+ <DimensionsUpdater />\n</View>\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message.react.js",
"new_path": "native/chat/multimedia-message.react.js",
"diff": "@@ -7,6 +7,7 @@ import { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport { messageTypes } from 'lib/types/message-types';\nimport type { Media } from 'lib/types/media-types';\nimport type { ImageStyle } from '../types/styles';\n+import type { Dimensions } from '../types/dimensions';\nimport * as React from 'react';\nimport {\n@@ -24,7 +25,7 @@ import { messageKey } from 'lib/shared/message-utils';\nimport { promiseAll } from 'lib/utils/promises';\nimport ComposedMessage from './composed-message.react';\n-import { type Dimensions, preloadImage } from '../utils/media-utils';\n+import { preloadImage } from '../utils/media-utils';\nconst multimediaMessageLoadingContentHeight = 100; // TODO\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/dimensions-updater.react.js",
"diff": "+// @flow\n+\n+import type { Dimensions } from './types/dimensions';\n+import type { DispatchActionPayload } from 'lib/utils/action-utils';\n+\n+import * as React from 'react';\n+import PropTypes from 'prop-types';\n+import { Dimensions as NativeDimensions } from 'react-native';\n+\n+import { connect } from 'lib/utils/redux-utils';\n+\n+import { updateDimensionsActiveType } from './navigation/action-types';\n+\n+type Props = {|\n+ // Redux dispatch functions\n+ dispatchActionPayload: DispatchActionPayload,\n+|};\n+class DimensionsUpdater extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ dispatchActionPayload: PropTypes.func.isRequired,\n+ };\n+\n+ componentDidMount() {\n+ NativeDimensions.addEventListener('change', this.onDimensionsChange);\n+ }\n+\n+ componentWillUnmount() {\n+ NativeDimensions.removeEventListener('change', this.onDimensionsChange);\n+ }\n+\n+ onDimensionsChange = (allDimensions: { window: Dimensions }) => {\n+ const dimensions = allDimensions.window;\n+ this.props.dispatchActionPayload(\n+ updateDimensionsActiveType,\n+ dimensions,\n+ );\n+ }\n+\n+ render() {\n+ return null;\n+ }\n+\n+}\n+\n+export default connect(null, null, true)(DimensionsUpdater);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation/action-types.js",
"new_path": "native/navigation/action-types.js",
"diff": "@@ -8,3 +8,4 @@ export const recordNotifPermissionAlertActionType =\nexport const recordAndroidNotificationActionType =\n\"RECORD_ANDROID_NOTIFICATION\";\nexport const clearAndroidNotificationActionType = \"CLEAR_ANDROID_NOTIFICATION\";\n+export const updateDimensionsActiveType = \"UPDATE_DIMENSIONS\";\n"
},
{
"change_type": "MODIFY",
"old_path": "native/persist.js",
"new_path": "native/persist.js",
"diff": "@@ -16,9 +16,15 @@ import { unshimMessageStore } from 'lib/shared/unshim-utils';\nimport { nativeCalendarQuery } from './selectors/nav-selectors';\nimport { defaultNotifPermissionAlertInfo } from './push/alerts';\n+const baseBlacklist = [\n+ 'loadingStatuses',\n+ 'foreground',\n+ 'messageSentFromRoute',\n+ 'dimensions',\n+];\nconst blacklist = __DEV__\n- ? [ 'loadingStatuses', 'foreground', 'messageSentFromRoute' ]\n- : [ 'loadingStatuses', 'foreground', 'messageSentFromRoute', 'navInfo' ];\n+ ? baseBlacklist\n+ : [ ...baseBlacklist, 'navInfo' ];\nconst migrations = {\n[1]: (state: AppState) => ({\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux-setup.js",
"new_path": "native/redux-setup.js",
"diff": "@@ -24,6 +24,7 @@ import {\ndefaultConnectionInfo,\nincrementalStateSyncActionType,\n} from 'lib/types/socket-types';\n+import type { Dimensions } from './types/dimensions';\nimport React from 'react';\nimport invariant from 'invariant';\n@@ -40,7 +41,11 @@ import { NavigationActions, StackActions } from 'react-navigation';\nimport {\ncreateReactNavigationReduxMiddleware,\n} from 'react-navigation-redux-helpers';\n-import { AppState as NativeAppState, Platform } from 'react-native';\n+import {\n+ AppState as NativeAppState,\n+ Platform,\n+ Dimensions as NativeDimensions,\n+} from 'react-native';\nimport baseReducer from 'lib/reducers/master-reducer';\nimport {\n@@ -58,6 +63,7 @@ import {\nrecordNotifPermissionAlertActionType,\nrecordAndroidNotificationActionType,\nclearAndroidNotificationActionType,\n+ updateDimensionsActiveType,\n} from './navigation/action-types';\nimport {\ndefaultNavInfo,\n@@ -114,8 +120,10 @@ export type AppState = {|\nnextLocalID: number,\n_persist: ?PersistState,\nsessionID?: void,\n+ dimensions: Dimensions,\n|};\n+const { height, width } = NativeDimensions.get('window');\nconst defaultState = ({\nnavInfo: defaultNavInfo,\ncurrentUserInfo: null,\n@@ -152,6 +160,7 @@ const defaultState = ({\nforeground: true,\nnextLocalID: 0,\n_persist: null,\n+ dimensions: { height, width },\n}: AppState);\nfunction chatRouteFromNavInfo(navInfo: NavInfo): NavigationStateRoute {\n@@ -198,6 +207,11 @@ function reducer(state: AppState = defaultState, action: *) {\ncurrentUserInfo,\ncookie,\n};\n+ } else if (action.type === updateDimensionsActiveType) {\n+ return {\n+ ...state,\n+ dimensions: action.payload,\n+ };\n}\nconst oldState = state;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/account-selectors.js",
"new_path": "native/selectors/account-selectors.js",
"diff": "// @flow\n-import type { AppState } from '../redux-setup';\nimport type { LogInExtraInfo } from 'lib/types/account-types';\nimport { createSelector } from 'reselect';\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/selectors/dimension-selectors.js",
"diff": "+// @flow\n+\n+import type { AppState } from '../redux-setup';\n+import type { Dimensions } from '../types/dimensions';\n+\n+import { Platform, DeviceInfo } from 'react-native';\n+\n+import { createSelector } from 'reselect';\n+\n+const isIPhoneX = Platform.OS === \"ios\" && DeviceInfo.isIPhoneX_deprecated;\n+\n+let statusBarHeight = 0;\n+if (Platform.OS === \"android\") {\n+ statusBarHeight = 24;\n+} else if (isIPhoneX) {\n+ statusBarHeight = 44;\n+} else if (Platform.OS === \"ios\") {\n+ statusBarHeight = 20;\n+}\n+\n+const dimensionsSelector = createSelector<*, *, *, *>(\n+ (state: AppState) => state.dimensions,\n+ (dimensions: Dimensions) => {\n+ let { height, width } = dimensions;\n+ if (Platform.OS === \"android\") {\n+ // Android starts the 0 pixel below the status bar height,\n+ // but doesn't subtract it out of the dimensions\n+ height -= statusBarHeight;\n+ } else if (isIPhoneX) {\n+ // We avoid painting the bottom 34 pixels on the iPhone X,\n+ // as they are occupied by the home pill\n+ height -= 34;\n+ }\n+ return { height, width };\n+ },\n+);\n+\n+// iOS starts the 0 pixel above the status bar,\n+// so we offset our content by the status bar height\n+const contentVerticalOffset = Platform.OS === \"ios\"\n+ ? statusBarHeight\n+ : 0;\n+\n+const tabBarSize = Platform.OS === \"android\" ? 50 : 49;\n+\n+export {\n+ dimensionsSelector,\n+ contentVerticalOffset,\n+ tabBarSize,\n+};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/types/dimensions.js",
"diff": "+// @flow\n+\n+export type Dimensions = {|\n+ height: number,\n+ width: number,\n+|};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Store screen dimensions in Redux |
129,187 | 14.03.2019 19:13:23 | 14,400 | 6ef25752b36aac5f3c69b2532ac259896b71e768 | [native] Convert business logic to use Redux dimensions | [
{
"change_type": "MODIFY",
"old_path": "native/account/forgot-password-panel.react.js",
"new_path": "native/account/forgot-password-panel.react.js",
"diff": "@@ -28,7 +28,10 @@ import {\nvalidEmailRegex,\n} from 'lib/shared/account-regexes';\n-import { TextInput, usernamePlaceholder } from './modal-components.react';\n+import {\n+ TextInput,\n+ usernamePlaceholderSelector,\n+} from './modal-components.react';\nimport { PanelButton, Panel } from './panel-components.react';\ntype Props = {\n@@ -37,6 +40,7 @@ type Props = {\nonSuccess: () => void,\n// Redux state\nloadingStatus: LoadingStatus,\n+ usernamePlaceholder: string,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -52,6 +56,7 @@ class ForgotPasswordPanel extends React.PureComponent<Props, State> {\nopacityValue: PropTypes.object.isRequired,\nonSuccess: PropTypes.func.isRequired,\nloadingStatus: PropTypes.string.isRequired,\n+ usernamePlaceholder: PropTypes.string.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nforgotPassword: PropTypes.func.isRequired,\n};\n@@ -69,7 +74,7 @@ class ForgotPasswordPanel extends React.PureComponent<Props, State> {\nstyle={styles.input}\nvalue={this.state.usernameOrEmailInputText}\nonChangeText={this.onChangeUsernameOrEmailInputText}\n- placeholder={usernamePlaceholder}\n+ placeholder={this.props.usernamePlaceholder}\nautoFocus={true}\nautoCorrect={false}\nautoCapitalize=\"none\"\n@@ -183,6 +188,7 @@ const loadingStatusSelector\nexport default connect(\n(state: AppState) => ({\nloadingStatus: loadingStatusSelector(state),\n+ usernamePlaceholder: usernamePlaceholderSelector(state),\n}),\n{ forgotPassword },\n)(ForgotPasswordPanel);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel-container.react.js",
"new_path": "native/account/log-in-panel-container.react.js",
"diff": "@@ -6,8 +6,10 @@ import {\nstateContainerPropType,\n} from '../utils/state-container';\nimport type { LogInState } from './log-in-panel.react';\n+import type { AppState } from '../redux-setup';\n+import { type Dimensions, dimensionsPropType } from '../types/dimensions';\n-import React from 'react';\n+import * as React from 'react';\nimport {\nView,\nAnimated,\n@@ -20,25 +22,28 @@ import invariant from 'invariant';\nimport PropTypes from 'prop-types';\nimport sleep from 'lib/utils/sleep';\n+import { connect } from 'lib/utils/redux-utils';\n-import { windowWidth } from '../dimensions';\n+import { dimensionsSelector } from '../selectors/dimension-selectors';\nimport LogInPanel from './log-in-panel.react';\nimport ForgotPasswordPanel from './forgot-password-panel.react';\ntype LogInMode = \"log-in\" | \"forgot-password\" | \"forgot-password-success\";\n-type Props = {\n+type Props = {|\nonePasswordSupported: bool,\nsetActiveAlert: (activeAlert: bool) => void,\nopacityValue: Animated.Value,\nforgotPasswordLinkOpacity: Animated.Value,\nlogInState: StateContainer<LogInState>,\n-};\n-type State = {\n+ // Redux state\n+ dimensions: Dimensions,\n+|};\n+type State = {|\npanelTransition: Animated.Value,\nlogInMode: LogInMode,\nnextLogInMode: LogInMode,\n-};\n+|};\nclass LogInPanelContainer extends React.PureComponent<Props, State> {\nstatic propTypes = {\n@@ -47,6 +52,7 @@ class LogInPanelContainer extends React.PureComponent<Props, State> {\nopacityValue: PropTypes.object.isRequired,\nforgotPasswordLinkOpacity: PropTypes.object.isRequired,\nlogInState: stateContainerPropType.isRequired,\n+ dimensions: dimensionsPropType.isRequired,\n};\nstate = {\npanelTransition: new Animated.Value(0),\n@@ -56,6 +62,7 @@ class LogInPanelContainer extends React.PureComponent<Props, State> {\nlogInPanel: ?InnerLogInPanel = null;\nrender() {\n+ const windowWidth = this.props.dimensions.width;\nconst logInPanelDynamicStyle = {\nleft: this.state.panelTransition.interpolate({\ninputRange: [0, 2],\n@@ -284,4 +291,8 @@ const styles = StyleSheet.create({\n},\n});\n-export default LogInPanelContainer;\n+export default connect(\n+ (state: AppState) => ({\n+ dimensions: dimensionsSelector(state),\n+ }),\n+)(LogInPanelContainer);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel.react.js",
"new_path": "native/account/log-in-panel.react.js",
"diff": "@@ -39,7 +39,10 @@ import {\n} from 'lib/actions/user-actions';\nimport { createLoadingStatusSelector } from 'lib/selectors/loading-selectors';\n-import { TextInput, usernamePlaceholder } from './modal-components.react';\n+import {\n+ TextInput,\n+ usernamePlaceholderSelector,\n+} from './modal-components.react';\nimport {\nPanelButton,\nPanelOnePasswordButton,\n@@ -64,6 +67,7 @@ type Props = {\n// Redux state\nloadingStatus: LoadingStatus,\nlogInExtraInfo: () => LogInExtraInfo,\n+ usernamePlaceholder: string,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -79,6 +83,7 @@ class LogInPanel extends React.PureComponent<Props> {\nstate: stateContainerPropType.isRequired,\nloadingStatus: PropTypes.string.isRequired,\nlogInExtraInfo: PropTypes.func.isRequired,\n+ usernamePlaceholder: PropTypes.string.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nlogIn: PropTypes.func.isRequired,\n};\n@@ -117,7 +122,7 @@ class LogInPanel extends React.PureComponent<Props> {\nstyle={styles.input}\nvalue={this.props.state.state.usernameOrEmailInputText}\nonChangeText={this.onChangeUsernameOrEmailInputText}\n- placeholder={usernamePlaceholder}\n+ placeholder={this.props.usernamePlaceholder}\nautoFocus={true}\nautoCorrect={false}\nautoCapitalize=\"none\"\n@@ -357,6 +362,7 @@ export default connect(\n(state: AppState) => ({\nloadingStatus: loadingStatusSelector(state),\nlogInExtraInfo: nativeLogInExtraInfoSelector(state),\n+ usernamePlaceholder: usernamePlaceholderSelector(state),\n}),\n{ logIn },\n)(LogInPanel);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -12,6 +12,8 @@ import type { KeyboardEvent, EmitterSubscription } from '../keyboard';\nimport type { LogInState } from './log-in-panel.react';\nimport type { RegisterState } from './register-panel.react';\nimport type { LogInExtraInfo } from 'lib/types/account-types';\n+import { type Dimensions, dimensionsPropType } from '../types/dimensions';\n+import type { ImageStyle } from '../types/styles';\nimport * as React from 'react';\nimport {\n@@ -44,10 +46,9 @@ import sleep from 'lib/utils/sleep';\nimport { connect } from 'lib/utils/redux-utils';\nimport {\n- windowHeight,\n- windowWidth,\n+ dimensionsSelector,\ncontentVerticalOffset,\n-} from '../dimensions';\n+} from '../selectors/dimension-selectors';\nimport LogInPanelContainer from './log-in-panel-container.react';\nimport RegisterPanel from './register-panel.react';\nimport ConnectedStatusBar from '../connected-status-bar.react';\n@@ -57,7 +58,7 @@ import {\nresetUserStateActionType,\n} from '../navigation/action-types';\nimport { splashBackgroundURI } from './background-info';\n-import { splashStyle } from '../splash';\n+import { splashStyleSelector } from '../splash';\nimport {\naddKeyboardShowListener,\naddKeyboardDismissListener,\n@@ -83,6 +84,8 @@ type Props = {\nurlPrefix: string,\nloggedIn: bool,\nisForeground: bool,\n+ dimensions: Dimensions,\n+ splashStyle: ImageStyle,\n// Redux dispatch functions\ndispatch: Dispatch,\ndispatchActionPayload: DispatchActionPayload,\n@@ -100,7 +103,7 @@ type State = {\nregisterState: StateContainer<RegisterState>;\n};\n-class InnerLoggedOutModal extends React.PureComponent<Props, State> {\n+class LoggedOutModal extends React.PureComponent<Props, State> {\nstatic propTypes = {\nnavigation: PropTypes.shape({\n@@ -112,6 +115,7 @@ class InnerLoggedOutModal extends React.PureComponent<Props, State> {\nurlPrefix: PropTypes.string.isRequired,\nloggedIn: PropTypes.bool.isRequired,\nisForeground: PropTypes.bool.isRequired,\n+ dimensions: dimensionsPropType.isRequired,\ndispatch: PropTypes.func.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\n@@ -172,10 +176,10 @@ class InnerLoggedOutModal extends React.PureComponent<Props, State> {\nthis.state = {\nmode: props.rehydrateConcluded ? \"prompt\" : \"loading\",\npanelPaddingTop: new Animated.Value(\n- InnerLoggedOutModal.calculatePanelPaddingTop(\"prompt\", 0),\n+ this.calculatePanelPaddingTop(\"prompt\", 0),\n),\nfooterPaddingTop: new Animated.Value(\n- InnerLoggedOutModal.calculateFooterPaddingTop(0),\n+ this.calculateFooterPaddingTop(0),\n),\npanelOpacity: new Animated.Value(0),\nforgotPasswordLinkOpacity: new Animated.Value(0),\n@@ -351,10 +355,11 @@ class InnerLoggedOutModal extends React.PureComponent<Props, State> {\nreturn false;\n}\n- static calculatePanelPaddingTop(\n+ calculatePanelPaddingTop(\nmode: LoggedOutMode,\nkeyboardHeight: number,\n) {\n+ const windowHeight = this.props.dimensions.height;\nlet containerSize = Platform.OS === \"ios\" ? 62 : 59; // header height\nif (mode === \"log-in\") {\n// We need to make space for the reset password button on smaller devices\n@@ -373,7 +378,8 @@ class InnerLoggedOutModal extends React.PureComponent<Props, State> {\nreturn (contentHeight - containerSize - keyboardHeight) / 2;\n}\n- static calculateFooterPaddingTop(keyboardHeight: number) {\n+ calculateFooterPaddingTop(keyboardHeight: number) {\n+ const windowHeight = this.props.dimensions.height;\nconst textHeight = Platform.OS === \"ios\" ? 17 : 19;\nif (DeviceInfo.isIPhoneX_deprecated) {\nkeyboardHeight -= 34;\n@@ -391,7 +397,7 @@ class InnerLoggedOutModal extends React.PureComponent<Props, State> {\n}\nconst animations = [];\nconst newPanelPaddingTopValue =\n- InnerLoggedOutModal.calculatePanelPaddingTop(\n+ this.calculatePanelPaddingTop(\nthis.state.mode,\nthis.keyboardHeight,\n);\n@@ -414,7 +420,7 @@ class InnerLoggedOutModal extends React.PureComponent<Props, State> {\n{\nduration,\neasing: Easing.out(Easing.ease),\n- toValue: InnerLoggedOutModal.calculateFooterPaddingTop(\n+ toValue: this.calculateFooterPaddingTop(\nrealKeyboardHeight,\n),\n},\n@@ -467,7 +473,7 @@ class InnerLoggedOutModal extends React.PureComponent<Props, State> {\nanimateKeyboardDownOrBackToPrompt(inputDuration: ?number) {\nconst duration = inputDuration ? inputDuration : 250;\nconst newLastPanelPaddingTopValue =\n- InnerLoggedOutModal.calculatePanelPaddingTop(\n+ this.calculatePanelPaddingTop(\nthis.nextMode,\n0,\n);\n@@ -486,7 +492,7 @@ class InnerLoggedOutModal extends React.PureComponent<Props, State> {\n{\nduration,\neasing: Easing.out(Easing.ease),\n- toValue: InnerLoggedOutModal.calculateFooterPaddingTop(\n+ toValue: this.calculateFooterPaddingTop(\nthis.keyboardHeight,\n),\n},\n@@ -571,7 +577,7 @@ class InnerLoggedOutModal extends React.PureComponent<Props, State> {\nconst background = (\n<Image\nsource={{ uri: splashBackgroundURI }}\n- style={styles.modalBackground}\n+ style={[ styles.modalBackground, this.props.splashStyle ]}\n/>\n);\n@@ -651,13 +657,18 @@ class InnerLoggedOutModal extends React.PureComponent<Props, State> {\n);\n}\n+ const windowWidth = this.props.dimensions.width;\n+ const buttonStyle = {\n+ opacity: this.state.panelOpacity,\n+ left: windowWidth < 360 ? 28 : 40,\n+ };\nconst padding = { paddingTop: this.state.panelPaddingTop };\n- const opacity = { opacity: this.state.panelOpacity };\n+\nconst animatedContent = (\n<Animated.View style={[styles.animationContainer, padding]}>\n<View>\n<Text style={styles.header}>SquadCal</Text>\n- <Animated.View style={[styles.backButton, opacity]}>\n+ <Animated.View style={[ styles.backButton, buttonStyle ]}>\n<TouchableOpacity activeOpacity={0.6} onPress={this.hardwareBack}>\n<Icon\nname=\"arrow-circle-o-left\"\n@@ -688,8 +699,10 @@ class InnerLoggedOutModal extends React.PureComponent<Props, State> {\n</React.Fragment>\n);\n} else {\n+ // https://github.com/facebook/react-native/issues/6785\n+ const topContainerStyle = { height: this.props.dimensions.height };\nreturn (\n- <View style={styles.topContainer}>\n+ <View style={[ styles.androidTopContainer, topContainerStyle ]}>\n{background}\n<View style={styles.container}>\n{statusBar}\n@@ -746,12 +759,9 @@ const styles = StyleSheet.create({\nbottom: 0,\nleft: 0,\nright: 0,\n- ...splashStyle,\n},\n- topContainer: {\n+ androidTopContainer: {\nbackgroundColor: 'transparent',\n- // https://github.com/facebook/react-native/issues/6785\n- height: windowHeight,\n},\ncontainer: {\nflex: 1,\n@@ -768,7 +778,6 @@ const styles = StyleSheet.create({\n},\nbackButton: {\nposition: 'absolute',\n- left: windowWidth < 360 ? 28 : 40,\ntop: 13,\n},\nbuttonContainer: {\n@@ -811,7 +820,7 @@ const styles = StyleSheet.create({\nconst isForegroundSelector =\ncreateIsForegroundSelector(LoggedOutModalRouteName);\n-const LoggedOutModal = connect(\n+export default connect(\n(state: AppState) => ({\nrehydrateConcluded: state._persist && state._persist.rehydrated,\ncookie: state.cookie,\n@@ -819,9 +828,9 @@ const LoggedOutModal = connect(\nloggedIn: !!(state.currentUserInfo &&\n!state.currentUserInfo.anonymous && true),\nisForeground: isForegroundSelector(state),\n+ dimensions: dimensionsSelector(state),\n+ splashStyle: splashStyleSelector(state),\n}),\nnull,\ntrue,\n-)(InnerLoggedOutModal);\n-\n-export default LoggedOutModal;\n+)(LoggedOutModal);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/modal-components.react.js",
"new_path": "native/account/modal-components.react.js",
"diff": "// @flow\n-import React from 'react';\n+import type { Dimensions } from '../types/dimensions';\n+\n+import * as React from 'react';\nimport {\nTextInput as BaseTextInput,\nView,\n@@ -8,8 +10,9 @@ import {\nPlatform,\n} from 'react-native';\nimport invariant from 'invariant';\n+import { createSelector } from 'reselect';\n-import { windowWidth } from '../dimensions';\n+import { dimensionsSelector } from '../selectors/dimension-selectors';\nclass TextInput extends React.PureComponent<*> {\n@@ -54,11 +57,14 @@ const styles = StyleSheet.create({\n},\n});\n-const usernamePlaceholder = windowWidth < 360\n+const usernamePlaceholderSelector = createSelector<*, *, *, *>(\n+ dimensionsSelector,\n+ (dimensions: Dimensions): string => dimensions.width < 360\n? \"Username or email\"\n- : \"Username or email address\";\n+ : \"Username or email address\",\n+);\nexport {\nTextInput,\n- usernamePlaceholder,\n+ usernamePlaceholderSelector,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/panel-components.react.js",
"new_path": "native/account/panel-components.react.js",
"diff": "@@ -4,6 +4,8 @@ import type { LoadingStatus } from 'lib/types/loading-types';\nimport { loadingStatusPropType } from 'lib/types/loading-types';\nimport type { ViewStyle } from '../types/styles';\nimport type { KeyboardEvent, EmitterSubscription } from '../keyboard';\n+import { type Dimensions, dimensionsPropType } from '../types/dimensions';\n+import type { AppState } from '../redux-setup';\nimport * as React from 'react';\nimport {\n@@ -14,13 +16,16 @@ import {\nAnimated,\nScrollView,\nLayoutAnimation,\n+ ViewPropTypes,\n} from 'react-native';\nimport Icon from 'react-native-vector-icons/FontAwesome';\nimport PropTypes from 'prop-types';\n+import { connect } from 'lib/utils/redux-utils';\n+\nimport Button from '../components/button.react';\nimport OnePasswordButton from '../components/one-password-button.react';\n-import { windowHeight } from '../dimensions';\n+import { dimensionsSelector } from '../selectors/dimension-selectors';\nimport {\naddKeyboardShowListener,\naddKeyboardDismissListener,\n@@ -86,12 +91,19 @@ type PanelProps = {|\nopacityValue: Animated.Value,\nchildren: React.Node,\nstyle?: ViewStyle,\n+ dimensions: Dimensions,\n|};\ntype PanelState = {|\nkeyboardHeight: number,\n|};\n-class Panel extends React.PureComponent<PanelProps, PanelState> {\n+class InnerPanel extends React.PureComponent<PanelProps, PanelState> {\n+ static propTypes = {\n+ opacityValue: PropTypes.instanceOf(Animated.Value).isRequired,\n+ children: PropTypes.node.isRequired,\n+ style: ViewPropTypes.style,\n+ dimensions: dimensionsPropType.isRequired,\n+ };\nstate = {\nkeyboardHeight: 0,\n};\n@@ -116,6 +128,7 @@ class Panel extends React.PureComponent<PanelProps, PanelState> {\n}\nkeyboardHandler = (event: ?KeyboardEvent) => {\n+ const windowHeight = this.props.dimensions.height;\nconst keyboardHeight = event\n? windowHeight - event.endCoordinates.screenY\n: 0;\n@@ -139,9 +152,17 @@ class Panel extends React.PureComponent<PanelProps, PanelState> {\n}\nrender() {\n- const opacityStyle = { opacity: this.props.opacityValue };\n+ const windowHeight = this.props.dimensions.height;\n+ const containerStyle = {\n+ opacity: this.props.opacityValue,\n+ marginTop: windowHeight < 600 ? 15 : 40,\n+ };\nconst content = (\n- <Animated.View style={[styles.container, opacityStyle, this.props.style]}>\n+ <Animated.View style={[\n+ styles.container,\n+ containerStyle,\n+ this.props.style,\n+ ]}>\n{this.props.children}\n</Animated.View>\n);\n@@ -162,6 +183,12 @@ class Panel extends React.PureComponent<PanelProps, PanelState> {\n}\n+const Panel = connect(\n+ (state: AppState) => ({\n+ dimensions: dimensionsSelector(state),\n+ }),\n+)(InnerPanel);\n+\nconst styles = StyleSheet.create({\nloadingIndicatorContainer: {\nwidth: 14,\n@@ -201,7 +228,6 @@ const styles = StyleSheet.create({\npaddingRight: 18,\nmarginLeft: 20,\nmarginRight: 20,\n- marginTop: windowHeight < 600 ? 15 : 40,\nborderRadius: 6,\nbackgroundColor: '#FFFFFFAA',\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/verification-modal.react.js",
"new_path": "native/account/verification-modal.react.js",
"diff": "@@ -15,6 +15,8 @@ import {\ntype HandleVerificationCodeResult,\n} from 'lib/types/verify-types';\nimport type { KeyboardEvent } from '../keyboard';\n+import { type Dimensions, dimensionsPropType } from '../types/dimensions';\n+import type { ImageStyle } from '../types/styles';\nimport * as React from 'react';\nimport {\n@@ -45,13 +47,13 @@ import {\n} from 'lib/actions/user-actions';\nimport sleep from 'lib/utils/sleep';\n-import { windowHeight } from '../dimensions';\n+import { dimensionsSelector } from '../selectors/dimension-selectors';\nimport ConnectedStatusBar from '../connected-status-bar.react';\nimport ResetPasswordPanel from './reset-password-panel.react';\nimport { createIsForegroundSelector } from '../selectors/nav-selectors';\nimport { navigateToAppActionType } from '../navigation/action-types';\nimport { splashBackgroundURI } from './background-info';\n-import { splashStyle } from '../splash';\n+import { splashStyleSelector } from '../splash';\nimport {\naddKeyboardShowListener,\naddKeyboardDismissListener,\n@@ -68,6 +70,8 @@ type Props = {\n& NavigationScreenProp<NavigationLeafRoute>,\n// Redux state\nisForeground: bool,\n+ dimensions: Dimensions,\n+ splashStyle: ImageStyle,\n// Redux dispatch functions\ndispatchActionPayload: DispatchActionPayload,\ndispatchActionPromise: DispatchActionPromise,\n@@ -96,6 +100,7 @@ class InnerVerificationModal extends React.PureComponent<Props, State> {\ngoBack: PropTypes.func.isRequired,\n}).isRequired,\nisForeground: PropTypes.bool.isRequired,\n+ dimensions: dimensionsPropType.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nhandleVerificationCode: PropTypes.func.isRequired,\n@@ -104,7 +109,7 @@ class InnerVerificationModal extends React.PureComponent<Props, State> {\nstate = {\nmode: \"simple-text\",\npaddingTop: new Animated.Value(\n- InnerVerificationModal.currentPaddingTop(\"simple-text\", 0),\n+ this.currentPaddingTop(\"simple-text\", 0),\n),\nverifyField: null,\nerrorMessage: null,\n@@ -160,7 +165,7 @@ class InnerVerificationModal extends React.PureComponent<Props, State> {\nthis.setState({\nmode: \"simple-text\",\npaddingTop: new Animated.Value(\n- InnerVerificationModal.currentPaddingTop(\"simple-text\", 0),\n+ this.currentPaddingTop(\"simple-text\", 0),\n),\nverifyField: null,\nerrorMessage: null,\n@@ -272,10 +277,11 @@ class InnerVerificationModal extends React.PureComponent<Props, State> {\n}\n}\n- static currentPaddingTop(\n+ currentPaddingTop(\nmode: VerificationModalMode,\nkeyboardHeight: number,\n) {\n+ const windowHeight = this.props.dimensions.height;\nlet containerSize = 0;\nif (mode === \"simple-text\") {\ncontainerSize = 90;\n@@ -293,7 +299,7 @@ class InnerVerificationModal extends React.PureComponent<Props, State> {\n{\nduration,\neasing: Easing.out(Easing.ease),\n- toValue: InnerVerificationModal.currentPaddingTop(\n+ toValue: this.currentPaddingTop(\nthis.state.mode,\nthis.keyboardHeight,\n),\n@@ -338,7 +344,7 @@ class InnerVerificationModal extends React.PureComponent<Props, State> {\n{\nduration,\neasing: Easing.out(Easing.ease),\n- toValue: InnerVerificationModal.currentPaddingTop(this.nextMode, 0),\n+ toValue: this.currentPaddingTop(this.nextMode, 0),\n},\n),\n];\n@@ -385,7 +391,7 @@ class InnerVerificationModal extends React.PureComponent<Props, State> {\nconst background = (\n<Image\nsource={{ uri: splashBackgroundURI }}\n- style={styles.modalBackground}\n+ style={[ styles.modalBackground, this.props.splashStyle ]}\n/>\n);\nconst closeButton = (\n@@ -483,7 +489,6 @@ const styles = StyleSheet.create({\nposition: 'absolute',\nwidth: ('100%': number | string),\nheight: ('100%': number | string),\n- ...splashStyle,\n},\ncontainer: {\nflex: 1,\n@@ -529,6 +534,8 @@ const isForegroundSelector =\nconst VerificationModal = connect(\n(state: AppState) => ({\nisForeground: isForegroundSelector(state),\n+ dimensions: dimensionsSelector(state),\n+ splashStyle: splashStyleSelector(state),\n}),\n{ handleVerificationCode },\n)(InnerVerificationModal);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -22,6 +22,7 @@ import {\ntype CalendarFilter,\ncalendarFilterPropType,\n} from 'lib/types/filter-types';\n+import { type Dimensions, dimensionsPropType } from '../types/dimensions';\nimport React from 'react';\nimport {\n@@ -60,7 +61,11 @@ import { connect } from 'lib/utils/redux-utils';\nimport { registerFetchKey } from 'lib/reducers/loading-reducer';\nimport { Entry, InternalEntry, entryStyles } from './entry.react';\n-import { contentVerticalOffset, windowHeight, tabBarSize } from '../dimensions';\n+import {\n+ dimensionsSelector,\n+ contentVerticalOffset,\n+ tabBarSize,\n+} from '../selectors/dimension-selectors';\nimport { calendarListData } from '../selectors/calendar-selectors';\nimport {\ncreateIsForegroundSelector,\n@@ -120,6 +125,7 @@ type Props = {\nstartDate: string,\nendDate: string,\ncalendarFilters: $ReadOnlyArray<CalendarFilter>,\n+ dimensions: Dimensions,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -164,6 +170,7 @@ class InnerCalendar extends React.PureComponent<Props, State> {\nstartDate: PropTypes.string.isRequired,\nendDate: PropTypes.string.isRequired,\ncalendarFilters: PropTypes.arrayOf(calendarFilterPropType).isRequired,\n+ dimensions: dimensionsPropType.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nupdateCalendarQuery: PropTypes.func.isRequired,\n};\n@@ -715,8 +722,7 @@ class InnerCalendar extends React.PureComponent<Props, State> {\nlet flatList = null;\nif (listDataWithHeights) {\nconst flatListStyle = { opacity: this.state.readyToShowList ? 1 : 0 };\n- const initialScrollIndex =\n- InnerCalendar.initialScrollIndex(listDataWithHeights);\n+ const initialScrollIndex = this.initialScrollIndex(listDataWithHeights);\nflatList = (\n<FlatList\ndata={listDataWithHeights}\n@@ -769,16 +775,17 @@ class InnerCalendar extends React.PureComponent<Props, State> {\n);\n}\n- static flatListHeight() {\n+ flatListHeight() {\n+ const windowHeight = this.props.dimensions.height;\nreturn windowHeight - contentVerticalOffset - tabBarSize;\n}\n- static initialScrollIndex(data: $ReadOnlyArray<CalendarItemWithHeight>) {\n+ initialScrollIndex(data: $ReadOnlyArray<CalendarItemWithHeight>) {\nconst todayIndex = _findIndex(['dateString', dateString(new Date())])(data);\nconst heightOfTodayHeader = InnerCalendar.itemHeight(data[todayIndex]);\nlet returnIndex = todayIndex;\n- let heightLeft = (InnerCalendar.flatListHeight() - heightOfTodayHeader) / 2;\n+ let heightLeft = (this.flatListHeight() - heightOfTodayHeader) / 2;\nwhile (heightLeft > 0) {\nheightLeft -= InnerCalendar.itemHeight(data[--returnIndex]);\n}\n@@ -902,7 +909,7 @@ class InnerCalendar extends React.PureComponent<Props, State> {\nconst itemHeight = InnerCalendar.itemHeight(data[index]);\nconst entryAdditionalActiveHeight = Platform.OS === \"android\" ? 21 : 20;\nconst itemEnd = itemStart + itemHeight + entryAdditionalActiveHeight;\n- let visibleHeight = InnerCalendar.flatListHeight() - keyboardHeight;\n+ let visibleHeight = this.flatListHeight() - keyboardHeight;\n// flatListHeight() factors in the size of the iOS tab bar, but it is hidden\n// by the keyboard since it is at the bottom\nif (Platform.OS === \"ios\") {\n@@ -1119,6 +1126,7 @@ const Calendar = connect(\nstartDate: state.navInfo.startDate,\nendDate: state.navInfo.endDate,\ncalendarFilters: state.calendarFilters,\n+ dimensions: dimensionsSelector(state),\n}),\n{ updateCalendarQuery },\n)(InnerCalendar);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/tag-input.react.js",
"new_path": "native/components/tag-input.react.js",
"diff": "// @flow\nimport type { ViewStyle, TextStyle } from '../types/styles';\n+import { type Dimensions, dimensionsPropType } from '../types/dimensions';\n+import type { AppState } from '../redux-setup';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n@@ -10,7 +12,6 @@ import {\nTextInput,\nStyleSheet,\nTouchableOpacity,\n- Dimensions,\nTouchableWithoutFeedback,\nScrollView,\nViewPropTypes,\n@@ -18,7 +19,9 @@ import {\n} from 'react-native';\nimport invariant from 'invariant';\n-const windowWidth = Dimensions.get('window').width;\n+import { connect } from 'lib/utils/redux-utils';\n+\n+import { dimensionsSelector } from '../selectors/dimension-selectors';\ntype Props<T> = {\n/**\n@@ -86,6 +89,8 @@ type Props<T> = {\n* value and the new value, which looks sketchy.\n*/\ndefaultInputWidth: number,\n+ // Redux state\n+ dimensions: Dimensions,\n};\ntype State = {\ninputWidth: number,\n@@ -109,8 +114,9 @@ class TagInput<T> extends React.PureComponent<Props<T>, State> {\nmaxHeight: PropTypes.number,\nonHeightChange: PropTypes.func,\ndefaultInputWidth: PropTypes.number,\n+ dimensions: dimensionsPropType.isRequired,\n};\n- wrapperWidth = windowWidth;\n+ wrapperWidth: number;\nspaceLeft = 0;\n// scroll to bottom\ncontentHeight = 0;\n@@ -150,6 +156,7 @@ class TagInput<T> extends React.PureComponent<Props<T>, State> {\ninputWidth: props.defaultInputWidth,\nwrapperHeight: 36,\n};\n+ this.wrapperWidth = props.dimensions.width;\n}\ncomponentWillReceiveProps(nextProps: Props<T>) {\n@@ -466,4 +473,8 @@ const styles = StyleSheet.create({\n},\n});\n-export default TagInput;\n+export default connect(\n+ (state: AppState) => ({\n+ dimensions: dimensionsSelector(state),\n+ }),\n+)(TagInput);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/tooltip.react.js",
"new_path": "native/components/tooltip.react.js",
"diff": "// @flow\nimport type { ViewStyle, TextStyle } from '../types/styles';\n+import { type Dimensions, dimensionsPropType } from '../types/dimensions';\n+import type { AppState } from '../redux-setup';\nimport * as React from 'react';\nimport {\n@@ -9,7 +11,6 @@ import {\nAnimated,\nTouchableOpacity,\nStyleSheet,\n- Dimensions,\nText,\nEasing,\nViewPropTypes,\n@@ -18,12 +19,13 @@ import {\nimport PropTypes from 'prop-types';\nimport invariant from 'invariant';\n+import { connect } from 'lib/utils/redux-utils';\n+\nimport TooltipItem, { type Label, labelPropType } from './tooltip-item.react';\n+import { dimensionsSelector } from '../selectors/dimension-selectors';\nexport type TooltipItemData = { +label: Label, onPress: () => void };\n-const window = Dimensions.get('window');\n-\ntype Props = {\nbuttonComponent: React.Node,\nbuttonComponentExpandRatio: number,\n@@ -45,6 +47,8 @@ type Props = {\ntimingConfig?: { duration?: number },\nspringConfig?: { tension?: number, friction?: number },\nopacityChangeDuration?: number,\n+ // Redux state\n+ dimensions: Dimensions,\n};\ntype State = {\nisModalOpen: bool,\n@@ -90,6 +94,7 @@ class Tooltip extends React.PureComponent<Props, State> {\ntimingConfig: PropTypes.object,\nspringConfig: PropTypes.object,\nopacityChangeDuration: PropTypes.number,\n+ dimensions: dimensionsPropType.isRequired,\n};\nstatic defaultProps = {\nbuttonComponentExpandRatio: 1.0,\n@@ -172,11 +177,12 @@ class Tooltip extends React.PureComponent<Props, State> {\nconst componentWrapper = this.wrapperComponent;\ninvariant(componentWrapper, \"should be set\");\n+ const { width: windowWidth, height: windowHeight } = this.props.dimensions;\ncomponentWrapper.measure((x, y, width, height, pageX, pageY) => {\nconst fullWidth = pageX + tooltipContainerWidth\n+ (width - tooltipContainerWidth) / 2;\n- const tooltipContainerX_final = fullWidth > window.width\n- ? window.width - tooltipContainerWidth\n+ const tooltipContainerX_final = fullWidth > windowWidth\n+ ? windowWidth - tooltipContainerWidth\n: pageX + (width - tooltipContainerWidth) / 2;\nlet tooltipContainerY_final = this.state.tooltipTriangleDown\n? pageY - tooltipContainerHeight - 20\n@@ -186,7 +192,7 @@ class Tooltip extends React.PureComponent<Props, State> {\ntooltipContainerY_final = pageY + height + 20;\ntooltipTriangleDown = false;\n}\n- if (pageY + tooltipContainerHeight + 80 > window.height) {\n+ if (pageY + tooltipContainerHeight + 80 > windowHeight) {\ntooltipContainerY_final = pageY - tooltipContainerHeight - 20;\ntooltipTriangleDown = true;\n}\n@@ -507,4 +513,8 @@ const styles = StyleSheet.create({\n},\n});\n-export default Tooltip;\n+export default connect(\n+ (state: AppState) => ({\n+ dimensions: dimensionsSelector(state),\n+ }),\n+)(Tooltip);\n"
},
{
"change_type": "DELETE",
"old_path": "native/dimensions.js",
"new_path": null,
"diff": "-// @flow\n-\n-import { Dimensions, Platform, DeviceInfo } from 'react-native';\n-\n-let { height, width } = Dimensions.get('window');\n-if (Platform.OS === \"android\") {\n- // Android's Dimensions.get doesn't include the status bar\n- height -= 24;\n-}\n-if (Platform.OS === \"ios\" && DeviceInfo.isIPhoneX_deprecated) {\n- height -= 34;\n-}\n-const windowHeight = height;\n-const windowWidth = width;\n-\n-let contentVerticalOffset = 0;\n-if (Platform.OS === \"ios\") {\n- contentVerticalOffset = DeviceInfo.isIPhoneX_deprecated ? 44 : 20;\n-}\n-\n-const tabBarSize = Platform.OS === \"android\" ? 50 : 49;\n-\n-export {\n- windowHeight,\n- windowWidth,\n- contentVerticalOffset,\n- tabBarSize,\n-};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/dimension-selectors.js",
"new_path": "native/selectors/dimension-selectors.js",
"diff": "@@ -20,7 +20,7 @@ if (Platform.OS === \"android\") {\nconst dimensionsSelector = createSelector<*, *, *, *>(\n(state: AppState) => state.dimensions,\n- (dimensions: Dimensions) => {\n+ (dimensions: Dimensions): Dimensions => {\nlet { height, width } = dimensions;\nif (Platform.OS === \"android\") {\n// Android starts the 0 pixel below the status bar height,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/splash.js",
"new_path": "native/splash.js",
"diff": "// @flow\n+import type { ImageStyle } from './types/styles';\n+import type { Dimensions } from './types/dimensions';\n+\nimport { Platform, PixelRatio } from 'react-native';\n+import { createSelector } from 'reselect';\n-import { windowHeight, windowWidth } from './dimensions';\n+import { dimensionsSelector } from './selectors/dimension-selectors';\n-let splashStyle;\n-if (Platform.OS === \"android\") {\n+const splashStyleSelector = createSelector<*, *, *, *>(\n+ dimensionsSelector,\n+ (dimensions: Dimensions): ImageStyle => {\n+ if (Platform.OS !== \"android\") {\n+ return null;\n+ }\n+ const { width: windowWidth, height: windowHeight } = dimensions;\nlet splashWidth = windowWidth;\nif (windowWidth > 960) {\n} else if (windowWidth > 800) {\n@@ -29,8 +38,10 @@ if (Platform.OS === \"android\") {\n} else {\nsplashWidth = 320;\n}\n- const splashHeight = windowWidth <= 480 ? splashWidth * 2.5 : splashWidth * 2;\n- splashStyle = {\n+ const splashHeight = windowWidth <= 480\n+ ? splashWidth * 2.5\n+ : splashWidth * 2;\n+ return {\nwidth: splashWidth,\nheight: splashHeight,\ntransform: [\n@@ -38,8 +49,10 @@ if (Platform.OS === \"android\") {\n{ translateY: -1 * (splashHeight - windowHeight) / 2 },\n],\n};\n-}\n+ },\n+);\n+\nexport {\n- splashStyle,\n+ splashStyleSelector,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/types/dimensions.js",
"new_path": "native/types/dimensions.js",
"diff": "// @flow\n+import PropTypes from 'prop-types';\n+\nexport type Dimensions = {|\nheight: number,\nwidth: number,\n|};\n+\n+export const dimensionsPropType = PropTypes.shape({\n+ height: PropTypes.number.isRequired,\n+ width: PropTypes.number.isRequired,\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "native/utils/media-utils.js",
"new_path": "native/utils/media-utils.js",
"diff": "// @flow\n+import type { Dimensions } from '../types/dimensions';\n+\nimport { Image } from 'react-native';\n-export type Dimensions = {|\n- height: number,\n- width: number,\n-|};\nasync function preloadImage(uri: string): Promise<Dimensions> {\nconst [ dimensions ] = await Promise.all([\nfetchSize(uri),\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Convert business logic to use Redux dimensions |
129,187 | 14.03.2019 20:26:42 | 14,400 | 2921306afa45eabf16f9d9121f6506582164caa0 | [native] Fix Tooltip ref mechanism
Broken by Redux `connect` wrapping | [
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel.react.js",
"new_path": "native/account/log-in-panel.react.js",
"diff": "@@ -62,7 +62,7 @@ type Props = {\nsetActiveAlert: (activeAlert: bool) => void,\nopacityValue: Animated.Value,\nonePasswordSupported: bool,\n- innerRef: (logInPanel: LogInPanel) => void,\n+ innerRef: (logInPanel: ?LogInPanel) => void,\nstate: StateContainer<LogInState>,\n// Redux state\nloadingStatus: LoadingStatus,\n@@ -95,6 +95,10 @@ class LogInPanel extends React.PureComponent<Props> {\nthis.attemptToFetchCredentials();\n}\n+ componentWillUnmount() {\n+ this.props.innerRef(null);\n+ }\n+\nasync attemptToFetchCredentials() {\nconst credentials = await fetchNativeCredentials();\nif (credentials) {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/text-message.react.js",
"new_path": "native/chat/text-message.react.js",
"diff": "@@ -133,7 +133,7 @@ class TextMessage extends React.PureComponent<Props> {\nlabelStyle={styles.popoverLabelStyle}\nonOpenTooltipMenu={this.onFocus}\nonCloseTooltipMenu={this.onBlur}\n- ref={this.tooltipRef}\n+ innerRef={this.tooltipRef}\n/>\n</ComposedMessage>\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/tooltip.react.js",
"new_path": "native/components/tooltip.react.js",
"diff": "@@ -47,6 +47,7 @@ type Props = {\ntimingConfig?: { duration?: number },\nspringConfig?: { tension?: number, friction?: number },\nopacityChangeDuration?: number,\n+ innerRef?: (tooltip: ?Tooltip) => void,\n// Redux state\ndimensions: Dimensions,\n};\n@@ -94,6 +95,7 @@ class Tooltip extends React.PureComponent<Props, State> {\ntimingConfig: PropTypes.object,\nspringConfig: PropTypes.object,\nopacityChangeDuration: PropTypes.number,\n+ innerRef: PropTypes.func,\ndimensions: dimensionsPropType.isRequired,\n};\nstatic defaultProps = {\n@@ -129,12 +131,21 @@ class Tooltip extends React.PureComponent<Props, State> {\n};\n}\n- componentWillMount() {\n+ componentDidMount() {\nconst newOppositeOpacity = this.state.opacity.interpolate({\ninputRange: [0, 1],\noutputRange: [1, 0],\n});\nthis.setState({ oppositeOpacity: newOppositeOpacity });\n+ if (this.props.innerRef) {\n+ this.props.innerRef(this);\n+ }\n+ }\n+\n+ componentWillUnmount() {\n+ if (this.props.innerRef) {\n+ this.props.innerRef(null);\n+ }\n}\ntoggleModal = () => {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Fix Tooltip ref mechanism
Broken by Redux `connect` wrapping |
129,187 | 14.03.2019 20:29:11 | 14,400 | 3ba7444dd60ea525f6372b917d65c60bb4680daa | [native] Limit ComposedMessage width to 80% | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/composed-message-width.js",
"diff": "+// @flow\n+\n+import type { Dimensions } from '../types/dimensions';\n+\n+import { createSelector } from 'reselect';\n+\n+import { dimensionsSelector } from '../selectors/dimension-selectors';\n+\n+// Keep sorta synced with styles.alignment/styles.messageBox in ComposedMessage\n+const composedMessageMaxWidthSelector = createSelector<*, *, *, *>(\n+ dimensionsSelector,\n+ (dimensions: Dimensions): number => (dimensions.width - 24) * 0.80,\n+);\n+\n+// Keep strictly synced with styles.message in TextMessage\n+const textMessageMaxWidthSelector = createSelector<*, *, *, *>(\n+ composedMessageMaxWidthSelector,\n+ (composedMessageMaxWidth: number): number => composedMessageMaxWidth - 24,\n+);\n+\n+export {\n+ composedMessageMaxWidthSelector,\n+ textMessageMaxWidthSelector,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/composed-message.react.js",
"new_path": "native/chat/composed-message.react.js",
"diff": "@@ -6,6 +6,7 @@ import type {\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport { assertComposableMessageType } from 'lib/types/message-types';\nimport type { ViewStyle } from '../types/styles';\n+import type { AppState } from '../redux-setup';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n@@ -13,9 +14,11 @@ import { Text, StyleSheet, View, ViewPropTypes } from 'react-native';\nimport Icon from 'react-native-vector-icons/Feather';\nimport { stringForUser } from 'lib/shared/user-utils';\n+import { connect } from 'lib/utils/redux-utils';\nimport FailedSend from './failed-send.react';\nimport RoundedMessageContainer from './rounded-message-container.react';\n+import { composedMessageMaxWidthSelector } from './composed-message-width';\ntype Props = {|\nitem: ChatMessageInfoItemWithHeight,\n@@ -23,6 +26,8 @@ type Props = {|\nstyle?: ViewStyle,\nborderRadius: number,\nchildren: React.Node,\n+ // Redux state\n+ composedMessageMaxWidth: number,\n|};\nclass ComposedMessage extends React.PureComponent<Props> {\n@@ -32,6 +37,7 @@ class ComposedMessage extends React.PureComponent<Props> {\nstyle: ViewPropTypes.style,\nborderRadius: PropTypes.number.isRequired,\nchildren: PropTypes.node.isRequired,\n+ composedMessageMaxWidth: PropTypes.number.isRequired,\n};\nstatic defaultProps = {\nborderRadius: 8,\n@@ -50,11 +56,14 @@ class ComposedMessage extends React.PureComponent<Props> {\nstyles.alignment,\n{ marginBottom: item.endsCluster ? 12 : 5 },\n];\n+ const messageBoxStyle = {\n+ maxWidth: this.props.composedMessageMaxWidth,\n+ };\nlet authorName = null;\nif (!isViewer && item.startsCluster) {\nauthorName = (\n- <Text style={styles.authorName}>\n+ <Text style={styles.authorName} numberOfLines={1}>\n{stringForUser(creator)}\n</Text>\n);\n@@ -87,8 +96,8 @@ class ComposedMessage extends React.PureComponent<Props> {\nreturn (\n<View style={containerStyle}>\n{authorName}\n- <View style={styles.content}>\n- <View style={[styles.messageBox, alignStyle]}>\n+ <View style={[ styles.content, alignStyle ]}>\n+ <View style={[ styles.messageBox, messageBoxStyle ]}>\n<RoundedMessageContainer\nitem={item}\nborderRadius={borderRadius}\n@@ -144,4 +153,8 @@ const styles = StyleSheet.create({\n},\n});\n-export default ComposedMessage;\n+export default connect(\n+ (state: AppState) => ({\n+ composedMessageMaxWidth: composedMessageMaxWidthSelector(state),\n+ }),\n+)(ComposedMessage);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-container.react.js",
"new_path": "native/chat/message-list-container.react.js",
"diff": "@@ -41,6 +41,7 @@ import ChatInputBar from './chat-input-bar.react';\nimport {\nmultimediaMessageLoadingContentHeight,\n} from './multimedia-message.react';\n+import { textMessageMaxWidthSelector } from './composed-message-width';\nexport type ChatMessageInfoItemWithHeight =\n| {|\n@@ -79,6 +80,7 @@ type Props = {|\n// Redux state\nthreadInfo: ?ThreadInfo,\nmessageListData: $ReadOnlyArray<ChatMessageItem>,\n+ textMessageMaxWidth: number,\n|};\ntype State = {|\ntextToMeasure: TextToMeasure[],\n@@ -99,6 +101,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n}).isRequired,\nthreadInfo: threadInfoPropType,\nmessageListData: PropTypes.arrayOf(chatMessageItemPropType).isRequired,\n+ textMessageMaxWidth: PropTypes.number.isRequired,\n};\nstatic navigationOptions = ({ navigation }) => ({\nheaderTitle: (\n@@ -123,7 +126,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nconstructor(props: Props) {\nsuper(props);\nconst textToMeasure = props.messageListData\n- ? MessageListContainer.textToMeasureFromListData(props.messageListData)\n+ ? this.textToMeasureFromListData(props.messageListData)\n: [];\nconst listDataWithHeights =\nprops.messageListData && textToMeasure.length === 0\n@@ -132,7 +135,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nthis.state = { textToMeasure, listDataWithHeights };\n}\n- static textToMeasureFromListData(listData: $ReadOnlyArray<ChatMessageItem>) {\n+ textToMeasureFromListData(listData: $ReadOnlyArray<ChatMessageItem>) {\nconst textToMeasure = [];\nfor (let item of listData) {\nif (item.itemType !== \"message\") {\n@@ -140,12 +143,11 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n}\nconst { messageInfo } = item;\nif (messageInfo.type === messageTypes.TEXT) {\n- const { isViewer } = messageInfo.creator;\nconst style = [\nonlyEmojiRegex.test(messageInfo.text)\n? styles.emojiOnlyText\n: styles.text,\n- isViewer ? styles.viewerMargins : styles.nonViewerMargins,\n+ { width: this.props.textMessageMaxWidth },\n];\ntextToMeasure.push({\nid: messageKey(messageInfo),\n@@ -203,8 +205,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nreturn;\n}\n- const newTextToMeasure =\n- MessageListContainer.textToMeasureFromListData(newListData);\n+ const newTextToMeasure = this.textToMeasureFromListData(newListData);\nthis.setState({ textToMeasure: newTextToMeasure });\n}\n@@ -386,14 +387,6 @@ const styles = StyleSheet.create({\nloadingIndicatorContainer: {\nflex: 1,\n},\n- viewerMargins: {\n- left: 24,\n- right: 42,\n- },\n- nonViewerMargins: {\n- left: 24,\n- right: 24,\n- },\ntext: {\nfontSize: 18,\nfontFamily: 'Arial',\n@@ -416,6 +409,7 @@ export default connect(\nreturn {\nthreadInfo: threadInfoSelector(state)[threadID],\nmessageListData: messageListData(threadID)(state),\n+ textMessageMaxWidth: textMessageMaxWidthSelector(state),\n};\n},\n)(MessageListContainer);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Limit ComposedMessage width to 80% |
129,187 | 14.03.2019 20:58:07 | 14,400 | 8a33f4f81f15c97c2817d4aafb3f7e1b8accd254 | [native] Calculate height of MultimediaMessage | [
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message.react.js",
"new_path": "native/chat/multimedia-message.react.js",
"diff": "@@ -7,7 +7,7 @@ import { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport { messageTypes } from 'lib/types/message-types';\nimport type { Media } from 'lib/types/media-types';\nimport type { ImageStyle } from '../types/styles';\n-import type { Dimensions } from '../types/dimensions';\n+import type { AppState } from '../redux-setup';\nimport * as React from 'react';\nimport {\n@@ -22,22 +22,22 @@ import invariant from 'invariant';\nimport PropTypes from 'prop-types';\nimport { messageKey } from 'lib/shared/message-utils';\n-import { promiseAll } from 'lib/utils/promises';\n+import { connect } from 'lib/utils/redux-utils';\nimport ComposedMessage from './composed-message.react';\nimport { preloadImage } from '../utils/media-utils';\n+import { composedMessageMaxWidthSelector } from './composed-message-width';\n-const multimediaMessageLoadingContentHeight = 100; // TODO\n+const multimediaMessageLoadingContentHeight = 100;\nfunction multimediaMessageItemHeight(\nitem: ChatMessageInfoItemWithHeight,\nviewerID: ?string,\n) {\n- // TODO\nconst { messageInfo, contentHeight, startsCluster, endsCluster } = item;\nconst { id, creator } = messageInfo;\nconst { isViewer } = creator;\n- let height = 17 + contentHeight; // for padding, margin, and text\n+ let height = 5 + contentHeight; // for margin and image\nif (!isViewer && startsCluster) {\nheight += 25; // for username\n}\n@@ -50,7 +50,7 @@ function multimediaMessageItemHeight(\nitem.localMessageInfo &&\nitem.localMessageInfo.sendFailed\n) {\n- height += 22; // extra padding at the end of a cluster\n+ height += 22; // extra padding for sendFailed\n}\nreturn height;\n}\n@@ -59,9 +59,11 @@ type Props = {|\nitem: ChatMessageInfoItemWithHeight,\ntoggleFocus: (messageKey: string) => void,\nupdateHeightForMessage: (id: string, contentHeight: number) => void,\n+ // Redux state\n+ composedMessageMaxWidth: number,\n|};\ntype State = {|\n- dimensions: ?{[id: string]: Dimensions},\n+ preloaded: bool,\n|};\nclass MultimediaMessage extends React.PureComponent<Props, State> {\n@@ -69,9 +71,10 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\nitem: chatMessageItemPropType.isRequired,\ntoggleFocus: PropTypes.func.isRequired,\nupdateHeightForMessage: PropTypes.func.isRequired,\n+ composedMessageMaxWidth: PropTypes.number.isRequired,\n};\nstate = {\n- dimensions: null,\n+ preloaded: false,\n};\ncomponentDidMount() {\n@@ -109,8 +112,32 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\nfor (let media of messageInfo.media) {\npromises[media.id] = preloadImage(media.uri);\n}\n- const dimensions = await promiseAll(promises);\n- this.setState({ dimensions });\n+ const dimensions = await Promise.all(messageInfo.media.map(\n+ media => preloadImage(media.uri),\n+ ));\n+ this.setState({ preloaded: true });\n+\n+ const { composedMessageMaxWidth } = this.props;\n+ let contentHeight;\n+ if (messageInfo.media.length === 1) {\n+ const [ mediaDimensions ] = dimensions;\n+ if (composedMessageMaxWidth >= mediaDimensions.width) {\n+ contentHeight = mediaDimensions.height;\n+ } else {\n+ contentHeight = mediaDimensions.height *\n+ composedMessageMaxWidth / mediaDimensions.width;\n+ }\n+ } else if (messageInfo.media.length === 2) {\n+ contentHeight = composedMessageMaxWidth / 2;\n+ } else if (messageInfo.media.length === 3) {\n+ contentHeight = composedMessageMaxWidth / 3;\n+ } else if (messageInfo.media.length === 4) {\n+ contentHeight = composedMessageMaxWidth;\n+ } else {\n+ const numRows = Math.floor(messageInfo.media.length / 3);\n+ contentHeight = numRows * composedMessageMaxWidth / 3;\n+ }\n+ this.props.updateHeightForMessage(messageKey(messageInfo), contentHeight);\n}\nrender() {\n@@ -124,7 +151,7 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\nconst heightStyle = { height: contentHeight };\nlet content;\n- if (!this.state.dimensions) {\n+ if (!this.state.preloaded) {\ncontent = (\n<View style={[heightStyle, styles.container]}>\n<ActivityIndicator\n@@ -305,8 +332,14 @@ const styles = StyleSheet.create({\n},\n});\n+const WrappedMultimediaMessage = connect(\n+ (state: AppState) => ({\n+ composedMessageMaxWidth: composedMessageMaxWidthSelector(state),\n+ }),\n+)(MultimediaMessage);\n+\nexport {\nmultimediaMessageLoadingContentHeight,\n- MultimediaMessage,\n+ WrappedMultimediaMessage as MultimediaMessage,\nmultimediaMessageItemHeight,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/text-message.react.js",
"new_path": "native/chat/text-message.react.js",
"diff": "@@ -44,7 +44,7 @@ function textMessageItemHeight(\nitem.localMessageInfo &&\nitem.localMessageInfo.sendFailed\n) {\n- height += 22; // extra padding at the end of a cluster\n+ height += 22; // extra padding for sendFailed\n}\nreturn height;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Calculate height of MultimediaMessage |
129,187 | 14.03.2019 21:16:19 | 14,400 | 125fc76ed46b658122f3d47286cca16bd6ff97ac | [native] Fix layout bugs in MultimediaMessage | [
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message.react.js",
"new_path": "native/chat/multimedia-message.react.js",
"diff": "@@ -134,7 +134,7 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\n} else if (messageInfo.media.length === 4) {\ncontentHeight = composedMessageMaxWidth;\n} else {\n- const numRows = Math.floor(messageInfo.media.length / 3);\n+ const numRows = Math.ceil(messageInfo.media.length / 3);\ncontentHeight = numRows * composedMessageMaxWidth / 3;\n}\nthis.props.updateHeightForMessage(messageKey(messageInfo), contentHeight);\n@@ -217,7 +217,7 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\n} else if (messageInfo.media.length === 4) {\nconst [ one, two, three, four ] = messageInfo.media;\nreturn (\n- <React.Fragment>\n+ <View style={styles.grid}>\n<View style={styles.row}>\n{MultimediaMessage.renderImage(one, styles.topLeftImage)}\n{MultimediaMessage.renderImage(two, styles.topRightImage)}\n@@ -226,40 +226,40 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\n{MultimediaMessage.renderImage(three, styles.bottomLeftImage)}\n{MultimediaMessage.renderImage(four, styles.bottomRightImage)}\n</View>\n- </React.Fragment>\n+ </View>\n);\n} else {\nconst rows = [];\nfor (let i = 0; i < messageInfo.media.length; i += 3) {\n- const media = messageInfo.media.slice(i, i + 3);\n- const [ one, two, three ] = media;\n+ let rowStyle;\nif (i === 0) {\n- rows.push(\n- <View style={styles.row} key={i}>\n- {MultimediaMessage.renderImage(one, styles.topLeftImage)}\n- {MultimediaMessage.renderImage(two, styles.topCenterImage)}\n- {MultimediaMessage.renderImage(three, styles.topRightImage)}\n- </View>\n- );\n+ rowStyle = rowStyles.top;\n} else if (i + 3 >= messageInfo.media.length) {\n- rows.push(\n- <View style={styles.row} key={i}>\n- {MultimediaMessage.renderImage(one, styles.bottomLeftImage)}\n- {MultimediaMessage.renderImage(two, styles.bottomCenterImage)}\n- {MultimediaMessage.renderImage(three, styles.bottomRightImage)}\n- </View>\n- );\n+ rowStyle = rowStyles.bottom;\n} else {\n+ rowStyle = rowStyles.middle;\n+ }\n+\n+ const rowMedia = messageInfo.media.slice(i, i + 3);\n+ const row = [];\n+ let j = 0;\n+ for (; j < rowMedia.length; j++) {\n+ const media = rowMedia[j];\n+ const style = rowStyle[j];\n+ row.push(MultimediaMessage.renderImage(media, style));\n+ }\n+ for (; j < 3; j++) {\n+ const key = `filler${j}`;\n+ row.push(<View style={styles.image} key={key} />);\n+ }\n+\nrows.push(\n<View style={styles.row} key={i}>\n- {MultimediaMessage.renderImage(one, styles.leftImage)}\n- {MultimediaMessage.renderImage(two, styles.centerImage)}\n- {MultimediaMessage.renderImage(three, styles.rightImage)}\n+ {row}\n</View>\n);\n}\n- }\n- return rows;\n+ return <View style={styles.grid}>{rows}</View>;\n}\n}\n@@ -281,12 +281,16 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\n}\n+const spaceBetweenImages = 2;\nconst styles = StyleSheet.create({\ncontainer: {\nflex: 1,\nflexDirection: 'row',\njustifyContent: 'center',\n},\n+ grid: {\n+ flex: 1,\n+ },\nrow: {\nflex: 1,\nflexDirection: 'row',\n@@ -295,42 +299,59 @@ const styles = StyleSheet.create({\nflex: 1,\n},\nleftImage: {\n- marginRight: 3,\n+ marginRight: spaceBetweenImages,\n},\ncenterImage: {\n- marginLeft: 3,\n- marginRight: 3,\n+ marginLeft: spaceBetweenImages,\n+ marginRight: spaceBetweenImages,\n},\nrightImage: {\n- marginLeft: 3,\n+ marginLeft: spaceBetweenImages,\n},\ntopLeftImage: {\n- marginRight: 3,\n- marginBottom: 3,\n+ marginRight: spaceBetweenImages,\n+ marginBottom: spaceBetweenImages,\n},\ntopCenterImage: {\n- marginLeft: 3,\n- marginRight: 3,\n- marginBottom: 3,\n+ marginLeft: spaceBetweenImages,\n+ marginRight: spaceBetweenImages,\n+ marginBottom: spaceBetweenImages,\n},\ntopRightImage: {\n- marginLeft: 3,\n- marginBottom: 3,\n+ marginLeft: spaceBetweenImages,\n+ marginBottom: spaceBetweenImages,\n},\nbottomLeftImage: {\n- marginRight: 3,\n- marginTop: 3,\n+ marginRight: spaceBetweenImages,\n+ marginTop: spaceBetweenImages,\n},\nbottomCenterImage: {\n- marginLeft: 3,\n- marginRight: 3,\n- marginTop: 3,\n+ marginLeft: spaceBetweenImages,\n+ marginRight: spaceBetweenImages,\n+ marginTop: spaceBetweenImages,\n},\nbottomRightImage: {\n- marginLeft: 3,\n- marginTop: 3,\n+ marginLeft: spaceBetweenImages,\n+ marginTop: spaceBetweenImages,\n},\n});\n+const rowStyles = {\n+ top: [\n+ styles.topLeftImage,\n+ styles.topCenterImage,\n+ styles.topRightImage,\n+ ],\n+ bottom: [\n+ styles.bottomLeftImage,\n+ styles.bottomCenterImage,\n+ styles.bottomRightImage,\n+ ],\n+ middle: [\n+ styles.leftImage,\n+ styles.centerImage,\n+ styles.rightImage,\n+ ],\n+};\nconst WrappedMultimediaMessage = connect(\n(state: AppState) => ({\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Fix layout bugs in MultimediaMessage |
129,187 | 14.03.2019 21:52:44 | 14,400 | 96a11cff7713aeecfc3b490acd8d3d2260f84a10 | [native] Attempt to refetch unfetched MultimediaMessage images after reconnecting | [
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message.react.js",
"new_path": "native/chat/multimedia-message.react.js",
"diff": "@@ -8,6 +8,10 @@ import { messageTypes } from 'lib/types/message-types';\nimport type { Media } from 'lib/types/media-types';\nimport type { ImageStyle } from '../types/styles';\nimport type { AppState } from '../redux-setup';\n+import {\n+ type ConnectionStatus,\n+ connectionStatusPropType,\n+} from 'lib/types/socket-types';\nimport * as React from 'react';\nimport {\n@@ -61,6 +65,7 @@ type Props = {|\nupdateHeightForMessage: (id: string, contentHeight: number) => void,\n// Redux state\ncomposedMessageMaxWidth: number,\n+ connectionStatus: ConnectionStatus,\n|};\ntype State = {|\npreloaded: bool,\n@@ -72,6 +77,7 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\ntoggleFocus: PropTypes.func.isRequired,\nupdateHeightForMessage: PropTypes.func.isRequired,\ncomposedMessageMaxWidth: PropTypes.number.isRequired,\n+ connectionStatus: connectionStatusPropType.isRequired,\n};\nstate = {\npreloaded: false,\n@@ -99,6 +105,14 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\nreturn;\n}\n}\n+\n+ if (\n+ !this.state.preloaded &&\n+ this.props.connectionStatus === \"connected\" &&\n+ prevProps.connectionStatus !== \"connected\"\n+ ) {\n+ this.calculateDimensions();\n+ }\n}\nasync calculateDimensions() {\n@@ -112,9 +126,14 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\nfor (let media of messageInfo.media) {\npromises[media.id] = preloadImage(media.uri);\n}\n- const dimensions = await Promise.all(messageInfo.media.map(\n+ let dimensions;\n+ try {\n+ dimensions = await Promise.all(messageInfo.media.map(\nmedia => preloadImage(media.uri),\n));\n+ } catch (e) {\n+ return;\n+ }\nthis.setState({ preloaded: true });\nconst { composedMessageMaxWidth } = this.props;\n@@ -356,6 +375,7 @@ const rowStyles = {\nconst WrappedMultimediaMessage = connect(\n(state: AppState) => ({\ncomposedMessageMaxWidth: composedMessageMaxWidthSelector(state),\n+ connectionStatus: state.connection.status,\n}),\n)(MultimediaMessage);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Attempt to refetch unfetched MultimediaMessage images after reconnecting |
129,187 | 15.03.2019 11:13:43 | 14,400 | c355d9b0ab95f06171eedfd4518bb97a3e5a6834 | [server] Add Cache-Control header to uploadDownloadResponder | [
{
"change_type": "MODIFY",
"old_path": "server/src/uploads/uploads.js",
"new_path": "server/src/uploads/uploads.js",
"diff": "@@ -65,7 +65,8 @@ async function uploadDownloadResponder(\nthrow new ServerError('invalid_parameters');\n}\nconst { content, mime } = await fetchUpload(viewer, uploadID, secret);\n- res.set(\"Content-Type\", mime);\n+ res.type(mime);\n+ res.set('Cache-Control', 'public, max-age=31557600, immutable');\nres.send(content);\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Add Cache-Control header to uploadDownloadResponder |
129,187 | 15.03.2019 11:33:09 | 14,400 | 8d7ac42c1707811ca3bd3205288628076f43f4b4 | [server] Use util.promisify instead of denodeify | [
{
"change_type": "DELETE",
"old_path": "server/flow-typed/npm/denodeify_vx.x.x.js",
"new_path": null,
"diff": "-// flow-typed signature: 70f753186153eda65067c154004c031d\n-// flow-typed version: <<STUB>>/denodeify_v^1.2.1/flow_v0.89.0\n-\n-/**\n- * This is an autogenerated libdef stub for:\n- *\n- * 'denodeify'\n- *\n- * Fill this stub out by replacing all the `any` types.\n- *\n- * Once filled out, we encourage you to share your work with the\n- * community by sending a pull request to:\n- * https://github.com/flowtype/flow-typed\n- */\n-\n-declare module 'denodeify' {\n- declare module.exports: any;\n-}\n-\n-/**\n- * We include stubs for each file inside this npm package in case you need to\n- * require those files directly. Feel free to delete any files that aren't\n- * needed.\n- */\n-declare module 'denodeify/test/es6-promise-test' {\n- declare module.exports: any;\n-}\n-\n-declare module 'denodeify/test/es6-shim-test' {\n- declare module.exports: any;\n-}\n-\n-declare module 'denodeify/test/helpers' {\n- declare module.exports: any;\n-}\n-\n-declare module 'denodeify/test/lie-test' {\n- declare module.exports: any;\n-}\n-\n-declare module 'denodeify/test/native-promise-only-test' {\n- declare module.exports: any;\n-}\n-\n-// Filename aliases\n-declare module 'denodeify/index' {\n- declare module.exports: $Exports<'denodeify'>;\n-}\n-declare module 'denodeify/index.js' {\n- declare module.exports: $Exports<'denodeify'>;\n-}\n-declare module 'denodeify/test/es6-promise-test.js' {\n- declare module.exports: $Exports<'denodeify/test/es6-promise-test'>;\n-}\n-declare module 'denodeify/test/es6-shim-test.js' {\n- declare module.exports: $Exports<'denodeify/test/es6-shim-test'>;\n-}\n-declare module 'denodeify/test/helpers.js' {\n- declare module.exports: $Exports<'denodeify/test/helpers'>;\n-}\n-declare module 'denodeify/test/lie-test.js' {\n- declare module.exports: $Exports<'denodeify/test/lie-test'>;\n-}\n-declare module 'denodeify/test/native-promise-only-test.js' {\n- declare module.exports: $Exports<'denodeify/test/native-promise-only-test'>;\n-}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/loader.mjs",
"new_path": "server/loader.mjs",
"diff": "import url from 'url';\nimport Module from 'module';\nimport fs from 'fs';\n-import Promise from 'promise';\n+import { promisify } from 'util';\nconst builtins = Module.builtinModules;\nconst extensions = { js: 'esm', json: \"json\" };\n-const access = Promise.denodeify(fs.access);\n-const readFile = Promise.denodeify(fs.readFile);\n+const access = promisify(fs.access);\n+const readFile = promisify(fs.readFile);\nconst baseURL = new url.URL('file://');\nexport async function resolve(\n"
},
{
"change_type": "MODIFY",
"old_path": "server/package.json",
"new_path": "server/package.json",
"diff": "\"common-tags\": \"^1.7.2\",\n\"cookie-parser\": \"^1.4.3\",\n\"dateformat\": \"^3.0.3\",\n- \"denodeify\": \"^1.2.1\",\n\"express\": \"^4.16.2\",\n\"express-ws\": \"^4.0.0\",\n\"firebase-admin\": \"^6.5.1\",\n\"mysql2\": \"^1.5.1\",\n\"node-schedule\": \"^1.3.0\",\n\"nodemailer\": \"^4.4.2\",\n- \"promise\": \"^8.0.1\",\n\"react\": \"^16.2.0\",\n\"react-dom\": \"^16.2.0\",\n\"react-hot-loader\": \"^3.1.3\",\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/backups.js",
"new_path": "server/src/backups.js",
"diff": "@@ -4,15 +4,15 @@ import fs from 'fs';\nimport childProcess from 'child_process';\nimport zlib from 'zlib';\nimport dateFormat from 'dateformat';\n-import denodeify from 'denodeify';\nimport StreamCache from 'stream-cache';\n+import { promisify } from 'util';\nimport dbConfig from '../secrets/db_config';\nimport backupConfig from '../facts/backups';\n-const readdir = denodeify(fs.readdir);\n-const lstat = denodeify(fs.lstat);\n-const unlink = denodeify(fs.unlink);\n+const readdir = promisify(fs.readdir);\n+const lstat = promisify(fs.lstat);\n+const unlink = promisify(fs.unlink);\nasync function backupDB() {\nif (!backupConfig || !backupConfig.enabled) {\n"
},
{
"change_type": "MODIFY",
"old_path": "yarn.lock",
"new_path": "yarn.lock",
"diff": "@@ -1983,7 +1983,7 @@ art@^0.10.0:\nresolved \"https://registry.yarnpkg.com/art/-/art-0.10.3.tgz#b01d84a968ccce6208df55a733838c96caeeaea2\"\nintegrity sha512-HXwbdofRTiJT6qZX/FnchtldzJjS3vkLJxQilc3Xj+ma2MXjY4UAyQ0ls1XZYVnDvVIBiFZbC6QsvtW86TD6tQ==\n-asap@^2.0.6, asap@~2.0.3, asap@~2.0.6:\n+asap@^2.0.6, asap@~2.0.3:\nversion \"2.0.6\"\nresolved \"https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46\"\nintegrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=\n@@ -9596,13 +9596,6 @@ promise@^7.1.1:\ndependencies:\nasap \"~2.0.3\"\n-promise@^8.0.1:\n- version \"8.0.2\"\n- resolved \"https://registry.yarnpkg.com/promise/-/promise-8.0.2.tgz#9dcd0672192c589477d56891271bdc27547ae9f0\"\n- integrity sha512-EIyzM39FpVOMbqgzEHhxdrEhtOSDOtjMZQ0M6iVfCE+kWNgCkAyOdnuCWqfmflylftfadU6FkiMgHZA2kUzwRw==\n- dependencies:\n- asap \"~2.0.6\"\n-\nprompts@^2.0.1:\nversion \"2.0.1\"\nresolved \"https://registry.yarnpkg.com/prompts/-/prompts-2.0.1.tgz#201b3718b4276fb407f037db48c0029d6465245c\"\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Use util.promisify instead of denodeify |
129,187 | 15.03.2019 12:02:26 | 14,400 | 77aecd8c79a7d308fd7eeadf79fb7326df19304e | [server] Migration to add image size to uploads table | [
{
"change_type": "MODIFY",
"old_path": "server/package.json",
"new_path": "server/package.json",
"diff": "},\n\"dependencies\": {\n\"apn\": \"^2.2.0\",\n+ \"buffer-image-size\": \"^0.6.4\",\n\"common-tags\": \"^1.7.2\",\n\"cookie-parser\": \"^1.4.3\",\n\"dateformat\": \"^3.0.3\",\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/src/scripts/image-size.js",
"diff": "+// @flow\n+\n+import sizeOf from 'buffer-image-size';\n+\n+import { pool, dbQuery, SQL } from '../database';\n+\n+async function main() {\n+ try {\n+ await addImageSizeToUploadsTable();\n+ pool.end();\n+ } catch (e) {\n+ pool.end();\n+ console.warn(e);\n+ }\n+}\n+\n+async function addImageSizeToUploadsTable() {\n+ await dbQuery(SQL`ALTER TABLE uploads ADD extra JSON NULL AFTER secret;`);\n+ const [ result ] = await dbQuery(SQL`\n+ SELECT id, content\n+ FROM uploads\n+ WHERE type = \"photo\" AND extra IS NULL\n+ `);\n+ for (let row of result) {\n+ const { height, width } = sizeOf(row.content);\n+ const dimensions = JSON.stringify({ height, width });\n+ await dbQuery(SQL`\n+ UPDATE uploads\n+ SET extra = ${dimensions}\n+ WHERE id = ${row.id}\n+ `);\n+ }\n+}\n+\n+main();\n"
},
{
"change_type": "MODIFY",
"old_path": "yarn.lock",
"new_path": "yarn.lock",
"diff": "@@ -2541,6 +2541,13 @@ buffer-from@^1.0.0:\nresolved \"https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef\"\nintegrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==\n+buffer-image-size@^0.6.4:\n+ version \"0.6.4\"\n+ resolved \"https://registry.yarnpkg.com/buffer-image-size/-/buffer-image-size-0.6.4.tgz#357e8173e951ced3b5a2785c695993aa29dbcac4\"\n+ integrity sha512-nEh+kZOPY1w+gcCMobZ6ETUp9WfibndnosbpwB1iJk/8Gt5ZF2bhS6+B6bPYz424KtwsR6Rflc3tCz1/ghX2dQ==\n+ dependencies:\n+ \"@types/node\" \"*\"\n+\nbuffer-indexof-polyfill@~1.0.0:\nversion \"1.0.1\"\nresolved \"https://registry.yarnpkg.com/buffer-indexof-polyfill/-/buffer-indexof-polyfill-1.0.1.tgz#a9fb806ce8145d5428510ce72f278bb363a638bf\"\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Migration to add image size to uploads table |
129,187 | 15.03.2019 12:06:57 | 14,400 | d3e744f03cdd99200163966ec864fc7a1df22320 | [server] Specify dimensions when uploading new photos | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "server/flow-typed/npm/buffer-image-size_vx.x.x.js",
"diff": "+// flow-typed signature: 3e61568f51105d10e2ba32525c104d45\n+// flow-typed version: <<STUB>>/buffer-image-size_v0.6.4/flow_v0.89.0\n+\n+/**\n+ * This is an autogenerated libdef stub for:\n+ *\n+ * 'buffer-image-size'\n+ *\n+ * Fill this stub out by replacing all the `any` types.\n+ *\n+ * Once filled out, we encourage you to share your work with the\n+ * community by sending a pull request to:\n+ * https://github.com/flowtype/flow-typed\n+ */\n+\n+declare module 'buffer-image-size' {\n+ declare module.exports: any;\n+}\n+\n+/**\n+ * We include stubs for each file inside this npm package in case you need to\n+ * require those files directly. Feel free to delete any files that aren't\n+ * needed.\n+ */\n+declare module 'buffer-image-size/lib/detector' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'buffer-image-size/lib/index' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'buffer-image-size/lib/readUInt' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'buffer-image-size/lib/types' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'buffer-image-size/lib/types/bmp' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'buffer-image-size/lib/types/cur' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'buffer-image-size/lib/types/dds' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'buffer-image-size/lib/types/gif' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'buffer-image-size/lib/types/ico' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'buffer-image-size/lib/types/jpg' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'buffer-image-size/lib/types/png' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'buffer-image-size/lib/types/psd' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'buffer-image-size/lib/types/svg' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'buffer-image-size/lib/types/webp' {\n+ declare module.exports: any;\n+}\n+\n+// Filename aliases\n+declare module 'buffer-image-size/lib/detector.js' {\n+ declare module.exports: $Exports<'buffer-image-size/lib/detector'>;\n+}\n+declare module 'buffer-image-size/lib/index.js' {\n+ declare module.exports: $Exports<'buffer-image-size/lib/index'>;\n+}\n+declare module 'buffer-image-size/lib/readUInt.js' {\n+ declare module.exports: $Exports<'buffer-image-size/lib/readUInt'>;\n+}\n+declare module 'buffer-image-size/lib/types.js' {\n+ declare module.exports: $Exports<'buffer-image-size/lib/types'>;\n+}\n+declare module 'buffer-image-size/lib/types/bmp.js' {\n+ declare module.exports: $Exports<'buffer-image-size/lib/types/bmp'>;\n+}\n+declare module 'buffer-image-size/lib/types/cur.js' {\n+ declare module.exports: $Exports<'buffer-image-size/lib/types/cur'>;\n+}\n+declare module 'buffer-image-size/lib/types/dds.js' {\n+ declare module.exports: $Exports<'buffer-image-size/lib/types/dds'>;\n+}\n+declare module 'buffer-image-size/lib/types/gif.js' {\n+ declare module.exports: $Exports<'buffer-image-size/lib/types/gif'>;\n+}\n+declare module 'buffer-image-size/lib/types/ico.js' {\n+ declare module.exports: $Exports<'buffer-image-size/lib/types/ico'>;\n+}\n+declare module 'buffer-image-size/lib/types/jpg.js' {\n+ declare module.exports: $Exports<'buffer-image-size/lib/types/jpg'>;\n+}\n+declare module 'buffer-image-size/lib/types/png.js' {\n+ declare module.exports: $Exports<'buffer-image-size/lib/types/png'>;\n+}\n+declare module 'buffer-image-size/lib/types/psd.js' {\n+ declare module.exports: $Exports<'buffer-image-size/lib/types/psd'>;\n+}\n+declare module 'buffer-image-size/lib/types/svg.js' {\n+ declare module.exports: $Exports<'buffer-image-size/lib/types/svg'>;\n+}\n+declare module 'buffer-image-size/lib/types/webp.js' {\n+ declare module.exports: $Exports<'buffer-image-size/lib/types/webp'>;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/creators/upload-creator.js",
"new_path": "server/src/creators/upload-creator.js",
"diff": "@@ -4,6 +4,7 @@ import type { MediaType, UploadMultimediaResult } from 'lib/types/media-types';\nimport type { Viewer } from '../session/viewer';\nimport crypto from 'crypto';\n+import sizeOf from 'buffer-image-size';\nimport { ServerError } from 'lib/utils/errors';\n@@ -11,6 +12,14 @@ import { dbQuery, SQL } from '../database';\nimport createIDs from './id-creator';\nimport { getUploadURL } from '../fetchers/upload-fetchers';\n+function uploadExtras(upload: UploadInput) {\n+ if (upload.mediaType !== \"photo\") {\n+ return null;\n+ }\n+ const { height, width } = sizeOf(upload.buffer);\n+ return JSON.stringify({ height, width });\n+}\n+\ntype UploadInput = {|\nname: string,\nmime: string,\n@@ -35,10 +44,12 @@ async function createUploads(\nuploadInfo.mime,\nuploadInfo.buffer,\nsecret,\n+ uploadExtras(uploadInfo),\n]);\nconst insertQuery = SQL`\n- INSERT INTO uploads(id, uploader, type, filename, mime, content, secret)\n+ INSERT INTO uploads(id, uploader, type,\n+ filename, mime, content, secret, extra)\nVALUES ${uploadRows}\n`;\nawait dbQuery(insertQuery);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Specify dimensions when uploading new photos |
129,187 | 15.03.2019 15:46:28 | 14,400 | 0175b78e118f1848ce17449ce4bb87f481bc3085 | Move Dimensions type to lib | [
{
"change_type": "MODIFY",
"old_path": "lib/types/media-types.js",
"new_path": "lib/types/media-types.js",
"diff": "import PropTypes from 'prop-types';\n+export type Dimensions = {|\n+ height: number,\n+ width: number,\n+|};\n+\n+export const dimensionsPropType = PropTypes.shape({\n+ height: PropTypes.number.isRequired,\n+ width: PropTypes.number.isRequired,\n+});\n+\nexport type MediaType = \"photo\" | \"video\";\nexport type Media = {|\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel-container.react.js",
"new_path": "native/account/log-in-panel-container.react.js",
"diff": "@@ -7,7 +7,7 @@ import {\n} from '../utils/state-container';\nimport type { LogInState } from './log-in-panel.react';\nimport type { AppState } from '../redux-setup';\n-import { type Dimensions, dimensionsPropType } from '../types/dimensions';\n+import { type Dimensions, dimensionsPropType } from 'lib/types/media-types';\nimport * as React from 'react';\nimport {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -12,7 +12,7 @@ import type { KeyboardEvent, EmitterSubscription } from '../keyboard';\nimport type { LogInState } from './log-in-panel.react';\nimport type { RegisterState } from './register-panel.react';\nimport type { LogInExtraInfo } from 'lib/types/account-types';\n-import { type Dimensions, dimensionsPropType } from '../types/dimensions';\n+import { type Dimensions, dimensionsPropType } from 'lib/types/media-types';\nimport type { ImageStyle } from '../types/styles';\nimport * as React from 'react';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/modal-components.react.js",
"new_path": "native/account/modal-components.react.js",
"diff": "// @flow\n-import type { Dimensions } from '../types/dimensions';\n+import type { Dimensions } from 'lib/types/media-types';\nimport * as React from 'react';\nimport {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/panel-components.react.js",
"new_path": "native/account/panel-components.react.js",
"diff": "@@ -4,7 +4,7 @@ import type { LoadingStatus } from 'lib/types/loading-types';\nimport { loadingStatusPropType } from 'lib/types/loading-types';\nimport type { ViewStyle } from '../types/styles';\nimport type { KeyboardEvent, EmitterSubscription } from '../keyboard';\n-import { type Dimensions, dimensionsPropType } from '../types/dimensions';\n+import { type Dimensions, dimensionsPropType } from 'lib/types/media-types';\nimport type { AppState } from '../redux-setup';\nimport * as React from 'react';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/verification-modal.react.js",
"new_path": "native/account/verification-modal.react.js",
"diff": "@@ -15,7 +15,7 @@ import {\ntype HandleVerificationCodeResult,\n} from 'lib/types/verify-types';\nimport type { KeyboardEvent } from '../keyboard';\n-import { type Dimensions, dimensionsPropType } from '../types/dimensions';\n+import { type Dimensions, dimensionsPropType } from 'lib/types/media-types';\nimport type { ImageStyle } from '../types/styles';\nimport * as React from 'react';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -22,7 +22,7 @@ import {\ntype CalendarFilter,\ncalendarFilterPropType,\n} from 'lib/types/filter-types';\n-import { type Dimensions, dimensionsPropType } from '../types/dimensions';\n+import { type Dimensions, dimensionsPropType } from 'lib/types/media-types';\nimport React from 'react';\nimport {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/composed-message-width.js",
"new_path": "native/chat/composed-message-width.js",
"diff": "// @flow\n-import type { Dimensions } from '../types/dimensions';\n+import type { Dimensions } from 'lib/types/media-types';\nimport { createSelector } from 'reselect';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/tag-input.react.js",
"new_path": "native/components/tag-input.react.js",
"diff": "// @flow\nimport type { ViewStyle, TextStyle } from '../types/styles';\n-import { type Dimensions, dimensionsPropType } from '../types/dimensions';\n+import { type Dimensions, dimensionsPropType } from 'lib/types/media-types';\nimport type { AppState } from '../redux-setup';\nimport * as React from 'react';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/tooltip.react.js",
"new_path": "native/components/tooltip.react.js",
"diff": "// @flow\nimport type { ViewStyle, TextStyle } from '../types/styles';\n-import { type Dimensions, dimensionsPropType } from '../types/dimensions';\n+import { type Dimensions, dimensionsPropType } from 'lib/types/media-types';\nimport type { AppState } from '../redux-setup';\nimport * as React from 'react';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/dimensions-updater.react.js",
"new_path": "native/dimensions-updater.react.js",
"diff": "// @flow\n-import type { Dimensions } from './types/dimensions';\n+import type { Dimensions } from 'lib/types/media-types';\nimport type { DispatchActionPayload } from 'lib/utils/action-utils';\nimport * as React from 'react';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux-setup.js",
"new_path": "native/redux-setup.js",
"diff": "@@ -24,7 +24,7 @@ import {\ndefaultConnectionInfo,\nincrementalStateSyncActionType,\n} from 'lib/types/socket-types';\n-import type { Dimensions } from './types/dimensions';\n+import type { Dimensions } from 'lib/types/media-types';\nimport React from 'react';\nimport invariant from 'invariant';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/dimension-selectors.js",
"new_path": "native/selectors/dimension-selectors.js",
"diff": "// @flow\nimport type { AppState } from '../redux-setup';\n-import type { Dimensions } from '../types/dimensions';\n+import type { Dimensions } from 'lib/types/media-types';\nimport { Platform, DeviceInfo } from 'react-native';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/splash.js",
"new_path": "native/splash.js",
"diff": "// @flow\nimport type { ImageStyle } from './types/styles';\n-import type { Dimensions } from './types/dimensions';\n+import type { Dimensions } from 'lib/types/media-types';\nimport { Platform, PixelRatio } from 'react-native';\nimport { createSelector } from 'reselect';\n"
},
{
"change_type": "DELETE",
"old_path": "native/types/dimensions.js",
"new_path": null,
"diff": "-// @flow\n-\n-import PropTypes from 'prop-types';\n-\n-export type Dimensions = {|\n- height: number,\n- width: number,\n-|};\n-\n-export const dimensionsPropType = PropTypes.shape({\n- height: PropTypes.number.isRequired,\n- width: PropTypes.number.isRequired,\n-});\n"
},
{
"change_type": "MODIFY",
"old_path": "native/utils/media-utils.js",
"new_path": "native/utils/media-utils.js",
"diff": "// @flow\n-import type { Dimensions } from '../types/dimensions';\n+import type { Dimensions } from 'lib/types/media-types';\nimport { Image } from 'react-native';\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Move Dimensions type to lib |
129,187 | 15.03.2019 16:37:12 | 14,400 | 792089f7169a46001207726cb951895e18c1c894 | Include Dimensions in Media | [
{
"change_type": "MODIFY",
"old_path": "lib/types/media-types.js",
"new_path": "lib/types/media-types.js",
"diff": "@@ -18,6 +18,7 @@ export type Media = {|\nid: string,\nuri: string,\ntype: MediaType,\n+ dimensions: Dimensions,\n|};\nexport const mediaTypePropType = PropTypes.oneOf([ \"photo\", \"video\" ]);\n@@ -26,6 +27,7 @@ export const mediaPropType = PropTypes.shape({\nid: PropTypes.string.isRequired,\nuri: PropTypes.string.isRequired,\ntype: mediaTypePropType.isRequired,\n+ dimensions: dimensionsPropType.isRequired,\n});\nexport type UploadMultimediaResult = {|\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/fetchers/message-fetchers.js",
"new_path": "server/src/fetchers/message-fetchers.js",
"diff": "@@ -97,7 +97,8 @@ async function fetchCollapsableNotifs(\nSELECT m.id, m.thread AS threadID, m.content, m.time, m.type,\nu.username AS creator, m.user AS creatorID,\nstm.permissions AS subthread_permissions, n.user, n.collapse_key,\n- up.id AS uploadID, up.type AS uploadType, up.secret AS uploadSecret\n+ up.id AS uploadID, up.type AS uploadType, up.secret AS uploadSecret,\n+ up.extra AS uploadExtra\nFROM notifications n\nLEFT JOIN messages m ON m.id = n.message\nLEFT JOIN uploads up\n@@ -375,6 +376,7 @@ function rawMessageInfoFromRows(\nid: uploadID,\nuri: getUploadURL(uploadID, row.uploadSecret),\ntype: row.uploadType,\n+ dimensions: row.uploadExtra,\n});\n}\nconst [ row ] = rows;\n@@ -406,14 +408,15 @@ async function fetchMessageInfos(\nSELECT * FROM (\nSELECT x.id, x.content, x.time, x.type, x.user AS creatorID,\nx.creation, u.username AS creator, x.subthread_permissions,\n- x.uploadID, x.uploadType, x.uploadSecret,\n+ x.uploadID, x.uploadType, x.uploadSecret, x.uploadExtra,\n@num := if(@thread = x.thread, @num + 1, 1) AS number,\n@thread := x.thread AS threadID\nFROM (SELECT @num := 0, @thread := '') init\nJOIN (\nSELECT m.id, m.thread, m.user, m.content, m.time, m.type,\nm.creation, stm.permissions AS subthread_permissions,\n- up.id AS uploadID, up.type AS uploadType, up.secret AS uploadSecret\n+ up.id AS uploadID, up.type AS uploadType, up.secret AS uploadSecret,\n+ up.extra AS uploadExtra\nFROM messages m\nLEFT JOIN uploads up ON m.type = ${messageTypes.MULTIMEDIA}\nAND JSON_CONTAINS(m.content, CAST(up.id as JSON), '$')\n@@ -574,7 +577,8 @@ async function fetchMessageInfosSince(\nSELECT m.id, m.thread AS threadID, m.content, m.time, m.type,\nm.creation, u.username AS creator, m.user AS creatorID,\nstm.permissions AS subthread_permissions,\n- up.id AS uploadID, up.type AS uploadType, up.secret AS uploadSecret\n+ up.id AS uploadID, up.type AS uploadType, up.secret AS uploadSecret,\n+ up.extra AS uploadExtra\nFROM messages m\nLEFT JOIN uploads up ON m.type = ${messageTypes.MULTIMEDIA}\nAND JSON_CONTAINS(m.content, CAST(up.id as JSON), '$')\n@@ -672,7 +676,8 @@ async function fetchMessageInfoForLocalID(\nconst query = SQL`\nSELECT m.id, m.thread AS threadID, m.content, m.time, m.type, m.creation,\nm.user AS creatorID, stm.permissions AS subthread_permissions,\n- up.id AS uploadID, up.type AS uploadType, up.secret AS uploadSecret\n+ up.id AS uploadID, up.type AS uploadType, up.secret AS uploadSecret,\n+ up.extra AS uploadExtra\nFROM messages m\nLEFT JOIN uploads up ON m.type = ${messageTypes.MULTIMEDIA}\nAND JSON_CONTAINS(m.content, CAST(up.id as JSON), '$')\n@@ -701,7 +706,7 @@ async function fetchMessageInfoForEntryAction(\nconst query = SQL`\nSELECT m.id, m.thread AS threadID, m.content, m.time, m.type, m.creation,\nm.user AS creatorID, up.id AS uploadID, up.type AS uploadType,\n- up.secret AS uploadSecret\n+ up.secret AS uploadSecret, up.extra AS uploadExtra\nFROM messages m\nLEFT JOIN uploads up ON m.type = ${messageTypes.MULTIMEDIA}\nAND JSON_CONTAINS(m.content, CAST(up.id as JSON), '$')\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-input-bar.react.js",
"new_path": "web/chat/chat-input-bar.react.js",
"diff": "@@ -365,11 +365,14 @@ class ChatInputBar extends React.PureComponent<Props> {\nthreadID: this.props.threadInfo.id,\ncreatorID,\ntime: Date.now(),\n- media: pendingUploads.map(({ localID, serverID, uri, mediaType }) => ({\n+ media: pendingUploads.map(\n+ ({ localID, serverID, uri, mediaType, dimensions }) => ({\nid: serverID ? serverID : localID,\nuri,\ntype: mediaType,\n- })),\n+ dimensions,\n+ }),\n+ ),\n}: RawMultimediaMessageInfo);\n// This call triggers a setState in ChatInputStateContainer. We hope that\n// propagates quicker than the createLocalMultimediaMessageActionType call\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-input-state-container.react.js",
"new_path": "web/chat/chat-input-state-container.react.js",
"diff": "@@ -106,25 +106,35 @@ class ChatInputStateContainer extends React.PureComponent<Props, State> {\n));\nasync appendFiles(threadID: string, files: $ReadOnlyArray<File>) {\n- const validationResult = await Promise.all(files.map(validateFile));\n- const validatedFileInfo = validationResult.filter(Boolean);\n- if (validatedFileInfo.length === 0) {\n- const { setModal } = this.props;\n- setModal(<InvalidUploadModal setModal={setModal} />);\n- return;\n+ const validationResults = await Promise.all(files.map(validateFile));\n+ const newUploads = [];\n+ for (let result of validationResults) {\n+ if (!result) {\n+ continue;\n}\n- const newUploads = validatedFileInfo.map(({ file, mediaType }) => ({\n+ const { file, mediaType, dimensions } = result;\n+ if (!dimensions) {\n+ continue;\n+ }\n+ newUploads.push({\nlocalID: `localUpload${nextLocalUploadID++}`,\nserverID: null,\nmessageID: null,\nfailed: null,\nfile,\nmediaType,\n+ dimensions,\nuri: URL.createObjectURL(file),\nuriIsReal: false,\nprogressPercent: 0,\nabort: null,\n- }));\n+ });\n+ }\n+ if (newUploads.length === 0) {\n+ const { setModal } = this.props;\n+ setModal(<InvalidUploadModal setModal={setModal} />);\n+ return;\n+ }\nconst newUploadsObject = _keyBy('localID')(newUploads);\nthis.setState(\nprevState => {\n"
},
{
"change_type": "MODIFY",
"old_path": "web/chat/chat-input-state.js",
"new_path": "web/chat/chat-input-state.js",
"diff": "// @flow\n-import { type MediaType, mediaTypePropType } from 'lib/types/media-types';\n+import {\n+ type MediaType,\n+ mediaTypePropType,\n+ type Dimensions,\n+ dimensionsPropType,\n+} from 'lib/types/media-types';\nimport PropTypes from 'prop-types';\n@@ -16,6 +21,7 @@ export type PendingMultimediaUpload = {|\nfailed: ?string,\nfile: File,\nmediaType: MediaType,\n+ dimensions: Dimensions,\nuri: string,\n// URLs created with createObjectURL aren't considered \"real\". The distinction\n// is required because those \"fake\" URLs must be disposed properly\n@@ -32,6 +38,7 @@ export const pendingMultimediaUploadPropType = PropTypes.shape({\nfailed: PropTypes.string,\nfile: PropTypes.object.isRequired,\nmediaType: mediaTypePropType.isRequired,\n+ dimensions: dimensionsPropType.isRequired,\nuri: PropTypes.string.isRequired,\nuriIsReal: PropTypes.bool.isRequired,\nprogressPercent: PropTypes.number.isRequired,\n"
},
{
"change_type": "MODIFY",
"old_path": "web/utils/media-utils.js",
"new_path": "web/utils/media-utils.js",
"diff": "// @flow\n-import type { MediaType } from 'lib/types/media-types';\n+import type { MediaType, Dimensions } from 'lib/types/media-types';\nimport {\nfileInfoFromData,\n@@ -14,17 +14,32 @@ function blobToArrayBuffer(blob: Blob): Promise<ArrayBuffer> {\nfileReader.abort();\nreject(error);\n};\n- fileReader.onload = (event) => {\n+ fileReader.onload = event => {\nresolve(event.target.result);\n};\nfileReader.readAsArrayBuffer(blob);\n});\n}\n+function getPhotoDimensions(blob: File): Promise<Dimensions> {\n+ const fileReader = new FileReader();\n+ return new Promise((resolve, reject) => {\n+ fileReader.onerror = error => {\n+ fileReader.abort();\n+ reject(error);\n+ };\n+ fileReader.onload = event => {\n+ resolve(event.target.result);\n+ };\n+ fileReader.readAsDataURL(blob);\n+ }).then(uri => preloadImage(uri));\n+}\n+\n// Returns null if unsupported\ntype FileValidationResult = {|\nfile: File,\nmediaType: MediaType,\n+ dimensions: ?Dimensions,\n|};\nasync function validateFile(file: File): Promise<?FileValidationResult> {\nconst arrayBuffer = await blobToArrayBuffer(file);\n@@ -37,19 +52,27 @@ async function validateFile(file: File): Promise<?FileValidationResult> {\nif (!mediaType) {\nreturn null;\n}\n+ let dimensions = null;\n+ if (mediaType === \"photo\") {\n+ dimensions = await getPhotoDimensions(file);\n+ }\nconst fixedFile = name !== file.name || mime !== file.type\n? new File([ file ], name, { type: mime })\n: file;\n- return { file: fixedFile, mediaType };\n+ return { file: fixedFile, mediaType, dimensions };\n}\nconst allowedMimeTypeString = Object.keys(mimeTypesToMediaTypes).join(',');\n-function preloadImage(uri: string): Promise<void> {\n- return new Promise(resolve => {\n+function preloadImage(uri: string): Promise<Dimensions> {\n+ return new Promise((resolve, reject) => {\nconst img = new Image();\nimg.src = uri;\n- img.onload = resolve;\n+ img.onload = () => {\n+ const { width, height } = img;\n+ resolve({ width, height });\n+ };\n+ img.onerror = reject;\n});\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Include Dimensions in Media |
129,187 | 15.03.2019 17:06:13 | 14,400 | d284de97dcfbd23ea45a40b7ac5aa109a2a7d88a | [lib] Hack to hardcode dimensions of first four photo uploads
This is ugly but it's easy and it works and I can remove it later. | [
{
"change_type": "MODIFY",
"old_path": "lib/shared/unshim-utils.js",
"new_path": "lib/shared/unshim-utils.js",
"diff": "@@ -8,6 +8,16 @@ import {\n} from '../types/message-types';\nimport _mapValues from 'lodash/fp/mapValues';\n+import invariant from 'invariant';\n+\n+// Four photos were uploaded before dimensions were calculated server-side,\n+// and delivered to clients without dimensions in the MultimediaMessageInfo.\n+const preDimensionUploads = {\n+ \"156642\": { width: 1440, height: 1080 },\n+ \"156649\": { width: 720, height: 803 },\n+ \"156794\": { width: 720, height: 803 },\n+ \"156877\": { width: 574, height: 454 },\n+};\nfunction unshimFunc(\nmessageInfo: RawMessageInfo,\n@@ -19,7 +29,25 @@ function unshimFunc(\nif (!unshimTypes.has(messageInfo.unsupportedMessageInfo.type)) {\nreturn messageInfo;\n}\n- return messageInfo.unsupportedMessageInfo;\n+ const unwrapped = messageInfo.unsupportedMessageInfo;\n+ if (unwrapped.type === messageTypes.MULTIMEDIA) {\n+ return {\n+ ...unwrapped,\n+ media: unwrapped.media.map(media => {\n+ if (media.dimensions) {\n+ return media;\n+ }\n+ const dimensions = preDimensionUploads[media.id];\n+ invariant(\n+ dimensions,\n+ \"only four photos were uploaded before dimensions were calculated, \" +\n+ `and ${media.id} was not one of them`,\n+ );\n+ return { ...media, dimensions };\n+ }),\n+ };\n+ }\n+ return unwrapped;\n}\nfunction unshimMessageStore(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Hack to hardcode dimensions of first four photo uploads
This is ugly but it's easy and it works and I can remove it later. |
129,187 | 15.03.2019 18:10:16 | 14,400 | c53b3527d06ed33df2aeb6e6fd6968bf280ba85b | [server] Include dimensions in fetchMedia
Forgot to add this because the typechecker didn't notice it | [
{
"change_type": "MODIFY",
"old_path": "server/src/fetchers/upload-fetchers.js",
"new_path": "server/src/fetchers/upload-fetchers.js",
"diff": "@@ -42,7 +42,7 @@ async function fetchMedia(\nmediaIDs: $ReadOnlyArray<string>,\n): Promise<$ReadOnlyArray<Media>> {\nconst query = SQL`\n- SELECT id, secret, type\n+ SELECT id, secret, type, extra\nFROM uploads\nWHERE id IN (${mediaIDs}) AND uploader = ${viewer.id} AND container IS NULL\n`;\n@@ -53,6 +53,7 @@ async function fetchMedia(\nid,\nuri: getUploadURL(id, row.secret),\ntype: row.type,\n+ dimensions: row.extra,\n};\n});\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Include dimensions in fetchMedia
Forgot to add this because the typechecker didn't notice it |
129,187 | 15.03.2019 18:22:31 | 14,400 | 4a69ac80563dc208936e0d10c202d06e1755f03b | [native] Use dimensions from MultimediaMessageInfo instead of calculating | [
{
"change_type": "MODIFY",
"old_path": "native/chat/composed-message.react.js",
"new_path": "native/chat/composed-message.react.js",
"diff": "// @flow\n-import type {\n- ChatMessageInfoItemWithHeight,\n-} from './message-list-container.react';\n+import type { ChatMessageInfoItemWithHeight } from './message.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport { assertComposableMessageType } from 'lib/types/message-types';\nimport type { ViewStyle } from '../types/styles';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/failed-send.react.js",
"new_path": "native/chat/failed-send.react.js",
"diff": "// @flow\n-import type {\n- ChatMessageInfoItemWithHeight,\n-} from './message-list-container.react';\n+import type { ChatMessageInfoItemWithHeight } from './message.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport {\nmessageTypes,\n@@ -27,7 +25,7 @@ import {\nimport Button from '../components/button.react';\n-type Props = {\n+type Props = {|\nitem: ChatMessageInfoItemWithHeight,\n// Redux state\nrawMessageInfo: RawMessageInfo,\n@@ -39,7 +37,7 @@ type Props = {\nlocalID: string,\ntext: string,\n) => Promise<SendMessageResult>,\n-};\n+|};\nclass FailedSend extends React.PureComponent<Props> {\nstatic propTypes = {\n@@ -49,26 +47,7 @@ class FailedSend extends React.PureComponent<Props> {\nsendTextMessage: PropTypes.func.isRequired,\n};\n- constructor(props: Props) {\n- super(props);\n- invariant(\n- props.item.messageInfo.type === messageTypes.TEXT,\n- \"TextMessage should only be used for messageTypes.TEXT\",\n- );\n- }\n-\n- componentWillReceiveProps(nextProps: Props) {\n- invariant(\n- nextProps.item.messageInfo.type === messageTypes.TEXT,\n- \"TextMessage should only be used for messageTypes.TEXT\",\n- );\n- }\n-\nrender() {\n- invariant(\n- this.props.item.messageInfo.type === messageTypes.TEXT,\n- \"TextMessage should only be used for messageTypes.TEXT\",\n- );\nconst { isViewer } = this.props.item.messageInfo.creator;\nif (!isViewer) {\nreturn null;\n@@ -99,10 +78,7 @@ class FailedSend extends React.PureComponent<Props> {\nretrySend = () => {\nconst { rawMessageInfo } = this.props;\n- invariant(\n- rawMessageInfo.type === messageTypes.TEXT,\n- \"TextMessage should only be used for messageTypes.TEXT\",\n- );\n+ if (rawMessageInfo.type === messageTypes.TEXT) {\nconst newRawMessageInfo = {\n...rawMessageInfo,\ntime: Date.now(),\n@@ -114,6 +90,7 @@ class FailedSend extends React.PureComponent<Props> {\nnewRawMessageInfo,\n);\n}\n+ }\nasync sendMessageAction(messageInfo: RawTextMessageInfo) {\ntry {\n@@ -162,12 +139,7 @@ const styles = StyleSheet.create({\nexport default connect(\n(state: AppState, ownProps: { item: ChatMessageInfoItemWithHeight }) => {\n- const { messageInfo } = ownProps.item;\n- invariant(\n- messageInfo.type === messageTypes.TEXT,\n- \"TextMessage should only be used for messageTypes.TEXT\",\n- );\n- const id = messageID(messageInfo);\n+ const id = messageID(ownProps.item.messageInfo);\nreturn {\nrawMessageInfo: state.messageStore.messages[id],\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-container.react.js",
"new_path": "native/chat/message-list-container.react.js",
"diff": "import type { AppState } from '../redux-setup';\nimport {\n- type ComposableMessageInfo,\n- type RobotextMessageInfo,\n- type LocalMessageInfo,\ntype FetchMessageInfosPayload,\nmessageTypes,\n} from 'lib/types/message-types';\n@@ -18,6 +15,7 @@ import type {\nNavigationLeafRoute,\n} from 'react-navigation';\nimport type { TextToMeasure } from '../text-height-measurer.react';\n+import type { ChatMessageInfoItemWithHeight } from './message.react';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n@@ -38,32 +36,12 @@ import ThreadSettingsButton from './thread-settings-button.react';\nimport { registerChatScreen } from './chat-screen-registry';\nimport TextHeightMeasurer from '../text-height-measurer.react';\nimport ChatInputBar from './chat-input-bar.react';\n+import { multimediaMessageContentHeight } from './multimedia-message.react';\nimport {\n- multimediaMessageLoadingContentHeight,\n-} from './multimedia-message.react';\n-import { textMessageMaxWidthSelector } from './composed-message-width';\n+ textMessageMaxWidthSelector,\n+ composedMessageMaxWidthSelector,\n+} from './composed-message-width';\n-export type ChatMessageInfoItemWithHeight =\n- | {|\n- itemType: \"message\",\n- messageInfo: RobotextMessageInfo,\n- threadInfo: ThreadInfo,\n- startsConversation: bool,\n- startsCluster: bool,\n- endsCluster: bool,\n- robotext: string,\n- contentHeight: number,\n- |}\n- | {|\n- itemType: \"message\",\n- messageInfo: ComposableMessageInfo,\n- localMessageInfo: ?LocalMessageInfo,\n- threadInfo: ThreadInfo,\n- startsConversation: bool,\n- startsCluster: bool,\n- endsCluster: bool,\n- contentHeight: number,\n- |};\nexport type ChatMessageItemWithHeight =\n{| itemType: \"loader\" |} |\nChatMessageInfoItemWithHeight;\n@@ -81,6 +59,7 @@ type Props = {|\nthreadInfo: ?ThreadInfo,\nmessageListData: $ReadOnlyArray<ChatMessageItem>,\ntextMessageMaxWidth: number,\n+ composedMessageMaxWidth: number,\n|};\ntype State = {|\ntextToMeasure: TextToMeasure[],\n@@ -102,6 +81,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nthreadInfo: threadInfoPropType,\nmessageListData: PropTypes.arrayOf(chatMessageItemPropType).isRequired,\ntextMessageMaxWidth: PropTypes.number.isRequired,\n+ composedMessageMaxWidth: PropTypes.number.isRequired,\n};\nstatic navigationOptions = ({ navigation }) => ({\nheaderTitle: (\n@@ -121,7 +101,6 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n: null,\nheaderBackTitle: \"Back\",\n});\n- updatedHeights: Map<string, number> = new Map();\nconstructor(props: Props) {\nsuper(props);\n@@ -219,7 +198,6 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n<MessageList\nthreadInfo={threadInfo}\nmessageListData={listDataWithHeights}\n- updateHeightForMessage={this.updateHeightForMessage}\n/>\n);\n} else {\n@@ -274,20 +252,19 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nconst localMessageInfo = item.localMessageInfo\n? item.localMessageInfo\n: null;\n- const updatedHeight = this.updatedHeights.get(id);\n- const contentHeight =\n- updatedHeight !== null && updatedHeight !== undefined\n- ? updatedHeight\n- : multimediaMessageLoadingContentHeight;\nreturn {\nitemType: \"message\",\n+ messageShapeType: \"multimedia\",\nmessageInfo,\nlocalMessageInfo,\nthreadInfo,\nstartsConversation: item.startsConversation,\nstartsCluster: item.startsCluster,\nendsCluster: item.endsCluster,\n- contentHeight,\n+ contentHeight: multimediaMessageContentHeight(\n+ messageInfo,\n+ this.props.composedMessageMaxWidth,\n+ ),\n};\n}\ninvariant(textHeights, \"textHeights not set\");\n@@ -303,6 +280,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n: null;\nreturn {\nitemType: \"message\",\n+ messageShapeType: \"text\",\nmessageInfo,\nlocalMessageInfo,\nthreadInfo,\n@@ -318,6 +296,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n);\nreturn {\nitemType: \"message\",\n+ messageShapeType: \"robotext\",\nmessageInfo,\nthreadInfo,\nstartsConversation: item.startsConversation,\n@@ -331,50 +310,6 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nreturn listDataWithHeights;\n}\n- updateHeightForMessage = (id: string, contentHeight: number) => {\n- this.updatedHeights.set(id, contentHeight);\n- this.setState((prevState: State) => {\n- const prevListData = prevState.listDataWithHeights;\n- if (!prevListData) {\n- return {};\n- }\n- let itemModified = false;\n- const newListData = prevListData.map(item => {\n- if (item.itemType !== \"message\") {\n- return item;\n- }\n- const { messageInfo } = item;\n- const itemID = messageKey(messageInfo);\n- if (itemID !== id) {\n- return item;\n- }\n- itemModified = true;\n- // Conditional due to Flow...\n- const localMessageInfo = item.localMessageInfo\n- ? item.localMessageInfo\n- : null;\n- invariant(\n- messageInfo.type === messageTypes.MULTIMEDIA,\n- \"only MULTIMEDIA messages can have height overriden\",\n- );\n- return {\n- itemType: \"message\",\n- messageInfo,\n- localMessageInfo,\n- threadInfo: item.threadInfo,\n- startsConversation: item.startsConversation,\n- startsCluster: item.startsCluster,\n- endsCluster: item.endsCluster,\n- contentHeight,\n- };\n- });\n- if (!itemModified) {\n- return {};\n- }\n- return { listDataWithHeights: newListData };\n- });\n- }\n-\n}\nconst styles = StyleSheet.create({\n@@ -410,6 +345,7 @@ export default connect(\nthreadInfo: threadInfoSelector(state)[threadID],\nmessageListData: messageListData(threadID)(state),\ntextMessageMaxWidth: textMessageMaxWidthSelector(state),\n+ composedMessageMaxWidth: composedMessageMaxWidthSelector(state),\n};\n},\n)(MessageListContainer);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -6,10 +6,7 @@ import { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport type { ViewToken } from 'react-native/Libraries/Lists/ViewabilityHelper';\nimport type { FetchMessageInfosPayload } from 'lib/types/message-types';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\n-import type {\n- ChatMessageInfoItemWithHeight,\n- ChatMessageItemWithHeight,\n-} from './message-list-container.react';\n+import type { ChatMessageItemWithHeight } from './message-list-container.react';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n@@ -29,13 +26,16 @@ import threadWatcher from 'lib/shared/thread-watcher';\nimport { threadInChatList } from 'lib/shared/thread-utils';\nimport { registerFetchKey } from 'lib/reducers/loading-reducer';\n-import { Message, messageItemHeight } from './message.react';\n+import {\n+ Message,\n+ messageItemHeight,\n+ type ChatMessageInfoItemWithHeight,\n+} from './message.react';\nimport ListLoadingIndicator from '../list-loading-indicator.react';\ntype Props = {|\nthreadInfo: ThreadInfo,\nmessageListData: $ReadOnlyArray<ChatMessageItemWithHeight>,\n- updateHeightForMessage: (id: string, contentHeight: number) => void,\n// Redux state\nviewerID: ?string,\nstartReached: bool,\n@@ -58,7 +58,6 @@ class MessageList extends React.PureComponent<Props, State> {\nstatic propTypes = {\nthreadInfo: threadInfoPropType.isRequired,\nmessageListData: PropTypes.arrayOf(chatMessageItemPropType).isRequired,\n- updateHeightForMessage: PropTypes.func.isRequired,\nviewerID: PropTypes.string,\nstartReached: PropTypes.bool.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\n@@ -125,7 +124,6 @@ class MessageList extends React.PureComponent<Props, State> {\nitem={messageInfoItem}\nfocused={focused}\ntoggleFocus={this.toggleMessageFocus}\n- updateHeightForMessage={this.props.updateHeightForMessage}\n/>\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message.react.js",
"new_path": "native/chat/message.react.js",
"diff": "// @flow\nimport type {\n- ChatMessageInfoItemWithHeight,\n-} from './message-list-container.react';\n+ ChatRobotextMessageInfoItemWithHeight,\n+} from './robotext-message.react';\n+import type {\n+ ChatTextMessageInfoItemWithHeight,\n+} from './text-message.react';\n+import type {\n+ ChatMultimediaMessageInfoItem,\n+} from './multimedia-message.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport { messageTypes } from 'lib/types/message-types';\n@@ -25,14 +31,19 @@ import {\nmultimediaMessageItemHeight,\n} from './multimedia-message.react';\n+export type ChatMessageInfoItemWithHeight =\n+ | ChatRobotextMessageInfoItemWithHeight\n+ | ChatTextMessageInfoItemWithHeight\n+ | ChatMultimediaMessageInfoItem;\n+\nfunction messageItemHeight(\nitem: ChatMessageInfoItemWithHeight,\nviewerID: ?string,\n) {\nlet height = 0;\n- if (item.messageInfo.type === messageTypes.TEXT) {\n+ if (item.messageShapeType === \"text\") {\nheight += textMessageItemHeight(item, viewerID);\n- } else if (item.messageInfo.type === messageTypes.MULTIMEDIA) {\n+ } else if (item.messageShapeType === \"multimedia\") {\nheight += multimediaMessageItemHeight(item, viewerID);\n} else {\nheight += robotextMessageItemHeight(item, viewerID);\n@@ -43,19 +54,17 @@ function messageItemHeight(\nreturn height;\n}\n-type Props = {\n+type Props = {|\nitem: ChatMessageInfoItemWithHeight,\nfocused: bool,\ntoggleFocus: (messageKey: string) => void,\n- updateHeightForMessage: (id: string, contentHeight: number) => void,\n-};\n+|};\nclass Message extends React.PureComponent<Props> {\nstatic propTypes = {\nitem: chatMessageItemPropType.isRequired,\nfocused: PropTypes.bool.isRequired,\ntoggleFocus: PropTypes.func.isRequired,\n- updateHeightForMessage: PropTypes.func.isRequired,\n};\ncomponentWillReceiveProps(nextProps: Props) {\n@@ -77,7 +86,7 @@ class Message extends React.PureComponent<Props> {\n);\n}\nlet message;\n- if (this.props.item.messageInfo.type === messageTypes.TEXT) {\n+ if (this.props.item.messageShapeType === \"text\") {\nmessage = (\n<TextMessage\nitem={this.props.item}\n@@ -85,12 +94,11 @@ class Message extends React.PureComponent<Props> {\ntoggleFocus={this.props.toggleFocus}\n/>\n);\n- } else if (this.props.item.messageInfo.type === messageTypes.MULTIMEDIA) {\n+ } else if (this.props.item.messageShapeType === \"multimedia\") {\nmessage = (\n<MultimediaMessage\nitem={this.props.item}\ntoggleFocus={this.props.toggleFocus}\n- updateHeightForMessage={this.props.updateHeightForMessage}\n/>\n);\n} else {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message.react.js",
"new_path": "native/chat/multimedia-message.react.js",
"diff": "// @flow\n-import type {\n- ChatMessageInfoItemWithHeight,\n-} from './message-list-container.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\n-import { messageTypes } from 'lib/types/message-types';\n+import {\n+ messageTypes,\n+ type MultimediaMessageInfo,\n+ type LocalMessageInfo,\n+} from 'lib/types/message-types';\nimport type { Media } from 'lib/types/media-types';\nimport type { ImageStyle } from '../types/styles';\n-import type { AppState } from '../redux-setup';\n-import {\n- type ConnectionStatus,\n- connectionStatusPropType,\n-} from 'lib/types/socket-types';\n+import type { ThreadInfo } from 'lib/types/thread-types';\nimport * as React from 'react';\nimport {\n@@ -26,16 +23,50 @@ import invariant from 'invariant';\nimport PropTypes from 'prop-types';\nimport { messageKey } from 'lib/shared/message-utils';\n-import { connect } from 'lib/utils/redux-utils';\nimport ComposedMessage from './composed-message.react';\n-import { preloadImage } from '../utils/media-utils';\n-import { composedMessageMaxWidthSelector } from './composed-message-width';\n-const multimediaMessageLoadingContentHeight = 100;\n+export type ChatMultimediaMessageInfoItem = {|\n+ itemType: \"message\",\n+ messageShapeType: \"multimedia\",\n+ messageInfo: MultimediaMessageInfo,\n+ localMessageInfo: ?LocalMessageInfo,\n+ threadInfo: ThreadInfo,\n+ startsConversation: bool,\n+ startsCluster: bool,\n+ endsCluster: bool,\n+ contentHeight: number,\n+|};\n+\n+function multimediaMessageContentHeight(\n+ messageInfo: MultimediaMessageInfo,\n+ composedMessageMaxWidth: number,\n+) {\n+ let contentHeight;\n+ if (messageInfo.media.length === 1) {\n+ const [ media ] = messageInfo.media;\n+ const mediaDimensions = media.dimensions;\n+ if (composedMessageMaxWidth >= mediaDimensions.width) {\n+ contentHeight = mediaDimensions.height;\n+ } else {\n+ contentHeight = mediaDimensions.height *\n+ composedMessageMaxWidth / mediaDimensions.width;\n+ }\n+ } else if (messageInfo.media.length === 2) {\n+ contentHeight = composedMessageMaxWidth / 2;\n+ } else if (messageInfo.media.length === 3) {\n+ contentHeight = composedMessageMaxWidth / 3;\n+ } else if (messageInfo.media.length === 4) {\n+ contentHeight = composedMessageMaxWidth;\n+ } else {\n+ const numRows = Math.ceil(messageInfo.media.length / 3);\n+ contentHeight = numRows * composedMessageMaxWidth / 3;\n+ }\n+ return contentHeight;\n+}\nfunction multimediaMessageItemHeight(\n- item: ChatMessageInfoItemWithHeight,\n+ item: ChatMultimediaMessageInfoItem,\nviewerID: ?string,\n) {\nconst { messageInfo, contentHeight, startsCluster, endsCluster } = item;\n@@ -60,12 +91,8 @@ function multimediaMessageItemHeight(\n}\ntype Props = {|\n- item: ChatMessageInfoItemWithHeight,\n+ item: ChatMultimediaMessageInfoItem,\ntoggleFocus: (messageKey: string) => void,\n- updateHeightForMessage: (id: string, contentHeight: number) => void,\n- // Redux state\n- composedMessageMaxWidth: number,\n- connectionStatus: ConnectionStatus,\n|};\ntype State = {|\npreloaded: bool,\n@@ -75,90 +102,11 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\nstatic propTypes = {\nitem: chatMessageItemPropType.isRequired,\ntoggleFocus: PropTypes.func.isRequired,\n- updateHeightForMessage: PropTypes.func.isRequired,\n- composedMessageMaxWidth: PropTypes.number.isRequired,\n- connectionStatus: connectionStatusPropType.isRequired,\n};\nstate = {\n- preloaded: false,\n+ preloaded: true,\n};\n- componentDidMount() {\n- this.calculateDimensions();\n- }\n-\n- componentDidUpdate(prevProps: Props) {\n- const { messageInfo } = this.props.item;\n- const oldMessageInfo = prevProps.item.messageInfo;\n- invariant(\n- messageInfo.type === messageTypes.MULTIMEDIA &&\n- oldMessageInfo.type === messageTypes.MULTIMEDIA,\n- \"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n- );\n- if (messageInfo.media.length !== oldMessageInfo.media.length) {\n- this.calculateDimensions();\n- return;\n- }\n- for (let i = 0; i < messageInfo.media.length; i++) {\n- if (messageInfo.media[i].uri !== oldMessageInfo.media[i].uri) {\n- this.calculateDimensions();\n- return;\n- }\n- }\n-\n- if (\n- !this.state.preloaded &&\n- this.props.connectionStatus === \"connected\" &&\n- prevProps.connectionStatus !== \"connected\"\n- ) {\n- this.calculateDimensions();\n- }\n- }\n-\n- async calculateDimensions() {\n- const { messageInfo } = this.props.item;\n- invariant(\n- messageInfo.type === messageTypes.MULTIMEDIA,\n- \"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n- );\n-\n- const promises = {};\n- for (let media of messageInfo.media) {\n- promises[media.id] = preloadImage(media.uri);\n- }\n- let dimensions;\n- try {\n- dimensions = await Promise.all(messageInfo.media.map(\n- media => preloadImage(media.uri),\n- ));\n- } catch (e) {\n- return;\n- }\n- this.setState({ preloaded: true });\n-\n- const { composedMessageMaxWidth } = this.props;\n- let contentHeight;\n- if (messageInfo.media.length === 1) {\n- const [ mediaDimensions ] = dimensions;\n- if (composedMessageMaxWidth >= mediaDimensions.width) {\n- contentHeight = mediaDimensions.height;\n- } else {\n- contentHeight = mediaDimensions.height *\n- composedMessageMaxWidth / mediaDimensions.width;\n- }\n- } else if (messageInfo.media.length === 2) {\n- contentHeight = composedMessageMaxWidth / 2;\n- } else if (messageInfo.media.length === 3) {\n- contentHeight = composedMessageMaxWidth / 3;\n- } else if (messageInfo.media.length === 4) {\n- contentHeight = composedMessageMaxWidth;\n- } else {\n- const numRows = Math.ceil(messageInfo.media.length / 3);\n- contentHeight = numRows * composedMessageMaxWidth / 3;\n- }\n- this.props.updateHeightForMessage(messageKey(messageInfo), contentHeight);\n- }\n-\nrender() {\nconst { messageInfo, contentHeight } = this.props.item;\ninvariant(\n@@ -372,15 +320,8 @@ const rowStyles = {\n],\n};\n-const WrappedMultimediaMessage = connect(\n- (state: AppState) => ({\n- composedMessageMaxWidth: composedMessageMaxWidthSelector(state),\n- connectionStatus: state.connection.status,\n- }),\n-)(MultimediaMessage);\n-\nexport {\n- multimediaMessageLoadingContentHeight,\n- WrappedMultimediaMessage as MultimediaMessage,\n+ MultimediaMessage,\n+ multimediaMessageContentHeight,\nmultimediaMessageItemHeight,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/robotext-message.react.js",
"new_path": "native/chat/robotext-message.react.js",
"diff": "// @flow\nimport { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\n-import type {\n- ChatMessageInfoItemWithHeight,\n-} from './message-list-container.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport type { Dispatch } from 'lib/types/redux-types';\nimport type { AppState } from '../redux-setup';\n-import { messageTypeIsRobotext } from 'lib/types/message-types';\n+import {\n+ messageTypeIsRobotext,\n+ type RobotextMessageInfo,\n+} from 'lib/types/message-types';\nimport React from 'react';\nimport {\n@@ -15,7 +15,6 @@ import {\nStyleSheet,\nTouchableWithoutFeedback,\n} from 'react-native';\n-import invariant from 'invariant';\nimport PropTypes from 'prop-types';\nimport Hyperlink from 'react-native-hyperlink';\n@@ -29,17 +28,29 @@ import { connect } from 'lib/utils/redux-utils';\nimport { MessageListRouteName } from '../navigation/route-names';\n+export type ChatRobotextMessageInfoItemWithHeight = {|\n+ itemType: \"message\",\n+ messageShapeType: \"robotext\",\n+ messageInfo: RobotextMessageInfo,\n+ threadInfo: ThreadInfo,\n+ startsConversation: bool,\n+ startsCluster: bool,\n+ endsCluster: bool,\n+ robotext: string,\n+ contentHeight: number,\n+|};\n+\nfunction robotextMessageItemHeight(\n- item: ChatMessageInfoItemWithHeight,\n+ item: ChatRobotextMessageInfoItemWithHeight,\nviewerID: ?string,\n) {\nreturn 17 + item.contentHeight; // for padding, margin, and text\n}\n-type Props = {\n- item: ChatMessageInfoItemWithHeight,\n+type Props = {|\n+ item: ChatRobotextMessageInfoItemWithHeight,\ntoggleFocus: (messageKey: string) => void,\n-};\n+|};\nclass RobotextMessage extends React.PureComponent<Props> {\nstatic propTypes = {\n@@ -47,21 +58,6 @@ class RobotextMessage extends React.PureComponent<Props> {\ntoggleFocus: PropTypes.func.isRequired,\n};\n- constructor(props: Props) {\n- super(props);\n- invariant(\n- messageTypeIsRobotext(props.item.messageInfo.type),\n- \"TextMessage can only be used for robotext\",\n- );\n- }\n-\n- componentWillReceiveProps(nextProps: Props) {\n- invariant(\n- messageTypeIsRobotext(nextProps.item.messageInfo.type),\n- \"TextMessage can only be used for robotext\",\n- );\n- }\n-\nrender() {\nreturn (\n<TouchableWithoutFeedback onPress={this.onPress}>\n@@ -71,11 +67,7 @@ class RobotextMessage extends React.PureComponent<Props> {\n}\nlinkedRobotext() {\n- const item = this.props.item;\n- invariant(\n- item.robotext && typeof item.robotext === \"string\",\n- \"Flow can't handle our fancy types :(\",\n- );\n+ const { item } = this.props;\nconst robotext = item.robotext;\nconst robotextParts = splitRobotext(robotext);\nconst textParts = [];\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/rounded-message-container.react.js",
"new_path": "native/chat/rounded-message-container.react.js",
"diff": "// @flow\n-import type {\n- ChatMessageInfoItemWithHeight,\n-} from './message-list-container.react';\n+import type { ChatMessageInfoItemWithHeight } from './message.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport type { ViewStyle } from '../types/styles';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/text-message.react.js",
"new_path": "native/chat/text-message.react.js",
"diff": "// @flow\n-import type {\n- ChatMessageInfoItemWithHeight,\n-} from './message-list-container.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport type { TooltipItemData } from '../components/tooltip.react';\nimport {\nmessageTypes,\n+ type TextMessageInfo,\n+ type LocalMessageInfo,\n} from 'lib/types/message-types';\n+import type { ThreadInfo } from 'lib/types/thread-types';\nimport * as React from 'react';\nimport { Text, StyleSheet, Clipboard } from 'react-native';\n@@ -24,8 +24,20 @@ import Tooltip from '../components/tooltip.react';\nimport ComposedMessage from './composed-message.react';\nimport RoundedMessageContainer from './rounded-message-container.react';\n+export type ChatTextMessageInfoItemWithHeight = {|\n+ itemType: \"message\",\n+ messageShapeType: \"text\",\n+ messageInfo: TextMessageInfo,\n+ localMessageInfo: ?LocalMessageInfo,\n+ threadInfo: ThreadInfo,\n+ startsConversation: bool,\n+ startsCluster: bool,\n+ endsCluster: bool,\n+ contentHeight: number,\n+|};\n+\nfunction textMessageItemHeight(\n- item: ChatMessageInfoItemWithHeight,\n+ item: ChatTextMessageInfoItemWithHeight,\nviewerID: ?string,\n) {\nconst { messageInfo, contentHeight, startsCluster, endsCluster } = item;\n@@ -50,7 +62,7 @@ function textMessageItemHeight(\n}\ntype Props = {|\n- item: ChatMessageInfoItemWithHeight,\n+ item: ChatTextMessageInfoItemWithHeight,\nfocused: bool,\ntoggleFocus: (messageKey: string) => void,\n|};\n@@ -73,10 +85,6 @@ class TextMessage extends React.PureComponent<Props> {\nrender() {\nconst { item } = this.props;\n- invariant(\n- item.messageInfo.type === messageTypes.TEXT,\n- \"TextMessage should only be used for messageTypes.TEXT\",\n- );\nconst { text, id, creator } = item.messageInfo;\nconst { isViewer } = creator;\n@@ -156,10 +164,6 @@ class TextMessage extends React.PureComponent<Props> {\n}\nonPressCopy = () => {\n- invariant(\n- this.props.item.messageInfo.type === messageTypes.TEXT,\n- \"TextMessage should only be used for messageTypes.TEXT\",\n- );\nClipboard.setString(this.props.item.messageInfo.text);\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use dimensions from MultimediaMessageInfo instead of calculating |
129,187 | 15.03.2019 19:10:01 | 14,400 | ff1d7027d90c931bd33d0985279eca92e8f87dea | [native] Use FastImage in MultimediaMessage | [
{
"change_type": "MODIFY",
"old_path": "native/.flowconfig",
"new_path": "native/.flowconfig",
"diff": ".*/Libraries/polyfills/.*\n.*/node_modules/redux-persist/lib/index.js\n+.*/node_modules/react-native-fast-image/src/index.js.flow\n; Ignore metro\n.*/node_modules/metro/.*\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/app/build.gradle",
"new_path": "native/android/app/build.gradle",
"diff": "@@ -144,6 +144,7 @@ android {\n}\ndependencies {\n+ implementation project(':react-native-fast-image')\ncompile project(':react-native-screens')\ncompile project(':react-native-gesture-handler')\nimplementation project(':react-native-splash-screen')\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java",
"new_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java",
"diff": "@@ -3,6 +3,7 @@ package org.squadcal;\nimport android.app.Application;\nimport com.facebook.react.ReactApplication;\n+import com.dylanvann.fastimage.FastImageViewPackage;\nimport com.swmansion.rnscreens.RNScreensPackage;\nimport com.swmansion.gesturehandler.react.RNGestureHandlerPackage;\nimport org.devio.rn.splashscreen.SplashScreenReactPackage;\n@@ -30,6 +31,7 @@ public class MainApplication extends Application implements ReactApplication {\nprotected List<ReactPackage> getPackages() {\nreturn Arrays.<ReactPackage>asList(\nnew MainReactPackage(),\n+ new FastImageViewPackage(),\nnew RNScreensPackage(),\nnew RNGestureHandlerPackage(),\nnew SplashScreenReactPackage(),\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/settings.gradle",
"new_path": "native/android/settings.gradle",
"diff": "rootProject.name = 'SquadCal'\n+include ':react-native-fast-image'\n+project(':react-native-fast-image').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fast-image/android')\ninclude ':react-native-screens'\nproject(':react-native-screens').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-screens/android')\ninclude ':react-native-gesture-handler'\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message.react.js",
"new_path": "native/chat/message.react.js",
"diff": "@@ -10,7 +10,6 @@ import type {\nChatMultimediaMessageInfoItem,\n} from './multimedia-message.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\n-import { messageTypes } from 'lib/types/message-types';\nimport React from 'react';\nimport { Text, StyleSheet, View, LayoutAnimation } from 'react-native';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message.react.js",
"new_path": "native/chat/multimedia-message.react.js",
"diff": "// @flow\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\n-import {\n- messageTypes,\n- type MultimediaMessageInfo,\n- type LocalMessageInfo,\n+import type {\n+ MultimediaMessageInfo,\n+ LocalMessageInfo,\n} from 'lib/types/message-types';\nimport type { Media } from 'lib/types/media-types';\nimport type { ImageStyle } from '../types/styles';\n@@ -16,15 +15,14 @@ import {\nStyleSheet,\nTouchableWithoutFeedback,\nView,\n- Image,\nActivityIndicator,\n} from 'react-native';\n-import invariant from 'invariant';\nimport PropTypes from 'prop-types';\nimport { messageKey } from 'lib/shared/message-utils';\nimport ComposedMessage from './composed-message.react';\n+import Multimedia from './multimedia.react';\nexport type ChatMultimediaMessageInfoItem = {|\nitemType: \"message\",\n@@ -95,7 +93,7 @@ type Props = {|\ntoggleFocus: (messageKey: string) => void,\n|};\ntype State = {|\n- preloaded: bool,\n+ loadedMediaIDs: $ReadOnlyArray<string>,\n|};\nclass MultimediaMessage extends React.PureComponent<Props, State> {\n@@ -104,35 +102,29 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\ntoggleFocus: PropTypes.func.isRequired,\n};\nstate = {\n- preloaded: true,\n+ loadedMediaIDs: [],\n};\n+ get loaded() {\n+ const { loadedMediaIDs } = this.state;\n+ const { messageInfo } = this.props.item;\n+ return loadedMediaIDs.length === messageInfo.media.length;\n+ }\n+\nrender() {\nconst { messageInfo, contentHeight } = this.props.item;\n- invariant(\n- messageInfo.type === messageTypes.MULTIMEDIA,\n- \"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n- );\nconst { id, creator } = messageInfo;\nconst { isViewer } = creator;\nconst heightStyle = { height: contentHeight };\n- let content;\n- if (!this.state.preloaded) {\n- content = (\n- <View style={[heightStyle, styles.container]}>\n+ let loadingOverlay;\n+ if (!this.loaded) {\n+ loadingOverlay = (\n<ActivityIndicator\ncolor=\"black\"\nsize=\"large\"\n- style={heightStyle}\n+ style={[heightStyle, styles.loadingOverlay]}\n/>\n- </View>\n- );\n- } else {\n- content = (\n- <View style={[heightStyle, styles.container]}>\n- {this.renderContent()}\n- </View>\n);\n}\n@@ -150,7 +142,10 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\nstyle={styles.row}\n>\n<TouchableWithoutFeedback onPress={this.onPress}>\n- {content}\n+ <View style={[heightStyle, styles.container]}>\n+ {loadingOverlay}\n+ {this.renderContent()}\n+ </View>\n</TouchableWithoutFeedback>\n</ComposedMessage>\n);\n@@ -158,27 +153,23 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\nrenderContent(): React.Node {\nconst { messageInfo } = this.props.item;\n- invariant(\n- messageInfo.type === messageTypes.MULTIMEDIA,\n- \"MultimediaMessage should only be used for messageTypes.MULTIMEDIA\",\n- );\nif (messageInfo.media.length === 1) {\n- return MultimediaMessage.renderImage(messageInfo.media[0]);\n+ return this.renderImage(messageInfo.media[0]);\n} else if (messageInfo.media.length === 2) {\nconst [ one, two ] = messageInfo.media;\nreturn (\n<View style={styles.row}>\n- {MultimediaMessage.renderImage(one, styles.leftImage)}\n- {MultimediaMessage.renderImage(two, styles.rightImage)}\n+ {this.renderImage(one, styles.leftImage)}\n+ {this.renderImage(two, styles.rightImage)}\n</View>\n);\n} else if (messageInfo.media.length === 3) {\nconst [ one, two, three ] = messageInfo.media;\nreturn (\n<View style={styles.row}>\n- {MultimediaMessage.renderImage(one, styles.leftImage)}\n- {MultimediaMessage.renderImage(two, styles.centerImage)}\n- {MultimediaMessage.renderImage(three, styles.rightImage)}\n+ {this.renderImage(one, styles.leftImage)}\n+ {this.renderImage(two, styles.centerImage)}\n+ {this.renderImage(three, styles.rightImage)}\n</View>\n);\n} else if (messageInfo.media.length === 4) {\n@@ -186,12 +177,12 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\nreturn (\n<View style={styles.grid}>\n<View style={styles.row}>\n- {MultimediaMessage.renderImage(one, styles.topLeftImage)}\n- {MultimediaMessage.renderImage(two, styles.topRightImage)}\n+ {this.renderImage(one, styles.topLeftImage)}\n+ {this.renderImage(two, styles.topRightImage)}\n</View>\n<View style={styles.row}>\n- {MultimediaMessage.renderImage(three, styles.bottomLeftImage)}\n- {MultimediaMessage.renderImage(four, styles.bottomRightImage)}\n+ {this.renderImage(three, styles.bottomLeftImage)}\n+ {this.renderImage(four, styles.bottomRightImage)}\n</View>\n</View>\n);\n@@ -213,7 +204,7 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\nfor (; j < rowMedia.length; j++) {\nconst media = rowMedia[j];\nconst style = rowStyle[j];\n- row.push(MultimediaMessage.renderImage(media, style));\n+ row.push(this.renderImage(media, style));\n}\nfor (; j < 3; j++) {\nconst key = `filler${j}`;\n@@ -230,18 +221,28 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\n}\n}\n- static renderImage(media: Media, style?: ImageStyle): React.Node {\n- const { id, uri } = media;\n- const source = { uri };\n+ renderImage(media: Media, style?: ImageStyle): React.Node {\nreturn (\n- <Image\n- source={source}\n- key={id}\n- style={[styles.image, style]}\n+ <Multimedia\n+ media={media}\n+ style={style}\n+ key={media.id}\n+ onLoad={this.onMediaLoad}\n/>\n);\n}\n+ onMediaLoad = (mediaID: string) => {\n+ this.setState(prevState => {\n+ const mediaIDs = new Set(prevState.loadedMediaIDs);\n+ if (mediaIDs.has(mediaID)) {\n+ return {};\n+ }\n+ mediaIDs.add(mediaID);\n+ return { loadedMediaIDs: [...mediaIDs] };\n+ });\n+ }\n+\nonPress = () => {\nthis.props.toggleFocus(messageKey(this.props.item.messageInfo));\n}\n@@ -255,6 +256,9 @@ const styles = StyleSheet.create({\nflexDirection: 'row',\njustifyContent: 'center',\n},\n+ loadingOverlay: {\n+ position: 'absolute',\n+ },\ngrid: {\nflex: 1,\n},\n@@ -262,9 +266,6 @@ const styles = StyleSheet.create({\nflex: 1,\nflexDirection: 'row',\n},\n- image: {\n- flex: 1,\n- },\nleftImage: {\nmarginRight: spaceBetweenImages,\n},\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/multimedia.react.js",
"diff": "+// @flow\n+\n+import { type Media, mediaPropType } from 'lib/types/media-types';\n+import type { ImageStyle } from '../types/styles';\n+\n+import * as React from 'react';\n+import PropTypes from 'prop-types';\n+import { StyleSheet } from 'react-native';\n+import FastImage from 'react-native-fast-image';\n+\n+type Props = {|\n+ media: Media,\n+ onLoad: (mediaID: string) => void,\n+ style?: ?ImageStyle,\n+|};\n+class Multimedia extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ media: mediaPropType.isRequired,\n+ onLoad: PropTypes.func.isRequired,\n+ };\n+\n+ render() {\n+ const { media, style } = this.props;\n+ const { uri } = media;\n+ const source = { uri };\n+ return (\n+ <FastImage\n+ source={source}\n+ onLoad={this.onLoad}\n+ style={[styles.image, style]}\n+ />\n+ );\n+ }\n+\n+ onLoad = () => {\n+ this.props.onLoad(this.props.media.id);\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ image: {\n+ flex: 1,\n+ },\n+});\n+\n+export default Multimedia;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/text-message.react.js",
"new_path": "native/chat/text-message.react.js",
"diff": "import { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport type { TooltipItemData } from '../components/tooltip.react';\n-import {\n- messageTypes,\n- type TextMessageInfo,\n- type LocalMessageInfo,\n+import type {\n+ TextMessageInfo,\n+ LocalMessageInfo,\n} from 'lib/types/message-types';\nimport type { ThreadInfo } from 'lib/types/thread-types';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"diff": "};\nobjectVersion = 46;\nobjects = {\n-\n/* Begin PBXBuildFile section */\n00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };\n00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };\nBBC287C467984DA6BF85800E /* libSplashScreen.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B6A1FF570694BFCB0D65D0E /* libSplashScreen.a */; };\nEFBA858A8D2B4909A08D9FE6 /* libRNGestureHandler.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E0952482A8094CE88F96C0EB /* libRNGestureHandler.a */; };\nFA7F2215AD7646E2BE985BF3 /* SimpleLineIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = AE31AFFF88FB4112A29ADE33 /* SimpleLineIcons.ttf */; };\n+ A4B3D66697E04C11B4167EE7 /* libFastImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 47C86914FEF44D79AD04F880 /* libFastImage.a */; };\n/* End PBXBuildFile section */\n/* Begin PBXContainerItemProxy section */\nEA40FBBA484449FAA8915A48 /* Foundation.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Foundation.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Foundation.ttf\"; sourceTree = \"<group>\"; };\nEBD8879422144B0188A8336F /* Zocial.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Zocial.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Zocial.ttf\"; sourceTree = \"<group>\"; };\nED28C047C454400D87062E8C /* RNGestureHandler.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = RNGestureHandler.xcodeproj; path = \"../node_modules/react-native-gesture-handler/ios/RNGestureHandler.xcodeproj\"; sourceTree = \"<group>\"; };\n+ 7FA344AAF237451CB8B3424B /* FastImage.xcodeproj */ = {isa = PBXFileReference; name = \"FastImage.xcodeproj\"; path = \"../node_modules/react-native-fast-image/ios/FastImage.xcodeproj\"; sourceTree = \"<group>\"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };\n+ 47C86914FEF44D79AD04F880 /* libFastImage.a */ = {isa = PBXFileReference; name = \"libFastImage.a\"; path = \"libFastImage.a\"; sourceTree = \"<group>\"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };\n/* End PBXFileReference section */\n/* Begin PBXFrameworksBuildPhase section */\nBBC287C467984DA6BF85800E /* libSplashScreen.a in Frameworks */,\nEFBA858A8D2B4909A08D9FE6 /* libRNGestureHandler.a in Frameworks */,\nA6EF57DD8BDA4D43812D0B13 /* libRNScreens.a in Frameworks */,\n+ A4B3D66697E04C11B4167EE7 /* libFastImage.a in Frameworks */,\n);\nrunOnlyForDeploymentPostprocessing = 0;\n};\nC2449EA8EFA9461DABF09B72 /* SplashScreen.xcodeproj */,\nED28C047C454400D87062E8C /* RNGestureHandler.xcodeproj */,\nBA72871056D240AEB0706398 /* RNScreens.xcodeproj */,\n+ 7FA344AAF237451CB8B3424B /* FastImage.xcodeproj */,\n);\nname = Libraries;\nsourceTree = \"<group>\";\n\"$(SRCROOT)/../node_modules/react-native-splash-screen/ios\",\n\"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**\",\n\"$(SRCROOT)/../node_modules/react-native-screens/ios\",\n+ \"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**\",\n);\nINFOPLIST_FILE = SquadCalTests/Info.plist;\nIPHONEOS_DEPLOYMENT_TARGET = 9.0;\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(SRCROOT)/../node_modules/react-native-splash-screen/ios\",\n\"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**\",\n\"$(SRCROOT)/../node_modules/react-native-screens/ios\",\n+ \"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**\",\n);\nINFOPLIST_FILE = SquadCalTests/Info.plist;\nIPHONEOS_DEPLOYMENT_TARGET = 9.0;\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(SRCROOT)/../node_modules/react-native-splash-screen/ios\",\n\"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**\",\n\"$(SRCROOT)/../node_modules/react-native-screens/ios\",\n+ \"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**\",\n);\nINFOPLIST_FILE = SquadCal/Info.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"$(SRCROOT)/../node_modules/react-native-splash-screen/ios\",\n\"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**\",\n\"$(SRCROOT)/../node_modules/react-native-screens/ios\",\n+ \"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**\",\n);\nINFOPLIST_FILE = SquadCal/Info.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"$(SRCROOT)/../node_modules/react-native-splash-screen/ios\",\n\"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**\",\n\"$(SRCROOT)/../node_modules/react-native-screens/ios\",\n+ \"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**\",\n);\nINFOPLIST_FILE = \"SquadCal-tvOS/Info.plist\";\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(SRCROOT)/../node_modules/react-native-splash-screen/ios\",\n\"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**\",\n\"$(SRCROOT)/../node_modules/react-native-screens/ios\",\n+ \"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**\",\n);\nINFOPLIST_FILE = \"SquadCal-tvOS/Info.plist\";\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nPRODUCT_BUNDLE_IDENTIFIER = \"com.facebook.REACT.SquadCal-tvOSTests\";\nPRODUCT_NAME = \"$(TARGET_NAME)\";\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nPRODUCT_BUNDLE_IDENTIFIER = \"com.facebook.REACT.SquadCal-tvOSTests\";\nPRODUCT_NAME = \"$(TARGET_NAME)\";\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react\": \"16.6.3\",\n\"react-native\": \"0.58.4\",\n\"react-native-exit-app\": \"^1.0.0\",\n+ \"react-native-fast-image\": \"^5.2.0\",\n\"react-native-fcm\": \"git+https://git@github.com/ashoat/react-native-fcm.git\",\n\"react-native-floating-action\": \"^1.9.0\",\n\"react-native-gesture-handler\": \"^1.0.15\",\n"
},
{
"change_type": "MODIFY",
"old_path": "yarn.lock",
"new_path": "yarn.lock",
"diff": "@@ -9990,6 +9990,11 @@ react-native-exit-app@^1.0.0:\nresolved \"https://registry.yarnpkg.com/react-native-exit-app/-/react-native-exit-app-1.0.0.tgz#a2fbb121d902e6967cd8a365fe8453e5c4bc3172\"\nintegrity sha512-2d8RlzfjA4fTJaXD3xObTt0hv+7i41bDyWDB9+zOI0zS1nGvY4mtENKhte8ceRih/3eZWQLpwkkHFP1Y8AG/5w==\n+react-native-fast-image@^5.2.0:\n+ version \"5.2.0\"\n+ resolved \"https://registry.yarnpkg.com/react-native-fast-image/-/react-native-fast-image-5.2.0.tgz#6730eb06951ea6f9a79abe02a733bc05b7a73412\"\n+ integrity sha512-S+2gmv9HfLc7CGjjnQ3kO/QoZD9BJnjfwWhsJWgjEvaeOPbpHZaXSUkINSqLcHD5KIHcYidu+U2lgXdEv4Jamg==\n+\n\"react-native-fcm@git+https://git@github.com/ashoat/react-native-fcm.git\":\nversion \"16.0.0\"\nresolved \"git+https://git@github.com/ashoat/react-native-fcm.git#5b3c8a971c3030c42b8cb795ad2f0e29ae319b78\"\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use FastImage in MultimediaMessage |
129,187 | 15.03.2019 19:56:40 | 14,400 | f99a7889ee5c6a0c9e0397ed75d18e6ce332f308 | [native] Fix own short text message alignment bug | [
{
"change_type": "MODIFY",
"old_path": "native/chat/composed-message.react.js",
"new_path": "native/chat/composed-message.react.js",
"diff": "@@ -95,7 +95,7 @@ class ComposedMessage extends React.PureComponent<Props> {\n<View style={containerStyle}>\n{authorName}\n<View style={[ styles.content, alignStyle ]}>\n- <View style={[ styles.messageBox, messageBoxStyle ]}>\n+ <View style={[ styles.messageBox, messageBoxStyle, alignStyle ]}>\n<RoundedMessageContainer\nitem={item}\nborderRadius={borderRadius}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Fix own short text message alignment bug |
129,187 | 15.03.2019 20:18:44 | 14,400 | dd410e62d0bf2d6d3b88aacfa570f097caa7c477 | [native] Show loading indicator on per-Multimedia basis | [
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message.react.js",
"new_path": "native/chat/multimedia-message.react.js",
"diff": "@@ -15,7 +15,6 @@ import {\nStyleSheet,\nTouchableWithoutFeedback,\nView,\n- ActivityIndicator,\n} from 'react-native';\nimport PropTypes from 'prop-types';\n@@ -50,6 +49,9 @@ function multimediaMessageContentHeight(\ncontentHeight = mediaDimensions.height *\ncomposedMessageMaxWidth / mediaDimensions.width;\n}\n+ if (contentHeight < 50) {\n+ contentHeight = 50;\n+ }\n} else if (messageInfo.media.length === 2) {\ncontentHeight = composedMessageMaxWidth / 2;\n} else if (messageInfo.media.length === 3) {\n@@ -92,24 +94,12 @@ type Props = {|\nitem: ChatMultimediaMessageInfoItem,\ntoggleFocus: (messageKey: string) => void,\n|};\n-type State = {|\n- loadedMediaIDs: $ReadOnlyArray<string>,\n-|};\n-class MultimediaMessage extends React.PureComponent<Props, State> {\n+class MultimediaMessage extends React.PureComponent<Props> {\nstatic propTypes = {\nitem: chatMessageItemPropType.isRequired,\ntoggleFocus: PropTypes.func.isRequired,\n};\n- state = {\n- loadedMediaIDs: [],\n- };\n-\n- get loaded() {\n- const { loadedMediaIDs } = this.state;\n- const { messageInfo } = this.props.item;\n- return loadedMediaIDs.length === messageInfo.media.length;\n- }\nrender() {\nconst { messageInfo, contentHeight } = this.props.item;\n@@ -117,17 +107,6 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\nconst { isViewer } = creator;\nconst heightStyle = { height: contentHeight };\n- let loadingOverlay;\n- if (!this.loaded) {\n- loadingOverlay = (\n- <ActivityIndicator\n- color=\"black\"\n- size=\"large\"\n- style={[heightStyle, styles.loadingOverlay]}\n- />\n- );\n- }\n-\nconst sendFailed =\nisViewer &&\n(id === null || id === undefined) &&\n@@ -143,7 +122,6 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\n>\n<TouchableWithoutFeedback onPress={this.onPress}>\n<View style={[heightStyle, styles.container]}>\n- {loadingOverlay}\n{this.renderContent()}\n</View>\n</TouchableWithoutFeedback>\n@@ -208,7 +186,7 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\n}\nfor (; j < 3; j++) {\nconst key = `filler${j}`;\n- row.push(<View style={styles.image} key={key} />);\n+ row.push(<View style={styles.filler} key={key} />);\n}\nrows.push(\n@@ -227,22 +205,10 @@ class MultimediaMessage extends React.PureComponent<Props, State> {\nmedia={media}\nstyle={style}\nkey={media.id}\n- onLoad={this.onMediaLoad}\n/>\n);\n}\n- onMediaLoad = (mediaID: string) => {\n- this.setState(prevState => {\n- const mediaIDs = new Set(prevState.loadedMediaIDs);\n- if (mediaIDs.has(mediaID)) {\n- return {};\n- }\n- mediaIDs.add(mediaID);\n- return { loadedMediaIDs: [...mediaIDs] };\n- });\n- }\n-\nonPress = () => {\nthis.props.toggleFocus(messageKey(this.props.item.messageInfo));\n}\n@@ -256,12 +222,12 @@ const styles = StyleSheet.create({\nflexDirection: 'row',\njustifyContent: 'center',\n},\n- loadingOverlay: {\n- position: 'absolute',\n- },\ngrid: {\nflex: 1,\n},\n+ filler: {\n+ flex: 1,\n+ },\nrow: {\nflex: 1,\nflexDirection: 'row',\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia.react.js",
"new_path": "native/chat/multimedia.react.js",
"diff": "import { type Media, mediaPropType } from 'lib/types/media-types';\nimport type { ImageStyle } from '../types/styles';\n+import type { LoadingStatus } from 'lib/types/loading-types';\nimport * as React from 'react';\n-import PropTypes from 'prop-types';\n-import { StyleSheet } from 'react-native';\n+import { View, StyleSheet, ActivityIndicator } from 'react-native';\nimport FastImage from 'react-native-fast-image';\ntype Props = {|\nmedia: Media,\n- onLoad: (mediaID: string) => void,\nstyle?: ?ImageStyle,\n|};\n-class Multimedia extends React.PureComponent<Props> {\n+type State = {|\n+ loadingStatus: LoadingStatus,\n+|};\n+class Multimedia extends React.PureComponent<Props, State> {\nstatic propTypes = {\nmedia: mediaPropType.isRequired,\n- onLoad: PropTypes.func.isRequired,\n+ };\n+ state = {\n+ loadingStatus: \"loading\",\n};\nrender() {\nconst { media, style } = this.props;\nconst { uri } = media;\nconst source = { uri };\n- return (\n+ const image = (\n<FastImage\nsource={source}\nonLoad={this.onLoad}\nstyle={[styles.image, style]}\n/>\n);\n+\n+ let loadingOverlay;\n+ if (this.state.loadingStatus !== \"inactive\") {\n+ return (\n+ <View style={styles.loadingContainer}>\n+ <ActivityIndicator\n+ color=\"black\"\n+ size=\"large\"\n+ style={styles.loadingOverlay}\n+ />\n+ {image}\n+ </View>\n+ );\n+ }\n+\n+ return image;\n}\nonLoad = () => {\n- this.props.onLoad(this.props.media.id);\n+ this.setState({ loadingStatus: \"inactive\" });\n}\n}\nconst styles = StyleSheet.create({\n+ loadingContainer: {\n+ flex: 1,\n+ justifyContent: 'center',\n+ alignItems: 'center',\n+ },\n+ loadingOverlay: {\n+ position: 'absolute',\n+ },\nimage: {\nflex: 1,\n},\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Show loading indicator on per-Multimedia basis |
129,187 | 15.03.2019 21:05:14 | 14,400 | 96d9e5608f2732b8bd61bdf4dd3e6ce4360b96c9 | [native] Retry Multimedia load after reconnecting | [
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia.react.js",
"new_path": "native/chat/multimedia.react.js",
"diff": "import { type Media, mediaPropType } from 'lib/types/media-types';\nimport type { ImageStyle } from '../types/styles';\nimport type { LoadingStatus } from 'lib/types/loading-types';\n+import {\n+ type ConnectionStatus,\n+ connectionStatusPropType,\n+} from 'lib/types/socket-types';\n+import type { AppState } from '../redux-setup';\nimport * as React from 'react';\nimport { View, StyleSheet, ActivityIndicator } from 'react-native';\nimport FastImage from 'react-native-fast-image';\n+import { connect } from 'lib/utils/redux-utils';\n+\ntype Props = {|\nmedia: Media,\nstyle?: ?ImageStyle,\n+ // Redux state\n+ connectionStatus: ConnectionStatus,\n|};\ntype State = {|\n+ attempt: number,\nloadingStatus: LoadingStatus,\n|};\nclass Multimedia extends React.PureComponent<Props, State> {\nstatic propTypes = {\nmedia: mediaPropType.isRequired,\n+ connectionStatus: connectionStatusPropType.isRequired,\n};\nstate = {\n+ attempt: 0,\nloadingStatus: \"loading\",\n};\n+ componentDidUpdate(prevProps: Props) {\n+ if (\n+ this.props.connectionStatus === \"connected\" &&\n+ prevProps.connectionStatus !== \"connected\"\n+ ) {\n+ this.setState(prevState => ({ attempt: prevState.attempt + 1 }));\n+ }\n+ }\n+\nrender() {\nconst { media, style } = this.props;\nconst { uri } = media;\n@@ -33,6 +54,7 @@ class Multimedia extends React.PureComponent<Props, State> {\nsource={source}\nonLoad={this.onLoad}\nstyle={[styles.image, style]}\n+ key={this.state.attempt}\n/>\n);\n@@ -73,4 +95,8 @@ const styles = StyleSheet.create({\n},\n});\n-export default Multimedia;\n+export default connect(\n+ (state: AppState) => ({\n+ connectionStatus: state.connection.status,\n+ }),\n+)(Multimedia);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Retry Multimedia load after reconnecting |
129,187 | 16.03.2019 13:23:08 | 14,400 | e257aedd44f43a937caf4373f96c715360b64e6f | [server] Get rid of file-type
Only needed from `lib` side. | [
{
"change_type": "DELETE",
"old_path": "server/flow-typed/npm/file-type_vx.x.x.js",
"new_path": null,
"diff": "-// flow-typed signature: f49f546a028646c3de3ad98d746dd7ef\n-// flow-typed version: <<STUB>>/file-type_v^10.6.0/flow_v0.78.0\n-\n-/**\n- * This is an autogenerated libdef stub for:\n- *\n- * 'file-type'\n- *\n- * Fill this stub out by replacing all the `any` types.\n- *\n- * Once filled out, we encourage you to share your work with the\n- * community by sending a pull request to:\n- * https://github.com/flowtype/flow-typed\n- */\n-\n-declare module 'file-type' {\n- declare module.exports: any;\n-}\n-\n-/**\n- * We include stubs for each file inside this npm package in case you need to\n- * require those files directly. Feel free to delete any files that aren't\n- * needed.\n- */\n-\n-\n-// Filename aliases\n-declare module 'file-type/index' {\n- declare module.exports: $Exports<'file-type'>;\n-}\n-declare module 'file-type/index.js' {\n- declare module.exports: $Exports<'file-type'>;\n-}\n"
},
{
"change_type": "MODIFY",
"old_path": "server/src/uploads/uploads.js",
"new_path": "server/src/uploads/uploads.js",
"diff": "@@ -8,7 +8,6 @@ import type {\n} from 'lib/types/media-types';\nimport multer from 'multer';\n-import fileType from 'file-type';\nimport { fileInfoFromData } from 'lib/utils/media-utils';\nimport { ServerError } from 'lib/utils/errors';\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Get rid of file-type
Only needed from `lib` side. |
129,187 | 17.03.2019 18:13:51 | 14,400 | 9277badebdb06f586b8da35426081dc1e92e35db | [server] Fix fetchMessageInfos to work with image uploads
The counting mechanism wasn't considering the joined `uploads` rows. | [
{
"change_type": "MODIFY",
"old_path": "server/src/fetchers/message-fetchers.js",
"new_path": "server/src/fetchers/message-fetchers.js",
"diff": "@@ -409,9 +409,14 @@ async function fetchMessageInfos(\nSELECT x.id, x.content, x.time, x.type, x.user AS creatorID,\nx.creation, u.username AS creator, x.subthread_permissions,\nx.uploadID, x.uploadType, x.uploadSecret, x.uploadExtra,\n- @num := if(@thread = x.thread, @num + 1, 1) AS number,\n+ @num := if(\n+ @thread = x.thread,\n+ if(@message = x.id, @num, @num + 1),\n+ 1\n+ ) AS number,\n+ @message := x.id AS messageID,\n@thread := x.thread AS threadID\n- FROM (SELECT @num := 0, @thread := '') init\n+ FROM (SELECT @num := 0, @thread := '', @message := '') init\nJOIN (\nSELECT m.id, m.thread, m.user, m.content, m.time, m.type,\nm.creation, stm.permissions AS subthread_permissions,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [server] Fix fetchMessageInfos to work with image uploads
The counting mechanism wasn't considering the joined `uploads` rows. |
129,187 | 19.03.2019 11:52:48 | 14,400 | 8bb2fbe277d0d65de901716f0c9863f388139047 | [native] Don't reload Multimedia if already loaded | [
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia.react.js",
"new_path": "native/chat/multimedia.react.js",
"diff": "import { type Media, mediaPropType } from 'lib/types/media-types';\nimport type { ImageStyle } from '../types/styles';\n-import type { LoadingStatus } from 'lib/types/loading-types';\nimport {\ntype ConnectionStatus,\nconnectionStatusPropType,\n@@ -23,7 +22,7 @@ type Props = {|\n|};\ntype State = {|\nattempt: number,\n- loadingStatus: LoadingStatus,\n+ loaded: bool,\n|};\nclass Multimedia extends React.PureComponent<Props, State> {\n@@ -33,11 +32,12 @@ class Multimedia extends React.PureComponent<Props, State> {\n};\nstate = {\nattempt: 0,\n- loadingStatus: \"loading\",\n+ loaded: false,\n};\ncomponentDidUpdate(prevProps: Props) {\nif (\n+ !this.state.loaded &&\nthis.props.connectionStatus === \"connected\" &&\nprevProps.connectionStatus !== \"connected\"\n) {\n@@ -59,7 +59,7 @@ class Multimedia extends React.PureComponent<Props, State> {\n);\nlet loadingOverlay;\n- if (this.state.loadingStatus !== \"inactive\") {\n+ if (!this.state.loaded) {\nreturn (\n<View style={styles.loadingContainer}>\n<ActivityIndicator\n@@ -76,7 +76,7 @@ class Multimedia extends React.PureComponent<Props, State> {\n}\nonLoad = () => {\n- this.setState({ loadingStatus: \"inactive\" });\n+ this.setState({ loaded: true });\n}\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Don't reload Multimedia if already loaded |
129,187 | 19.03.2019 13:43:57 | 14,400 | 83ab8733c726d915f5450a1064470826de748253 | [native] Pass navigate function to MultimediaMessageMultimedia | [
{
"change_type": "MODIFY",
"old_path": "native/chat/compose-thread-button.react.js",
"new_path": "native/chat/compose-thread-button.react.js",
"diff": "// @flow\n-import type { NavigationParams } from 'react-navigation';\n+import type { Navigate } from '../navigation/route-names';\n-import React from 'react';\n+import * as React from 'react';\nimport { StyleSheet } from 'react-native';\nimport Icon from 'react-native-vector-icons/Ionicons';\nimport PropTypes from 'prop-types';\n@@ -10,13 +10,9 @@ import PropTypes from 'prop-types';\nimport { ComposeThreadRouteName } from '../navigation/route-names';\nimport Button from '../components/button.react';\n-type Props = {\n- navigate: ({\n- routeName: string,\n- params?: NavigationParams,\n- key?: string,\n- }) => bool,\n-};\n+type Props = {|\n+ navigate: Navigate,\n+|};\nclass ComposeThreadButton extends React.PureComponent<Props> {\nstatic propTypes = {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-container.react.js",
"new_path": "native/chat/message-list-container.react.js",
"diff": "@@ -198,6 +198,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n<MessageList\nthreadInfo={threadInfo}\nmessageListData={listDataWithHeights}\n+ navigate={this.props.navigation.navigate}\n/>\n);\n} else {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-header-title.react.js",
"new_path": "native/chat/message-list-header-title.react.js",
"diff": "// @flow\n-import type { NavigationParams } from 'react-navigation';\nimport type { ThreadInfo } from 'lib/types/thread-types';\nimport { threadInfoPropType } from 'lib/types/thread-types';\n+import type { Navigate } from '../navigation/route-names';\n-import React from 'react';\n+import * as React from 'react';\nimport { View, Text, StyleSheet, Platform } from 'react-native';\nimport PropTypes from 'prop-types';\nimport Icon from 'react-native-vector-icons/Ionicons';\n@@ -13,14 +13,10 @@ import { HeaderTitle } from 'react-navigation';\nimport Button from '../components/button.react';\nimport { ThreadSettingsRouteName } from '../navigation/route-names';\n-type Props = {\n+type Props = {|\nthreadInfo: ThreadInfo,\n- navigate: ({\n- routeName: string,\n- params?: NavigationParams,\n- key?: string,\n- }) => bool,\n-};\n+ navigate: Navigate,\n+|};\nclass MessageListHeaderTitle extends React.PureComponent<Props> {\nstatic propTypes = {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -7,6 +7,7 @@ import type { ViewToken } from 'react-native/Libraries/Lists/ViewabilityHelper';\nimport type { FetchMessageInfosPayload } from 'lib/types/message-types';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type { ChatMessageItemWithHeight } from './message-list-container.react';\n+import type { Navigate } from '../navigation/route-names';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n@@ -36,6 +37,7 @@ import ListLoadingIndicator from '../list-loading-indicator.react';\ntype Props = {|\nthreadInfo: ThreadInfo,\nmessageListData: $ReadOnlyArray<ChatMessageItemWithHeight>,\n+ navigate: Navigate,\n// Redux state\nviewerID: ?string,\nstartReached: bool,\n@@ -58,6 +60,7 @@ class MessageList extends React.PureComponent<Props, State> {\nstatic propTypes = {\nthreadInfo: threadInfoPropType.isRequired,\nmessageListData: PropTypes.arrayOf(chatMessageItemPropType).isRequired,\n+ navigate: PropTypes.func.isRequired,\nviewerID: PropTypes.string,\nstartReached: PropTypes.bool.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\n@@ -123,6 +126,7 @@ class MessageList extends React.PureComponent<Props, State> {\n<Message\nitem={messageInfoItem}\nfocused={focused}\n+ navigate={this.props.navigate}\ntoggleFocus={this.toggleMessageFocus}\n/>\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message.react.js",
"new_path": "native/chat/message.react.js",
"diff": "@@ -10,8 +10,9 @@ import type {\nChatMultimediaMessageInfoItem,\n} from './multimedia-message.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\n+import type { Navigate } from '../navigation/route-names';\n-import React from 'react';\n+import * as React from 'react';\nimport { Text, StyleSheet, View, LayoutAnimation } from 'react-native';\nimport _isEqual from 'lodash/fp/isEqual';\nimport invariant from 'invariant';\n@@ -56,6 +57,7 @@ function messageItemHeight(\ntype Props = {|\nitem: ChatMessageInfoItemWithHeight,\nfocused: bool,\n+ navigate: Navigate,\ntoggleFocus: (messageKey: string) => void,\n|};\nclass Message extends React.PureComponent<Props> {\n@@ -63,6 +65,7 @@ class Message extends React.PureComponent<Props> {\nstatic propTypes = {\nitem: chatMessageItemPropType.isRequired,\nfocused: PropTypes.bool.isRequired,\n+ navigate: PropTypes.func.isRequired,\ntoggleFocus: PropTypes.func.isRequired,\n};\n@@ -97,6 +100,7 @@ class Message extends React.PureComponent<Props> {\nmessage = (\n<MultimediaMessage\nitem={this.props.item}\n+ navigate={this.props.navigate}\ntoggleFocus={this.props.toggleFocus}\n/>\n);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/chat/multimedia-message-multimedia.react.js",
"diff": "+// @flow\n+\n+import { type Media, mediaPropType } from 'lib/types/media-types';\n+import type { ImageStyle } from '../types/styles';\n+import type { Navigate } from '../navigation/route-names';\n+\n+import * as React from 'react';\n+import PropTypes from 'prop-types';\n+import { TouchableWithoutFeedback } from 'react-native';\n+\n+import Multimedia from './multimedia.react';\n+\n+type Props = {|\n+ media: Media,\n+ navigate: Navigate,\n+ style?: ImageStyle,\n+|};\n+class MultimediaMessageMultimedia extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ media: mediaPropType.isRequired,\n+ navigate: PropTypes.func.isRequired,\n+ };\n+\n+ render() {\n+ const { media, style } = this.props;\n+ return (\n+ <TouchableWithoutFeedback>\n+ <Multimedia media={media} style={style} />\n+ </TouchableWithoutFeedback>\n+ );\n+ }\n+\n+}\n+\n+export default MultimediaMessageMultimedia;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message.react.js",
"new_path": "native/chat/multimedia-message.react.js",
"diff": "@@ -8,6 +8,7 @@ import type {\nimport type { Media } from 'lib/types/media-types';\nimport type { ImageStyle } from '../types/styles';\nimport type { ThreadInfo } from 'lib/types/thread-types';\n+import type { Navigate } from '../navigation/route-names';\nimport * as React from 'react';\nimport {\n@@ -21,7 +22,7 @@ import PropTypes from 'prop-types';\nimport { messageKey } from 'lib/shared/message-utils';\nimport ComposedMessage from './composed-message.react';\n-import Multimedia from './multimedia.react';\n+import MultimediaMessageMultimedia from './multimedia-message-multimedia.react';\nexport type ChatMultimediaMessageInfoItem = {|\nitemType: \"message\",\n@@ -92,12 +93,14 @@ function multimediaMessageItemHeight(\ntype Props = {|\nitem: ChatMultimediaMessageInfoItem,\n+ navigate: Navigate,\ntoggleFocus: (messageKey: string) => void,\n|};\nclass MultimediaMessage extends React.PureComponent<Props> {\nstatic propTypes = {\nitem: chatMessageItemPropType.isRequired,\n+ navigate: PropTypes.func.isRequired,\ntoggleFocus: PropTypes.func.isRequired,\n};\n@@ -120,7 +123,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\nborderRadius={16}\nstyle={styles.row}\n>\n- <TouchableWithoutFeedback onPress={this.onPress}>\n+ <TouchableWithoutFeedback onLongPress={this.onLongPress}>\n<View style={[heightStyle, styles.container]}>\n{this.renderContent()}\n</View>\n@@ -201,15 +204,16 @@ class MultimediaMessage extends React.PureComponent<Props> {\nrenderImage(media: Media, style?: ImageStyle): React.Node {\nreturn (\n- <Multimedia\n+ <MultimediaMessageMultimedia\nmedia={media}\n+ navigate={this.props.navigate}\nstyle={style}\nkey={media.id}\n/>\n);\n}\n- onPress = () => {\n+ onLongPress = () => {\nthis.props.toggleFocus(messageKey(this.props.item.messageInfo));\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-child-thread.react.js",
"new_path": "native/chat/settings/thread-settings-child-thread.react.js",
"diff": "// @flow\nimport { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\n-import type {\n- NavigationParams,\n- NavigationNavigateAction,\n-} from 'react-navigation';\n+import type { Navigate } from '../../navigation/route-names';\n-import React from 'react';\n+import * as React from 'react';\nimport { Text, StyleSheet, View, Platform } from 'react-native';\nimport PropTypes from 'prop-types';\n@@ -17,12 +14,7 @@ import ThreadVisibility from '../../components/thread-visibility.react';\ntype Props = {|\nthreadInfo: ThreadInfo,\n- navigate: ({\n- routeName: string,\n- params?: NavigationParams,\n- action?: NavigationNavigateAction,\n- key?: string,\n- }) => bool,\n+ navigate: Navigate,\nlastListItem: bool,\n|};\nclass ThreadSettingsChildThread extends React.PureComponent<Props> {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-color.react.js",
"new_path": "native/chat/settings/thread-settings-color.react.js",
"diff": "@@ -7,9 +7,9 @@ import {\nimport type { LoadingStatus } from 'lib/types/loading-types';\nimport { loadingStatusPropType } from 'lib/types/loading-types';\nimport type { AppState } from '../../redux-setup';\n-import type { NavigationParams } from 'react-navigation';\n+import type { Navigate } from '../../navigation/route-names';\n-import React from 'react';\n+import * as React from 'react';\nimport {\nText,\nStyleSheet,\n@@ -32,11 +32,7 @@ type Props = {|\ncolorEditValue: string,\nsetColorEditValue: (color: string) => void,\ncanChangeSettings: bool,\n- navigate: ({\n- routeName: string,\n- params?: NavigationParams,\n- key?: string,\n- }) => bool,\n+ navigate: Navigate,\n// Redux state\nloadingStatus: LoadingStatus,\n|};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-delete-thread.react.js",
"new_path": "native/chat/settings/thread-settings-delete-thread.react.js",
"diff": "// @flow\n-import {\n- type ThreadInfo,\n- threadInfoPropType,\n-} from 'lib/types/thread-types';\n-import type {\n- NavigationParams,\n- NavigationNavigateAction,\n-} from 'react-navigation';\n+import { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\n+import type { Navigate } from '../../navigation/route-names';\n-import React from 'react';\n+import * as React from 'react';\nimport { Text, StyleSheet, View, Platform } from 'react-native';\nimport PropTypes from 'prop-types';\n@@ -18,12 +12,7 @@ import { DeleteThreadRouteName } from '../../navigation/route-names';\ntype Props = {|\nthreadInfo: ThreadInfo,\n- navigate: ({\n- routeName: string,\n- params?: NavigationParams,\n- action?: NavigationNavigateAction,\n- key?: string,\n- }) => bool,\n+ navigate: Navigate,\ncanLeaveThread: bool,\n|};\nclass ThreadSettingsDeleteThread extends React.PureComponent<Props> {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-parent.react.js",
"new_path": "native/chat/settings/thread-settings-parent.react.js",
"diff": "// @flow\n-import type { ThreadInfo } from 'lib/types/thread-types';\n-import { threadInfoPropType } from 'lib/types/thread-types';\n+import { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\nimport type { AppState } from '../../redux-setup';\n-import type { NavigationParams } from 'react-navigation';\n+import type { Navigate } from '../../navigation/route-names';\n-import React from 'react';\n+import * as React from 'react';\nimport { Text, StyleSheet, View, Platform } from 'react-native';\nimport PropTypes from 'prop-types';\nimport invariant from 'invariant';\n@@ -19,11 +18,7 @@ import { ThreadSettingsRouteName } from '../../navigation/route-names';\ntype Props = {|\nthreadInfo: ThreadInfo,\n- navigate: ({\n- routeName: string,\n- params?: NavigationParams,\n- key?: string,\n- }) => bool,\n+ navigate: Navigate,\n// Redux state\nparentThreadInfo?: ?ThreadInfo,\n|};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings.react.js",
"new_path": "native/chat/settings/thread-settings.react.js",
"diff": "import type {\nNavigationScreenProp,\nNavigationLeafRoute,\n- NavigationParams,\n- NavigationNavigateAction,\n} from 'react-navigation';\nimport {\ntype ThreadInfo,\n@@ -15,6 +13,7 @@ import {\n} from 'lib/types/thread-types';\nimport type { AppState } from '../../redux-setup';\nimport type { CategoryType } from './thread-settings-category.react';\n+import type { Navigate } from '../../navigation/route-names';\nimport React from 'react';\nimport PropTypes from 'prop-types';\n@@ -80,13 +79,6 @@ type NavProp = NavigationScreenProp<{|\n|},\n|}>;\n-type Navigate = ({\n- routeName: string,\n- params?: NavigationParams,\n- action?: NavigationNavigateAction,\n- key?: string,\n-}) => bool;\n-\ntype ChatSettingsItem =\n| {|\nitemType: \"header\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/thread-settings-button.react.js",
"new_path": "native/chat/thread-settings-button.react.js",
"diff": "// @flow\n-import type { NavigationParams } from 'react-navigation';\nimport { type ThreadInfo, threadInfoPropType } from 'lib/types/thread-types';\n+import type { Navigate } from '../navigation/route-names';\n-import React from 'react';\n+import * as React from 'react';\nimport { StyleSheet } from 'react-native';\nimport Icon from 'react-native-vector-icons/Ionicons';\nimport PropTypes from 'prop-types';\n@@ -11,14 +11,10 @@ import PropTypes from 'prop-types';\nimport { ThreadSettingsRouteName } from '../navigation/route-names';\nimport Button from '../components/button.react';\n-type Props = {\n+type Props = {|\nthreadInfo: ThreadInfo,\n- navigate: ({\n- routeName: string,\n- params?: NavigationParams,\n- key?: string,\n- }) => bool,\n-};\n+ navigate: Navigate,\n+|};\nclass ThreadSettingsButton extends React.PureComponent<Props> {\nstatic propTypes = {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation/route-names.js",
"new_path": "native/navigation/route-names.js",
"diff": "// @flow\n+import type {\n+ NavigationParams,\n+ NavigationNavigateAction,\n+} from 'react-navigation';\n+\n+export type Navigate = ({\n+ routeName: string,\n+ params?: NavigationParams,\n+ action?: NavigationNavigateAction,\n+ key?: string,\n+}) => bool;\n+\nexport const AppRouteName = 'App';\nexport const ComposeThreadRouteName = 'ComposeThread';\nexport const DeleteThreadRouteName = 'DeleteThread';\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Pass navigate function to MultimediaMessageMultimedia |
129,187 | 18.03.2019 23:41:40 | 14,400 | cad871d7afa7ddfc5d786d81c05235340b848410 | [native] replaceChatRoute
Simplifies a good bit of navigation logic. | [
{
"change_type": "MODIFY",
"old_path": "native/navigation/navigation-setup.js",
"new_path": "native/navigation/navigation-setup.js",
"diff": "@@ -13,6 +13,7 @@ import type {\nNavigationRouter,\nNavigationRoute,\nNavigationTransitionProps,\n+ NavigationStateRoute,\n} from 'react-navigation';\nimport type { AppState } from '../redux-setup';\nimport type { SetSessionPayload } from 'lib/types/session-types';\n@@ -28,7 +29,6 @@ import {\n} from 'react-navigation';\nimport invariant from 'invariant';\nimport _findIndex from 'lodash/fp/findIndex';\n-import _includes from 'lodash/fp/includes';\nimport { Alert, BackHandler, Platform, Keyboard } from 'react-native';\nimport React from 'react';\nimport PropTypes from 'prop-types';\n@@ -218,14 +218,14 @@ const ReduxWrappedAppNavigator = connect((state: AppState) => ({\nconst RootNavigator = createStackNavigator(\n{\n- [LoggedOutModalRouteName]: { screen: LoggedOutModal },\n- [VerificationModalRouteName]: { screen: VerificationModal },\n- [AppRouteName]: { screen: ReduxWrappedAppNavigator },\n- [ThreadPickerModalRouteName]: { screen: ThreadPickerModal },\n- [AddUsersModalRouteName]: { screen: AddUsersModal },\n- [CustomServerModalRouteName]: { screen: CustomServerModal },\n- [ColorPickerModalRouteName]: { screen: ColorPickerModal },\n- [ComposeSubthreadModalRouteName]: { screen: ComposeSubthreadModal },\n+ [LoggedOutModalRouteName]: LoggedOutModal,\n+ [VerificationModalRouteName]: VerificationModal,\n+ [AppRouteName]: ReduxWrappedAppNavigator,\n+ [ThreadPickerModalRouteName]: ThreadPickerModal,\n+ [AddUsersModalRouteName]: AddUsersModal,\n+ [CustomServerModalRouteName]: CustomServerModal,\n+ [ColorPickerModalRouteName]: ColorPickerModal,\n+ [ComposeSubthreadModalRouteName]: ComposeSubthreadModal,\n},\n{\nheaderMode: 'none',\n@@ -368,7 +368,7 @@ function reduceNavInfo(\nreturn {\nstartDate: navInfoState.startDate,\nendDate: navInfoState.endDate,\n- navigationState: removeModals(\n+ navigationState: removeRootModals(\nnavInfoState.navigationState,\naccountModals,\n),\n@@ -508,13 +508,13 @@ function removeScreensFromStack<S: NavigationState>(\n};\n}\n-function removeModals(\n+function removeRootModals(\nstate: NavigationState,\nmodalRouteNames: string[],\n): NavigationState {\nconst newState = removeScreensFromStack(\nstate,\n- (route: NavigationRoute) => _includes(route.routeName)(modalRouteNames)\n+ (route: NavigationRoute) => modalRouteNames.includes(route.routeName)\n? \"remove\"\n: \"keep\",\n);\n@@ -528,38 +528,46 @@ function removeModals(\n}\nfunction resetNavInfoAndEnsureLoggedOutModalPresence(state: NavInfo): NavInfo {\n- const navigationState = { ...state.navigationState };\n+ let navigationState = { ...state.navigationState };\nnavigationState.routes[0] = defaultNavInfo.navigationState.routes[0];\n- const currentModalIndex =\n- _findIndex(['routeName', LoggedOutModalRouteName])(navigationState.routes);\n- if (currentModalIndex >= 0 && navigationState.index >= currentModalIndex) {\n- return {\n- startDate: defaultNavInfo.startDate,\n- endDate: defaultNavInfo.endDate,\n+\n+ let loggedOutModalFound = false;\n+ navigationState = removeScreensFromStack(\nnavigationState,\n+ (route: NavigationRoute) => {\n+ const { routeName } = route;\n+ if (routeName === LoggedOutModalRouteName) {\n+ loggedOutModalFound = true;\n+ }\n+ return routeName === AppRouteName || accountModals.includes(routeName)\n+ ? \"keep\"\n+ : \"remove\";\n+ },\n+ );\n+\n+ if (!loggedOutModalFound) {\n+ const [ appRoute, ...restRoutes ] = navigationState.routes;\n+ navigationState = {\n+ ...navigationState,\n+ index: navigationState.index + 1,\n+ routes: [\n+ appRoute,\n+ { key: 'LoggedOutModal', routeName: LoggedOutModalRouteName },\n+ ...restRoutes,\n+ ],\n};\n- } else if (currentModalIndex >= 0) {\n- return {\n- startDate: defaultNavInfo.startDate,\n- endDate: defaultNavInfo.endDate,\n- navigationState: {\n+ if (navigationState.index === 1) {\n+ navigationState = {\n...navigationState,\n- index: currentModalIndex,\nisTransitioning: true,\n- },\n};\n}\n+ }\n+\nreturn {\nstartDate: defaultNavInfo.startDate,\nendDate: defaultNavInfo.endDate,\n- navigationState: {\n- index: navigationState.routes.length,\n- routes: [\n- ...navigationState.routes,\n- { key: 'LoggedOutModal', routeName: LoggedOutModalRouteName },\n- ],\n- isTransitioning: true,\n- },\n+ navigationState,\n};\n}\n@@ -596,14 +604,37 @@ function logOutIfCookieInvalidated(\nreturn newState;\n}\n+function replaceChatRoute(\n+ state: NavigationState,\n+ replaceFunc: (chatRoute: NavigationStateRoute) => NavigationStateRoute,\n+): NavigationState {\n+ const tabRoute = assertNavigationRouteNotLeafNode(state.routes[0]);\n+ const chatRoute = assertNavigationRouteNotLeafNode(tabRoute.routes[1]);\n+\n+ const newChatRoute = replaceFunc(chatRoute);\n+ if (newChatRoute === chatRoute) {\n+ return state;\n+ }\n+\n+ const newTabRoutes = [ ...tabRoute.routes ];\n+ newTabRoutes[1] = newChatRoute;\n+ const newTabRoute = { ...tabRoute, routes: newTabRoutes };\n+\n+ const newRootRoutes = [ ...state.routes ];\n+ newRootRoutes[0] = newTabRoute;\n+ return {\n+ ...state,\n+ routes: newRootRoutes,\n+ isTransitioning: true,\n+ };\n+}\n+\nfunction popChatScreensForThreadID(\nstate: NavigationState,\nactionPayload: LeaveThreadPayload,\n): NavigationState {\n- const appRoute = assertNavigationRouteNotLeafNode(state.routes[0]);\n- const chatRoute = assertNavigationRouteNotLeafNode(appRoute.routes[1]);\n-\n- const newChatRoute = removeScreensFromStack(\n+ const replaceFunc =\n+ (chatRoute: NavigationStateRoute) => removeScreensFromStack(\nchatRoute,\n(route: NavigationRoute) => {\nif (\n@@ -621,29 +652,15 @@ function popChatScreensForThreadID(\nreturn \"remove\";\n},\n);\n- if (newChatRoute === chatRoute) {\n- return state;\n- }\n-\n- const newAppSubRoutes = [ ...appRoute.routes ];\n- newAppSubRoutes[1] = newChatRoute;\n- const newRootSubRoutes = [ ...state.routes ];\n- newRootSubRoutes[0] = { ...appRoute, routes: newAppSubRoutes };\n- return {\n- ...state,\n- routes: newRootSubRoutes,\n- isTransitioning: true,\n- };\n+ return replaceChatRoute(state, replaceFunc);\n}\nfunction filterChatScreensForThreadInfos(\nstate: NavigationState,\nthreadInfos: {[id: string]: RawThreadInfo},\n): NavigationState {\n- const appRoute = assertNavigationRouteNotLeafNode(state.routes[0]);\n- const chatRoute = assertNavigationRouteNotLeafNode(appRoute.routes[1]);\n-\n- const newChatRoute = removeScreensFromStack(\n+ const replaceFunc =\n+ (chatRoute: NavigationStateRoute) => removeScreensFromStack(\nchatRoute,\n(route: NavigationRoute) => {\nif (\n@@ -660,19 +677,7 @@ function filterChatScreensForThreadInfos(\nreturn \"remove\";\n},\n);\n- if (newChatRoute === chatRoute) {\n- return state;\n- }\n-\n- const newAppSubRoutes = [ ...appRoute.routes ];\n- newAppSubRoutes[1] = newChatRoute;\n- const newRootSubRoutes = [ ...state.routes ];\n- newRootSubRoutes[0] = { ...appRoute, routes: newAppSubRoutes };\n- return {\n- ...state,\n- routes: newRootSubRoutes,\n- isTransitioning: true,\n- };\n+ return replaceChatRoute(state, replaceFunc);\n}\nfunction handleNewThread(\n@@ -686,31 +691,27 @@ function handleNewThread(\nviewerID,\nuserInfos,\n);\n- const appRoute = assertNavigationRouteNotLeafNode(state.routes[0]);\n- const chatRoute = assertNavigationRouteNotLeafNode(appRoute.routes[1]);\n-\n+ const replaceFunc = (chatRoute: NavigationStateRoute) => {\nconst newChatRoute = removeScreensFromStack(\nchatRoute,\n(route: NavigationRoute) => route.routeName === ComposeThreadRouteName\n? \"remove\"\n: \"break\",\n);\n- newChatRoute.routes.push({\n+ return {\n+ ...newChatRoute,\n+ routes: [\n+ ...newChatRoute.routes,\n+ {\nkey: 'NewThreadMessageList',\nrouteName: MessageListRouteName,\nparams: { threadInfo },\n- });\n- newChatRoute.index = newChatRoute.routes.length - 1;\n-\n- const newAppSubRoutes = [ ...appRoute.routes ];\n- newAppSubRoutes[1] = newChatRoute;\n- const newRootSubRoutes = [ ...state.routes ];\n- newRootSubRoutes[0] = { ...appRoute, routes: newAppSubRoutes };\n- return {\n- ...state,\n- routes: newRootSubRoutes,\n- isTransitioning: true,\n+ },\n+ ],\n+ index: newChatRoute.routes.length,\n+ };\n};\n+ return replaceChatRoute(state, replaceFunc);\n}\nfunction replaceChatStackWithThread(\n@@ -724,31 +725,27 @@ function replaceChatStackWithThread(\nviewerID,\nuserInfos,\n);\n- const appRoute = assertNavigationRouteNotLeafNode(state.routes[0]);\n- const chatRoute = assertNavigationRouteNotLeafNode(appRoute.routes[1]);\n-\n+ const replaceFunc = (chatRoute: NavigationStateRoute) => {\nconst newChatRoute = removeScreensFromStack(\nchatRoute,\n(route: NavigationRoute) => route.routeName === ChatThreadListRouteName\n? \"break\"\n: \"remove\",\n);\n- newChatRoute.routes.push({\n+ return {\n+ ...newChatRoute,\n+ routes: [\n+ ...newChatRoute.routes,\n+ {\nkey: 'NewThreadMessageList',\nrouteName: MessageListRouteName,\nparams: { threadInfo },\n- });\n- newChatRoute.index = 1;\n-\n- const newAppSubRoutes = [ ...appRoute.routes ];\n- newAppSubRoutes[1] = newChatRoute;\n- const newRootSubRoutes = [ ...state.routes ];\n- newRootSubRoutes[0] = { ...appRoute, routes: newAppSubRoutes };\n- return {\n- ...state,\n- routes: newRootSubRoutes,\n- isTransitioning: true,\n+ },\n+ ],\n+ index: newChatRoute.routes.length,\n+ };\n};\n+ return replaceChatRoute(state, replaceFunc);\n}\nfunction handleNotificationPress(\n@@ -757,14 +754,14 @@ function handleNotificationPress(\nviewerID: ?string,\nuserInfos: {[id: string]: UserInfo},\n): NavigationState {\n- const appRoute = assertNavigationRouteNotLeafNode(state.routes[0]);\n- const chatRoute = assertNavigationRouteNotLeafNode(appRoute.routes[1]);\n+ const tabRoute = assertNavigationRouteNotLeafNode(state.routes[0]);\n+ const chatRoute = assertNavigationRouteNotLeafNode(tabRoute.routes[1]);\nconst currentChatRoute = chatRoute.routes[chatRoute.index];\nif (\ncurrentChatRoute.routeName === MessageListRouteName &&\ngetThreadIDFromParams(currentChatRoute) === payload.rawThreadInfo.id &&\n- appRoute.index === 1\n+ tabRoute.index === 1\n) {\nreturn state;\n}\n@@ -776,11 +773,17 @@ function handleNotificationPress(\nviewerID,\nuserInfos,\n);\n- newState.routes[0] = {\n- ...assertNavigationRouteNotLeafNode(newState.routes[0]),\n- index: 1,\n+\n+ const newTabRoute = assertNavigationRouteNotLeafNode(newState.routes[0]);\n+ const updatedTabRoute = { ...newTabRoute, index: 1 };\n+\n+ const updatedRootRoutes = [ ...newState.routes ];\n+ updatedRootRoutes[0] = updatedTabRoute;\n+ return {\n+ ...newState,\n+ routes: updatedRootRoutes,\n+ isTransitioning: true,\n};\n- return newState;\n}\nconst threadInfo = threadInfoFromRawThreadInfo(\n@@ -800,13 +803,16 @@ function handleNotificationPress(\n],\nindex: chatRoute.routes.length,\n};\n- const newAppSubRoutes = [ ...appRoute.routes ];\n- newAppSubRoutes[1] = newChatRoute;\n- const newRootSubRoutes = [ ...state.routes ];\n- newRootSubRoutes[0] = { ...appRoute, routes: newAppSubRoutes, index: 1 };\n+\n+ const newTabRoutes = [ ...tabRoute.routes ];\n+ newTabRoutes[1] = newChatRoute;\n+ const newTabRoute = { ...tabRoute, routes: newTabRoutes, index: 1 };\n+\n+ const newRootRoutes = [ ...state.routes ];\n+ newRootRoutes[0] = newTabRoute;\nreturn {\n...state,\n- routes: newRootSubRoutes,\n+ routes: newRootRoutes,\nisTransitioning: true,\n};\n}\n@@ -816,5 +822,6 @@ export {\ndefaultNavInfo,\nreduceNavInfo,\nremoveScreensFromStack,\n+ replaceChatRoute,\nresetNavInfoAndEnsureLoggedOutModalPresence,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux-setup.js",
"new_path": "native/redux-setup.js",
"diff": "@@ -69,6 +69,7 @@ import {\ndefaultNavInfo,\nreduceNavInfo,\nremoveScreensFromStack,\n+ replaceChatRoute,\nresetNavInfoAndEnsureLoggedOutModalPresence,\n} from './navigation/navigation-setup';\nimport {\n@@ -165,8 +166,8 @@ const defaultState = ({\nfunction chatRouteFromNavInfo(navInfo: NavInfo): NavigationStateRoute {\nconst navState = navInfo.navigationState;\n- const appRoute = assertNavigationRouteNotLeafNode(navState.routes[0]);\n- return assertNavigationRouteNotLeafNode(appRoute.routes[1]);\n+ const tabRoute = assertNavigationRouteNotLeafNode(navState.routes[0]);\n+ return assertNavigationRouteNotLeafNode(tabRoute.routes[1]);\n}\nfunction reducer(state: AppState = defaultState, action: *) {\n@@ -284,26 +285,20 @@ function reducer(state: AppState = defaultState, action: *) {\n// navigate back to that compose thread screen, but instead, since the\n// user's intent has ostensibly already been satisfied, we will pop up\n// to the screen right before that one.\n- const newChatRoute = removeScreensFromStack(\n+ const replaceFunc =\n+ (chatRoute: NavigationStateRoute) => removeScreensFromStack(\nchatRoute,\n(route: NavigationRoute) => route.key === currentChatSubroute.key\n? \"remove\"\n: \"keep\",\n);\n-\n- const appRoute =\n- assertNavigationRouteNotLeafNode(navInfo.navigationState.routes[0]);\n- const newAppSubRoutes = [ ...appRoute.routes ];\n- newAppSubRoutes[1] = newChatRoute;\n- const newRootSubRoutes = [ ...navInfo.navigationState.routes ];\n- newRootSubRoutes[0] = { ...appRoute, routes: newAppSubRoutes };\nnavInfo = {\nstartDate: navInfo.startDate,\nendDate: navInfo.endDate,\n- navigationState: {\n- ...navInfo.navigationState,\n- routes: newRootSubRoutes,\n- },\n+ navigationState: replaceChatRoute(\n+ navInfo.navigationState,\n+ replaceFunc,\n+ ),\n};\n}\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] replaceChatRoute
Simplifies a good bit of navigation logic. |
129,187 | 20.03.2019 13:33:32 | 14,400 | e5e5450a4dbce94cb6bb01f2bfec5270b0e4c119 | [native] XCode changed some stuff after linking FastImage | [
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"diff": "};\nobjectVersion = 46;\nobjects = {\n+\n/* Begin PBXBuildFile section */\n00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };\n00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };\n8894ACD632254222B23F69E2 /* Ionicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 4ACC468F28D944F293B91ACC /* Ionicons.ttf */; };\n9985FC0D9B2A43E49A4C1789 /* FontAwesome.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 4AB1FC0EFD3A4ED1A082E32F /* FontAwesome.ttf */; };\nA1145AA76F5B4EF5B3ACB31D /* MaterialIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = E4E90F44E9F4420080594671 /* MaterialIcons.ttf */; };\n+ A4B3D66697E04C11B4167EE7 /* libFastImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 47C86914FEF44D79AD04F880 /* libFastImage.a */; };\nA6EF57DD8BDA4D43812D0B13 /* libRNScreens.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7AAA81E566EC47C883CDFA61 /* libRNScreens.a */; };\nAFA44E75249D4766A4ED74C7 /* Octicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 2D04F3CCBAFF4A8184206FAC /* Octicons.ttf */; };\nBBC287C467984DA6BF85800E /* libSplashScreen.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B6A1FF570694BFCB0D65D0E /* libSplashScreen.a */; };\nEFBA858A8D2B4909A08D9FE6 /* libRNGestureHandler.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E0952482A8094CE88F96C0EB /* libRNGestureHandler.a */; };\nFA7F2215AD7646E2BE985BF3 /* SimpleLineIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = AE31AFFF88FB4112A29ADE33 /* SimpleLineIcons.ttf */; };\n- A4B3D66697E04C11B4167EE7 /* libFastImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 47C86914FEF44D79AD04F880 /* libFastImage.a */; };\n/* End PBXBuildFile section */\n/* Begin PBXContainerItemProxy section */\nremoteGlobalIDString = 139D7E881E25C6D100323FB7;\nremoteInfo = \"double-conversion\";\n};\n+ 7F347C192242A05200F313CE /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = 7FA344AAF237451CB8B3424B /* FastImage.xcodeproj */;\n+ proxyType = 2;\n+ remoteGlobalIDString = A287971D1DE0C0A60081BDFA;\n+ remoteInfo = FastImage;\n+ };\n7F3DD3FE20521A4B00A0D652 /* PBXContainerItemProxy */ = {\nisa = PBXContainerItemProxy;\ncontainerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */;\n2D04F3CCBAFF4A8184206FAC /* Octicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Octicons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Octicons.ttf\"; sourceTree = \"<group>\"; };\n2D16E6891FA4F8E400B85C8A /* libReact.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libReact.a; sourceTree = BUILT_PRODUCTS_DIR; };\n3430816A291640AEACA13234 /* EvilIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = EvilIcons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/EvilIcons.ttf\"; sourceTree = \"<group>\"; };\n+ 47C86914FEF44D79AD04F880 /* libFastImage.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libFastImage.a; sourceTree = \"<group>\"; };\n4AB1FC0EFD3A4ED1A082E32F /* FontAwesome.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = FontAwesome.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/FontAwesome.ttf\"; sourceTree = \"<group>\"; };\n4ACC468F28D944F293B91ACC /* Ionicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Ionicons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Ionicons.ttf\"; sourceTree = \"<group>\"; };\n5E91572D1DD0AC6500FF2AA8 /* RCTAnimation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTAnimation.xcodeproj; path = \"../node_modules/react-native/Libraries/NativeAnimation/RCTAnimation.xcodeproj\"; sourceTree = \"<group>\"; };\n78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTLinking.xcodeproj; path = \"../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj\"; sourceTree = \"<group>\"; };\n7AAA81E566EC47C883CDFA61 /* libRNScreens.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNScreens.a; sourceTree = \"<group>\"; };\n7F761E292201141E001B6FB7 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };\n+ 7FA344AAF237451CB8B3424B /* FastImage.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = FastImage.xcodeproj; path = \"../node_modules/react-native-fast-image/ios/FastImage.xcodeproj\"; sourceTree = \"<group>\"; };\n7FB58ABB1E7F6BC600B4C1B1 /* Anaheim-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"Anaheim-Regular.ttf\"; sourceTree = \"<group>\"; };\n7FB58ABC1E7F6BC600B4C1B1 /* OpenSans-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"OpenSans-Regular.ttf\"; sourceTree = \"<group>\"; };\n7FB58ABD1E7F6BC600B4C1B1 /* OpenSans-Semibold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = \"OpenSans-Semibold.ttf\"; sourceTree = \"<group>\"; };\nEA40FBBA484449FAA8915A48 /* Foundation.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Foundation.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Foundation.ttf\"; sourceTree = \"<group>\"; };\nEBD8879422144B0188A8336F /* Zocial.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Zocial.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Zocial.ttf\"; sourceTree = \"<group>\"; };\nED28C047C454400D87062E8C /* RNGestureHandler.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = RNGestureHandler.xcodeproj; path = \"../node_modules/react-native-gesture-handler/ios/RNGestureHandler.xcodeproj\"; sourceTree = \"<group>\"; };\n- 7FA344AAF237451CB8B3424B /* FastImage.xcodeproj */ = {isa = PBXFileReference; name = \"FastImage.xcodeproj\"; path = \"../node_modules/react-native-fast-image/ios/FastImage.xcodeproj\"; sourceTree = \"<group>\"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };\n- 47C86914FEF44D79AD04F880 /* libFastImage.a */ = {isa = PBXFileReference; name = \"libFastImage.a\"; path = \"libFastImage.a\"; sourceTree = \"<group>\"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };\n/* End PBXFileReference section */\n/* Begin PBXFrameworksBuildPhase section */\nname = Products;\nsourceTree = \"<group>\";\n};\n+ 7F347C162242A05200F313CE /* Products */ = {\n+ isa = PBXGroup;\n+ children = (\n+ 7F347C1A2242A05200F313CE /* libFastImage.a */,\n+ );\n+ name = Products;\n+ sourceTree = \"<group>\";\n+ };\n7F3DD40720521A4C00A0D652 /* Products */ = {\nisa = PBXGroup;\nchildren = (\n8B6A1FF570694BFCB0D65D0E /* libSplashScreen.a */,\nE0952482A8094CE88F96C0EB /* libRNGestureHandler.a */,\n7AAA81E566EC47C883CDFA61 /* libRNScreens.a */,\n+ 47C86914FEF44D79AD04F880 /* libFastImage.a */,\n);\nname = \"Recovered References\";\nsourceTree = \"<group>\";\nproductRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;\nprojectDirPath = \"\";\nprojectReferences = (\n+ {\n+ ProductGroup = 7F347C162242A05200F313CE /* Products */;\n+ ProjectRef = 7FA344AAF237451CB8B3424B /* FastImage.xcodeproj */;\n+ },\n{\nProductGroup = 7FB58AD01E80C21000B4C1B1 /* Products */;\nProjectRef = E7D7D614C3184B1BB95EE661 /* OnePassword.xcodeproj */;\nremoteRef = 7F033BB11F01B5E100700D63 /* PBXContainerItemProxy */;\nsourceTree = BUILT_PRODUCTS_DIR;\n};\n+ 7F347C1A2242A05200F313CE /* libFastImage.a */ = {\n+ isa = PBXReferenceProxy;\n+ fileType = archive.ar;\n+ path = libFastImage.a;\n+ remoteRef = 7F347C192242A05200F313CE /* PBXContainerItemProxy */;\n+ sourceTree = BUILT_PRODUCTS_DIR;\n+ };\n7F3DD3FF20521A4B00A0D652 /* libReact.a */ = {\nisa = PBXReferenceProxy;\nfileType = archive.ar;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] XCode changed some stuff after linking FastImage |
129,187 | 20.03.2019 14:04:41 | 14,400 | 5aed43d5f13df00326f7e6d43454b55603c04b2e | [native] Make horizontal/vertical margin in MultimediaMessage image grid match | [
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message.react.js",
"new_path": "native/chat/multimedia-message.react.js",
"diff": "@@ -162,8 +162,8 @@ class MultimediaMessage extends React.PureComponent<Props> {\n{this.renderImage(two, styles.topRightImage)}\n</View>\n<View style={styles.row}>\n- {this.renderImage(three, styles.bottomLeftImage)}\n- {this.renderImage(four, styles.bottomRightImage)}\n+ {this.renderImage(three, styles.leftImage)}\n+ {this.renderImage(four, styles.rightImage)}\n</View>\n</View>\n);\n@@ -219,7 +219,8 @@ class MultimediaMessage extends React.PureComponent<Props> {\n}\n-const spaceBetweenImages = 2;\n+const horizontalSpaceBetweenImages = 2;\n+const verticalSpaceBetweenImages = 4;\nconst styles = StyleSheet.create({\ncontainer: {\nflex: 1,\n@@ -237,40 +238,40 @@ const styles = StyleSheet.create({\nflexDirection: 'row',\n},\nleftImage: {\n- marginRight: spaceBetweenImages,\n+ marginRight: horizontalSpaceBetweenImages,\n},\ncenterImage: {\n- marginLeft: spaceBetweenImages,\n- marginRight: spaceBetweenImages,\n+ marginLeft: horizontalSpaceBetweenImages,\n+ marginRight: horizontalSpaceBetweenImages,\n},\nrightImage: {\n- marginLeft: spaceBetweenImages,\n+ marginLeft: horizontalSpaceBetweenImages,\n},\ntopLeftImage: {\n- marginRight: spaceBetweenImages,\n- marginBottom: spaceBetweenImages,\n+ marginRight: horizontalSpaceBetweenImages,\n+ marginBottom: verticalSpaceBetweenImages,\n},\ntopCenterImage: {\n- marginLeft: spaceBetweenImages,\n- marginRight: spaceBetweenImages,\n- marginBottom: spaceBetweenImages,\n+ marginLeft: horizontalSpaceBetweenImages,\n+ marginRight: horizontalSpaceBetweenImages,\n+ marginBottom: verticalSpaceBetweenImages,\n},\ntopRightImage: {\n- marginLeft: spaceBetweenImages,\n- marginBottom: spaceBetweenImages,\n+ marginLeft: horizontalSpaceBetweenImages,\n+ marginBottom: verticalSpaceBetweenImages,\n},\n- bottomLeftImage: {\n- marginRight: spaceBetweenImages,\n- marginTop: spaceBetweenImages,\n+ middleLeftImage: {\n+ marginRight: horizontalSpaceBetweenImages,\n+ marginBottom: verticalSpaceBetweenImages,\n},\n- bottomCenterImage: {\n- marginLeft: spaceBetweenImages,\n- marginRight: spaceBetweenImages,\n- marginTop: spaceBetweenImages,\n+ middleCenterImage: {\n+ marginRight: horizontalSpaceBetweenImages,\n+ marginLeft: horizontalSpaceBetweenImages,\n+ marginBottom: verticalSpaceBetweenImages,\n},\n- bottomRightImage: {\n- marginLeft: spaceBetweenImages,\n- marginTop: spaceBetweenImages,\n+ middleRightImage: {\n+ marginLeft: horizontalSpaceBetweenImages,\n+ marginBottom: verticalSpaceBetweenImages,\n},\n});\nconst rowStyles = {\n@@ -279,12 +280,12 @@ const rowStyles = {\nstyles.topCenterImage,\nstyles.topRightImage,\n],\n- bottom: [\n- styles.bottomLeftImage,\n- styles.bottomCenterImage,\n- styles.bottomRightImage,\n- ],\nmiddle: [\n+ styles.middleLeftImage,\n+ styles.middleCenterImage,\n+ styles.middleRightImage,\n+ ],\n+ bottom: [\nstyles.leftImage,\nstyles.centerImage,\nstyles.rightImage,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Make horizontal/vertical margin in MultimediaMessage image grid match |
129,187 | 20.03.2019 16:45:39 | 14,400 | f33427156256d5d9c69b6ef1924435869cc10e59 | [native] MultimediaModal
I took some time to simplify both the `renderContent` and `multimediaMessageContentHeights` logic. | [
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message-multimedia.react.js",
"new_path": "native/chat/multimedia-message-multimedia.react.js",
"diff": "import { type Media, mediaPropType } from 'lib/types/media-types';\nimport type { ImageStyle } from '../types/styles';\n-import type { Navigate } from '../navigation/route-names';\n+import {\n+ type Navigate,\n+ MultimediaModalRouteName,\n+} from '../navigation/route-names';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n-import { TouchableWithoutFeedback } from 'react-native';\n+import { View, TouchableWithoutFeedback, StyleSheet } from 'react-native';\n-import Multimedia from './multimedia.react';\n+import Multimedia from '../media/multimedia.react';\ntype Props = {|\nmedia: Media,\n@@ -25,12 +28,28 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props> {\nrender() {\nconst { media, style } = this.props;\nreturn (\n- <TouchableWithoutFeedback>\n- <Multimedia media={media} style={style} />\n+ <TouchableWithoutFeedback onPress={this.onPress}>\n+ <View style={[styles.expand, style]}>\n+ <Multimedia media={media} style={styles.expand} />\n+ </View>\n</TouchableWithoutFeedback>\n);\n}\n+ onPress = () => {\n+ const { media, navigate } = this.props;\n+ navigate({\n+ routeName: MultimediaModalRouteName,\n+ params: { media },\n+ });\n}\n+}\n+\n+const styles = StyleSheet.create({\n+ expand: {\n+ flex: 1,\n+ },\n+});\n+\nexport default MultimediaMessageMultimedia;\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message.react.js",
"new_path": "native/chat/multimedia-message.react.js",
"diff": "@@ -18,6 +18,7 @@ import {\nView,\n} from 'react-native';\nimport PropTypes from 'prop-types';\n+import invariant from 'invariant';\nimport { messageKey } from 'lib/shared/message-utils';\n@@ -36,34 +37,45 @@ export type ChatMultimediaMessageInfoItem = {|\ncontentHeight: number,\n|};\n+function getMediaPerRow(mediaCount: number) {\n+ if (mediaCount === 0) {\n+ return 0; // ???\n+ } else if (mediaCount === 1) {\n+ return 1;\n+ } else if (mediaCount === 2) {\n+ return 2;\n+ } else if (mediaCount === 3) {\n+ return 3;\n+ } else if (mediaCount === 4) {\n+ return 2;\n+ } else {\n+ return 3;\n+ }\n+}\n+\nfunction multimediaMessageContentHeight(\nmessageInfo: MultimediaMessageInfo,\ncomposedMessageMaxWidth: number,\n-) {\n- let contentHeight;\n+): number {\n+ invariant(messageInfo.media.length > 0, \"should have media\");\nif (messageInfo.media.length === 1) {\nconst [ media ] = messageInfo.media;\n- const mediaDimensions = media.dimensions;\n- if (composedMessageMaxWidth >= mediaDimensions.width) {\n- contentHeight = mediaDimensions.height;\n- } else {\n- contentHeight = mediaDimensions.height *\n- composedMessageMaxWidth / mediaDimensions.width;\n- }\n- if (contentHeight < 50) {\n- contentHeight = 50;\n+ const { height, width } = media.dimensions;\n+ let imageHeight = composedMessageMaxWidth >= width\n+ ? height\n+ : height * composedMessageMaxWidth / width;\n+ if (imageHeight < 50) {\n+ imageHeight = 50;\n}\n- } else if (messageInfo.media.length === 2) {\n- contentHeight = composedMessageMaxWidth / 2;\n- } else if (messageInfo.media.length === 3) {\n- contentHeight = composedMessageMaxWidth / 3;\n- } else if (messageInfo.media.length === 4) {\n- contentHeight = composedMessageMaxWidth;\n- } else {\n- const numRows = Math.ceil(messageInfo.media.length / 3);\n- contentHeight = numRows * composedMessageMaxWidth / 3;\n+ return imageHeight;\n}\n- return contentHeight;\n+\n+ const mediaPerRow = getMediaPerRow(messageInfo.media.length);\n+ const marginSpace = spaceBetweenImages * (mediaPerRow - 1);\n+ const imageHeight = (composedMessageMaxWidth - marginSpace) / mediaPerRow;\n+\n+ const numRows = Math.ceil(messageInfo.media.length / mediaPerRow);\n+ return numRows * imageHeight + (numRows - 1) * spaceBetweenImages;\n}\nfunction multimediaMessageItemHeight(\n@@ -73,7 +85,7 @@ function multimediaMessageItemHeight(\nconst { messageInfo, contentHeight, startsCluster, endsCluster } = item;\nconst { id, creator } = messageInfo;\nconst { isViewer } = creator;\n- let height = 5 + contentHeight; // for margin and image\n+ let height = 5 + contentHeight; // for margin and images\nif (!isViewer && startsCluster) {\nheight += 25; // for username\n}\n@@ -134,75 +146,47 @@ class MultimediaMessage extends React.PureComponent<Props> {\nrenderContent(): React.Node {\nconst { messageInfo } = this.props.item;\n+ invariant(messageInfo.media.length > 0, \"should have media\");\nif (messageInfo.media.length === 1) {\nreturn this.renderImage(messageInfo.media[0]);\n- } else if (messageInfo.media.length === 2) {\n- const [ one, two ] = messageInfo.media;\n- return (\n- <View style={styles.row}>\n- {this.renderImage(one, styles.leftImage)}\n- {this.renderImage(two, styles.rightImage)}\n- </View>\n- );\n- } else if (messageInfo.media.length === 3) {\n- const [ one, two, three ] = messageInfo.media;\n- return (\n- <View style={styles.row}>\n- {this.renderImage(one, styles.leftImage)}\n- {this.renderImage(two, styles.centerImage)}\n- {this.renderImage(three, styles.rightImage)}\n- </View>\n- );\n- } else if (messageInfo.media.length === 4) {\n- const [ one, two, three, four ] = messageInfo.media;\n- return (\n- <View style={styles.grid}>\n- <View style={styles.row}>\n- {this.renderImage(one, styles.topLeftImage)}\n- {this.renderImage(two, styles.topRightImage)}\n- </View>\n- <View style={styles.row}>\n- {this.renderImage(three, styles.leftImage)}\n- {this.renderImage(four, styles.rightImage)}\n- </View>\n- </View>\n- );\n- } else {\n- const rows = [];\n- for (let i = 0; i < messageInfo.media.length; i += 3) {\n- let rowStyle;\n- if (i === 0) {\n- rowStyle = rowStyles.top;\n- } else if (i + 3 >= messageInfo.media.length) {\n- rowStyle = rowStyles.bottom;\n- } else {\n- rowStyle = rowStyles.middle;\n}\n- const rowMedia = messageInfo.media.slice(i, i + 3);\n+ const mediaPerRow = getMediaPerRow(messageInfo.media.length);\n+ const numRows = Math.ceil(messageInfo.media.length / mediaPerRow);\n+\n+ const rows = [];\n+ for (let i = 0; i < messageInfo.media.length; i += mediaPerRow) {\n+ const rowMedia = messageInfo.media.slice(i, i + mediaPerRow);\nconst row = [];\nlet j = 0;\nfor (; j < rowMedia.length; j++) {\nconst media = rowMedia[j];\n- const style = rowStyle[j];\n+ const style = j + 1 < mediaPerRow\n+ ? styles.imageBeforeImage\n+ : null;\nrow.push(this.renderImage(media, style));\n}\n- for (; j < 3; j++) {\n+ for (; j < mediaPerRow; j++) {\nconst key = `filler${j}`;\n- row.push(<View style={styles.filler} key={key} />);\n+ const style = j + 1 < mediaPerRow\n+ ? [ styles.filler, styles.imageBeforeImage ]\n+ : styles.filler;\n+ row.push(<View style={[ style, styles.filler ]} key={key} />);\n}\n+ const rowStyle = i + mediaPerRow < messageInfo.media.length\n+ ? [ styles.row, styles.rowAboveRow ]\n+ : styles.row;\nrows.push(\n- <View style={styles.row} key={i}>\n+ <View style={rowStyle} key={i}>\n{row}\n</View>\n);\n}\nreturn <View style={styles.grid}>{rows}</View>;\n}\n- }\n- renderImage(media: Media, style?: ImageStyle): React.Node {\n+ renderImage(media: Media, style?: ?ImageStyle): React.Node {\nreturn (\n<MultimediaMessageMultimedia\nmedia={media}\n@@ -219,8 +203,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\n}\n-const horizontalSpaceBetweenImages = 2;\n-const verticalSpaceBetweenImages = 4;\n+const spaceBetweenImages = 4;\nconst styles = StyleSheet.create({\ncontainer: {\nflex: 1,\n@@ -229,6 +212,7 @@ const styles = StyleSheet.create({\n},\ngrid: {\nflex: 1,\n+ justifyContent: 'space-between',\n},\nfiller: {\nflex: 1,\n@@ -236,61 +220,15 @@ const styles = StyleSheet.create({\nrow: {\nflex: 1,\nflexDirection: 'row',\n+ justifyContent: 'space-between',\n},\n- leftImage: {\n- marginRight: horizontalSpaceBetweenImages,\n+ rowAboveRow: {\n+ marginBottom: spaceBetweenImages,\n},\n- centerImage: {\n- marginLeft: horizontalSpaceBetweenImages,\n- marginRight: horizontalSpaceBetweenImages,\n- },\n- rightImage: {\n- marginLeft: horizontalSpaceBetweenImages,\n- },\n- topLeftImage: {\n- marginRight: horizontalSpaceBetweenImages,\n- marginBottom: verticalSpaceBetweenImages,\n- },\n- topCenterImage: {\n- marginLeft: horizontalSpaceBetweenImages,\n- marginRight: horizontalSpaceBetweenImages,\n- marginBottom: verticalSpaceBetweenImages,\n- },\n- topRightImage: {\n- marginLeft: horizontalSpaceBetweenImages,\n- marginBottom: verticalSpaceBetweenImages,\n- },\n- middleLeftImage: {\n- marginRight: horizontalSpaceBetweenImages,\n- marginBottom: verticalSpaceBetweenImages,\n- },\n- middleCenterImage: {\n- marginRight: horizontalSpaceBetweenImages,\n- marginLeft: horizontalSpaceBetweenImages,\n- marginBottom: verticalSpaceBetweenImages,\n- },\n- middleRightImage: {\n- marginLeft: horizontalSpaceBetweenImages,\n- marginBottom: verticalSpaceBetweenImages,\n+ imageBeforeImage: {\n+ marginRight: spaceBetweenImages,\n},\n});\n-const rowStyles = {\n- top: [\n- styles.topLeftImage,\n- styles.topCenterImage,\n- styles.topRightImage,\n- ],\n- middle: [\n- styles.middleLeftImage,\n- styles.middleCenterImage,\n- styles.middleRightImage,\n- ],\n- bottom: [\n- styles.leftImage,\n- styles.centerImage,\n- styles.rightImage,\n- ],\n-};\nexport {\nMultimediaMessage,\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/media/multimedia-modal.react.js",
"diff": "+// @flow\n+\n+import type {\n+ NavigationScreenProp,\n+ NavigationLeafRoute,\n+} from 'react-navigation';\n+import { type Media, mediaPropType } from 'lib/types/media-types';\n+\n+import * as React from 'react';\n+import { View, StyleSheet, TouchableWithoutFeedback } from 'react-native';\n+import PropTypes from 'prop-types';\n+\n+import Multimedia from './multimedia.react';\n+\n+type NavProp = NavigationScreenProp<{|\n+ ...NavigationLeafRoute,\n+ params: {|\n+ media: Media,\n+ |},\n+|}>;\n+\n+type Props = {|\n+ navigation: NavProp,\n+|};\n+class MultimediaModal extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ navigation: PropTypes.shape({\n+ state: PropTypes.shape({\n+ params: PropTypes.shape({\n+ media: mediaPropType.isRequired,\n+ }).isRequired,\n+ }).isRequired,\n+ goBack: PropTypes.func.isRequired,\n+ }).isRequired,\n+ };\n+\n+ render() {\n+ const { media } = this.props.navigation.state.params;\n+ return (\n+ <View style={styles.container}>\n+ <TouchableWithoutFeedback onPress={this.close}>\n+ <View style={styles.backdrop} />\n+ </TouchableWithoutFeedback>\n+ <View style={styles.modal}>\n+ <Multimedia media={media} />\n+ </View>\n+ </View>\n+ );\n+ }\n+\n+ close = () => {\n+ this.props.navigation.goBack();\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ container: {\n+ flex: 1,\n+ justifyContent: \"center\",\n+ overflow: 'visible',\n+ },\n+ backdrop: {\n+ position: \"absolute\",\n+ top: -1000,\n+ bottom: 0,\n+ left: 0,\n+ right: 0,\n+ opacity: 0.7,\n+ backgroundColor: \"black\",\n+ overflow: 'visible',\n+ },\n+ modal: {\n+ flex: 1,\n+ justifyContent: \"center\",\n+ },\n+});\n+\n+export default MultimediaModal;\n"
},
{
"change_type": "RENAME",
"old_path": "native/chat/multimedia.react.js",
"new_path": "native/media/multimedia.react.js",
"diff": ""
},
{
"change_type": "MODIFY",
"old_path": "native/navigation/route-names.js",
"new_path": "native/navigation/route-names.js",
"diff": "@@ -34,6 +34,7 @@ export const AddUsersModalRouteName = 'AddUsersModal';\nexport const CustomServerModalRouteName = 'CustomServerModal';\nexport const ColorPickerModalRouteName = 'ColorPickerModal';\nexport const ComposeSubthreadModalRouteName = 'ComposeSubthreadModal';\n+export const MultimediaModalRouteName = 'MultimediaModal';\nexport const accountModals = [\nLoggedOutModalRouteName,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] MultimediaModal
I took some time to simplify both the `renderContent` and `multimediaMessageContentHeights` logic. |
129,187 | 21.03.2019 13:31:50 | 14,400 | 49dedcacfe4155014b1f057b8dbdf70e45e53fe5 | [native] Useful remainders of react-navigation-fluid-transitions exploration | [
{
"change_type": "MODIFY",
"old_path": "native/chat/chat.react.js",
"new_path": "native/chat/chat.react.js",
"diff": "@@ -5,7 +5,7 @@ import type {\nNavigationStateRoute,\n} from 'react-navigation';\n-import React from 'react';\n+import * as React from 'react';\nimport { Platform, StyleSheet } from 'react-native';\nimport { createStackNavigator } from 'react-navigation';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/robotext-message.react.js",
"new_path": "native/chat/robotext-message.react.js",
"diff": "@@ -129,11 +129,12 @@ class InnerThreadEntity extends React.PureComponent<InnerThreadEntityProps> {\n}\nonPressThread = () => {\n- const id = this.props.id;\n- this.props.dispatch({\n+ const { id, threadInfo, dispatch } = this.props;\n+ dispatch({\ntype: \"Navigation/NAVIGATE\",\nrouteName: MessageListRouteName,\n- params: { threadInfo: this.props.threadInfo },\n+ params: { threadInfo },\n+ key: `${MessageListRouteName}${threadInfo.id}`,\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-child-thread.react.js",
"new_path": "native/chat/settings/thread-settings-child-thread.react.js",
"diff": "@@ -47,8 +47,8 @@ class ThreadSettingsChildThread extends React.PureComponent<Props> {\n}\nonPress = () => {\n- const threadInfo = this.props.threadInfo;\n- this.props.navigate({\n+ const { threadInfo, navigate } = this.props;\n+ navigate({\nrouteName: MessageListRouteName,\nparams: { threadInfo },\nkey: `${MessageListRouteName}${threadInfo.id}`,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/thread-settings-parent.react.js",
"new_path": "native/chat/settings/thread-settings-parent.react.js",
"diff": "@@ -14,7 +14,6 @@ import { connect } from 'lib/utils/redux-utils';\nimport Button from '../../components/button.react';\nimport { MessageListRouteName } from '../../navigation/route-names';\n-import { ThreadSettingsRouteName } from '../../navigation/route-names';\ntype Props = {|\nthreadInfo: ThreadInfo,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation/navigation-setup.js",
"new_path": "native/navigation/navigation-setup.js",
"diff": "@@ -34,6 +34,7 @@ import React from 'react';\nimport PropTypes from 'prop-types';\nimport { StackViewTransitionConfigs } from 'react-navigation-stack';\nimport { useScreens } from 'react-native-screens';\n+import hoistNonReactStatics from 'hoist-non-react-statics';\nimport { infoFromURL } from 'lib/utils/url-utils';\nimport { fifteenDaysEarlier, fifteenDaysLater } from 'lib/utils/date-utils';\n@@ -214,7 +215,7 @@ const ReduxWrappedAppNavigator = connect((state: AppState) => ({\nappCanRespondToBackButton: appCanRespondToBackButtonSelector(state),\nisForeground: appLoggedInSelector(state),\n}))(WrappedAppNavigator);\n-(ReduxWrappedAppNavigator: Object).router = AppNavigator.router;\n+hoistNonReactStatics(ReduxWrappedAppNavigator, AppNavigator);\nconst RootNavigator = createStackNavigator(\n{\n@@ -703,7 +704,7 @@ function handleNewThread(\nroutes: [\n...newChatRoute.routes,\n{\n- key: 'NewThreadMessageList',\n+ key: `${MessageListRouteName}${threadInfo.id}`,\nrouteName: MessageListRouteName,\nparams: { threadInfo },\n},\n@@ -737,7 +738,7 @@ function replaceChatStackWithThread(\nroutes: [\n...newChatRoute.routes,\n{\n- key: 'NewThreadMessageList',\n+ key: `${MessageListRouteName}${threadInfo.id}`,\nrouteName: MessageListRouteName,\nparams: { threadInfo },\n},\n@@ -796,7 +797,7 @@ function handleNotificationPress(\nroutes: [\n...chatRoute.routes,\n{\n- key: `Notif-${_getUuid()}`,\n+ key: `${MessageListRouteName}${threadInfo.id}`,\nrouteName: MessageListRouteName,\nparams: { threadInfo },\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux-setup.js",
"new_path": "native/redux-setup.js",
"diff": "@@ -37,7 +37,6 @@ import {\nimport { composeWithDevTools } from 'redux-devtools-extension';\nimport { persistStore, persistReducer, REHYDRATE } from 'redux-persist';\nimport PropTypes from 'prop-types';\n-import { NavigationActions, StackActions } from 'react-navigation';\nimport {\ncreateReactNavigationReduxMiddleware,\n} from 'react-navigation-redux-helpers';\n@@ -57,8 +56,6 @@ import { getConfig } from 'lib/utils/config';\nimport { activeThreadSelector } from './selectors/nav-selectors';\nimport {\n- handleURLActionType,\n- navigateToAppActionType,\nresetUserStateActionType,\nrecordNotifPermissionAlertActionType,\nrecordAndroidNotificationActionType,\n@@ -86,10 +83,7 @@ import {\ncurrentLeafRoute,\nfindRouteIndexWithKey,\n} from './utils/navigation-utils';\n-import {\n- ComposeThreadRouteName,\n- MessageListRouteName,\n-} from './navigation/route-names';\n+import { ComposeThreadRouteName } from './navigation/route-names';\nimport reactotron from './reactotron';\nimport reduceDrafts from './reducers/draft-reducer';\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Useful remainders of react-navigation-fluid-transitions exploration |
129,187 | 21.03.2019 16:21:33 | 14,400 | 0cbf2bf70a8c988f86c9b0ced3b638239bd7db7b | [native] Add second StackNavigator layer for lightbox
Will convert this into a custom navigator next. | [
{
"change_type": "MODIFY",
"old_path": "native/navigation/navigation-setup.js",
"new_path": "native/navigation/navigation-setup.js",
"diff": "@@ -70,6 +70,7 @@ import {\n} from '../utils/navigation-utils';\nimport {\nAppRouteName,\n+ TabNavigatorRouteName,\nComposeThreadRouteName,\nDeleteThreadRouteName,\nThreadSettingsRouteName,\n@@ -86,6 +87,7 @@ import {\nCustomServerModalRouteName,\nColorPickerModalRouteName,\nComposeSubthreadModalRouteName,\n+ MultimediaModalRouteName,\naccountModals,\n} from './route-names';\nimport {\n@@ -97,6 +99,7 @@ import AddUsersModal from '../chat/settings/add-users-modal.react';\nimport CustomServerModal from '../more/custom-server-modal.react';\nimport ColorPickerModal from '../chat/settings/color-picker-modal.react';\nimport ComposeSubthreadModal from '../chat/settings/compose-subthread-modal.react';\n+import MultimediaModal from '../media/multimedia-modal.react';\nuseScreens();\n@@ -141,7 +144,7 @@ if (Platform.OS === \"android\") {\nconst createTabNavigator = Platform.OS === \"android\"\n? createMaterialTopTabNavigator\n: createBottomTabNavigator;\n-const AppNavigator = createTabNavigator(\n+const TabNavigator = createTabNavigator(\n{\n[CalendarRouteName]: { screen: Calendar },\n[ChatRouteName]: { screen: Chat },\n@@ -153,6 +156,17 @@ const AppNavigator = createTabNavigator(\ntabBarOptions,\n},\n);\n+\n+const AppNavigator = createStackNavigator(\n+ {\n+ [TabNavigatorRouteName]: TabNavigator,\n+ [MultimediaModalRouteName]: MultimediaModal,\n+ },\n+ {\n+ headerMode: 'none',\n+ },\n+);\n+\ntype WrappedAppNavigatorProps = {|\nnavigation: NavigationScreenProp<*>,\nisForeground: bool,\n@@ -291,6 +305,11 @@ const defaultNavigationState = {\n{\nkey: 'App',\nrouteName: AppRouteName,\n+ index: 0,\n+ routes: [\n+ {\n+ key: 'TabNavigator',\n+ routeName: TabNavigatorRouteName,\nindex: 1,\nroutes: [\n{ key: 'Calendar', routeName: CalendarRouteName },\n@@ -312,6 +331,8 @@ const defaultNavigationState = {\n},\n],\n},\n+ ],\n+ },\n{ key: 'LoggedOutModal', routeName: LoggedOutModalRouteName },\n],\n};\n@@ -609,7 +630,8 @@ function replaceChatRoute(\nstate: NavigationState,\nreplaceFunc: (chatRoute: NavigationStateRoute) => NavigationStateRoute,\n): NavigationState {\n- const tabRoute = assertNavigationRouteNotLeafNode(state.routes[0]);\n+ const appRoute = assertNavigationRouteNotLeafNode(state.routes[0]);\n+ const tabRoute = assertNavigationRouteNotLeafNode(appRoute.routes[0]);\nconst chatRoute = assertNavigationRouteNotLeafNode(tabRoute.routes[1]);\nconst newChatRoute = replaceFunc(chatRoute);\n@@ -621,8 +643,12 @@ function replaceChatRoute(\nnewTabRoutes[1] = newChatRoute;\nconst newTabRoute = { ...tabRoute, routes: newTabRoutes };\n+ const newAppRoutes = [ ...appRoute.routes ];\n+ newAppRoutes[0] = newTabRoute;\n+ const newAppRoute = { ...appRoute, routes: newAppRoutes };\n+\nconst newRootRoutes = [ ...state.routes ];\n- newRootRoutes[0] = newTabRoute;\n+ newRootRoutes[0] = newAppRoute;\nreturn {\n...state,\nroutes: newRootRoutes,\n@@ -755,34 +781,45 @@ function handleNotificationPress(\nviewerID: ?string,\nuserInfos: {[id: string]: UserInfo},\n): NavigationState {\n- const tabRoute = assertNavigationRouteNotLeafNode(state.routes[0]);\n+ const appRoute = assertNavigationRouteNotLeafNode(state.routes[0]);\n+ const tabRoute = assertNavigationRouteNotLeafNode(appRoute.routes[0]);\nconst chatRoute = assertNavigationRouteNotLeafNode(tabRoute.routes[1]);\nconst currentChatRoute = chatRoute.routes[chatRoute.index];\nif (\n+ state.index === 0 &&\n+ appRoute.index === 0 &&\n+ tabRoute.index === 1 &&\ncurrentChatRoute.routeName === MessageListRouteName &&\n- getThreadIDFromParams(currentChatRoute) === payload.rawThreadInfo.id &&\n- tabRoute.index === 1\n+ getThreadIDFromParams(currentChatRoute) === payload.rawThreadInfo.id\n) {\nreturn state;\n}\nif (payload.clearChatRoutes) {\n- const newState = replaceChatStackWithThread(\n+ const replacedState = replaceChatStackWithThread(\nstate,\npayload.rawThreadInfo,\nviewerID,\nuserInfos,\n);\n-\n- const newTabRoute = assertNavigationRouteNotLeafNode(newState.routes[0]);\n- const updatedTabRoute = { ...newTabRoute, index: 1 };\n-\n- const updatedRootRoutes = [ ...newState.routes ];\n- updatedRootRoutes[0] = updatedTabRoute;\n+ const replacedAppRoute =\n+ assertNavigationRouteNotLeafNode(replacedState.routes[0]);\nreturn {\n- ...newState,\n- routes: updatedRootRoutes,\n+ ...replacedState,\n+ index: 0,\n+ routes: [\n+ {\n+ ...replacedState.routes[0],\n+ index: 0,\n+ routes: [\n+ {\n+ ...replacedAppRoute.routes[0],\n+ index: 1,\n+ },\n+ ],\n+ },\n+ ],\nisTransitioning: true,\n};\n}\n@@ -800,20 +837,29 @@ function handleNotificationPress(\nkey: `${MessageListRouteName}${threadInfo.id}`,\nrouteName: MessageListRouteName,\nparams: { threadInfo },\n- }\n+ },\n],\nindex: chatRoute.routes.length,\n};\nconst newTabRoutes = [ ...tabRoute.routes ];\nnewTabRoutes[1] = newChatRoute;\n- const newTabRoute = { ...tabRoute, routes: newTabRoutes, index: 1 };\n-\n- const newRootRoutes = [ ...state.routes ];\n- newRootRoutes[0] = newTabRoute;\nreturn {\n...state,\n- routes: newRootRoutes,\n+ index: 0,\n+ routes: [\n+ {\n+ ...appRoute,\n+ index: 0,\n+ routes: [\n+ {\n+ ...tabRoute,\n+ index: 1,\n+ routes: newTabRoutes,\n+ },\n+ ],\n+ },\n+ ],\nisTransitioning: true,\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation/route-names.js",
"new_path": "native/navigation/route-names.js",
"diff": "@@ -13,6 +13,7 @@ export type Navigate = ({\n}) => bool;\nexport const AppRouteName = 'App';\n+export const TabNavigatorRouteName = 'TabNavigator';\nexport const ComposeThreadRouteName = 'ComposeThread';\nexport const DeleteThreadRouteName = 'DeleteThread';\nexport const ThreadSettingsRouteName = 'ThreadSettings';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux-setup.js",
"new_path": "native/redux-setup.js",
"diff": "@@ -160,7 +160,8 @@ const defaultState = ({\nfunction chatRouteFromNavInfo(navInfo: NavInfo): NavigationStateRoute {\nconst navState = navInfo.navigationState;\n- const tabRoute = assertNavigationRouteNotLeafNode(navState.routes[0]);\n+ const appRoute = assertNavigationRouteNotLeafNode(navState.routes[0]);\n+ const tabRoute = assertNavigationRouteNotLeafNode(appRoute.routes[0]);\nreturn assertNavigationRouteNotLeafNode(tabRoute.routes[1]);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/nav-selectors.js",
"new_path": "native/selectors/nav-selectors.js",
"diff": "@@ -16,6 +16,7 @@ import {\nimport {\nAppRouteName,\n+ TabNavigatorRouteName,\nThreadSettingsRouteName,\nMessageListRouteName,\nChatRouteName,\n@@ -54,12 +55,17 @@ const baseCreateActiveTabSelector =\n(routeName: string) => createSelector<*, *, *, *>(\n(state: AppState) => state.navInfo.navigationState,\n(navigationState: NavigationState) => {\n- const currentRoute = navigationState.routes[navigationState.index];\n- if (currentRoute.routeName !== AppRouteName) {\n+ const currentRootSubroute = navigationState.routes[navigationState.index];\n+ if (currentRootSubroute.routeName !== AppRouteName) {\nreturn false;\n}\n- const appRoute = assertNavigationRouteNotLeafNode(currentRoute);\n- return appRoute.routes[appRoute.index].routeName === routeName;\n+ const appRoute = assertNavigationRouteNotLeafNode(currentRootSubroute);\n+ const currentAppSubroute = appRoute.routes[appRoute.index];\n+ if (currentAppSubroute.routeName !== TabNavigatorRouteName) {\n+ return false;\n+ }\n+ const tabRoute = assertNavigationRouteNotLeafNode(currentAppSubroute);\n+ return tabRoute.routes[tabRoute.index].routeName === routeName;\n},\n);\nconst createActiveTabSelector = _memoize<*, *>(baseCreateActiveTabSelector);\n@@ -67,39 +73,49 @@ const createActiveTabSelector = _memoize<*, *>(baseCreateActiveTabSelector);\nconst activeThreadSelector = createSelector<*, *, *, *>(\n(state: AppState) => state.navInfo.navigationState,\n(navigationState: NavigationState): ?string => {\n- const currentRoute = navigationState.routes[navigationState.index];\n- if (currentRoute.routeName !== AppRouteName) {\n+ const currentRootSubroute = navigationState.routes[navigationState.index];\n+ if (currentRootSubroute.routeName !== AppRouteName) {\nreturn null;\n}\n- const appRoute = assertNavigationRouteNotLeafNode(currentRoute);\n- const innerInnerState = appRoute.routes[appRoute.index];\n- if (innerInnerState.routeName !== ChatRouteName) {\n+ const appRoute = assertNavigationRouteNotLeafNode(currentRootSubroute);\n+ const currentAppSubroute = appRoute.routes[appRoute.index];\n+ if (currentAppSubroute.routeName !== TabNavigatorRouteName) {\nreturn null;\n}\n- const chatRoute = assertNavigationRouteNotLeafNode(innerInnerState);\n- const innerInnerInnerState = chatRoute.routes[chatRoute.index];\n+ const tabRoute = assertNavigationRouteNotLeafNode(currentAppSubroute);\n+ const currentTabSubroute = tabRoute.routes[tabRoute.index];\n+ if (currentTabSubroute.routeName !== ChatRouteName) {\n+ return null;\n+ }\n+ const chatRoute = assertNavigationRouteNotLeafNode(currentTabSubroute);\n+ const currentChatSubroute = chatRoute.routes[chatRoute.index];\nif (\n- innerInnerInnerState.routeName !== MessageListRouteName &&\n- innerInnerInnerState.routeName !== ThreadSettingsRouteName\n+ currentChatSubroute.routeName !== MessageListRouteName &&\n+ currentChatSubroute.routeName !== ThreadSettingsRouteName\n) {\nreturn null;\n}\n- return getThreadIDFromParams(innerInnerInnerState);\n+ return getThreadIDFromParams(currentChatSubroute);\n},\n);\nconst appCanRespondToBackButtonSelector = createSelector<*, *, *, *>(\n(state: AppState) => state.navInfo.navigationState,\n(navigationState: NavigationState): bool => {\n- const currentRoute = navigationState.routes[navigationState.index];\n- if (currentRoute.routeName !== AppRouteName) {\n+ const currentRootSubroute = navigationState.routes[navigationState.index];\n+ if (currentRootSubroute.routeName !== AppRouteName) {\nreturn false;\n}\n- const appRoute = assertNavigationRouteNotLeafNode(currentRoute);\n- const currentTabRoute = appRoute.routes[appRoute.index];\n- return currentTabRoute.index !== null\n- && currentTabRoute.index !== undefined\n- && currentTabRoute.index > 0;\n+ const appRoute = assertNavigationRouteNotLeafNode(currentRootSubroute);\n+ const currentAppSubroute = appRoute.routes[appRoute.index];\n+ if (currentAppSubroute.routeName !== TabNavigatorRouteName) {\n+ return true;\n+ }\n+ const tabRoute = assertNavigationRouteNotLeafNode(currentAppSubroute);\n+ const currentTabSubroute = tabRoute.routes[tabRoute.index];\n+ return currentTabSubroute.index !== null\n+ && currentTabSubroute.index !== undefined\n+ && currentTabSubroute.index > 0;\n},\n);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Add second StackNavigator layer for lightbox
Will convert this into a custom navigator next. |
129,187 | 26.03.2019 11:57:51 | 14,400 | 2bd39becade8d656a4cfb45548ac6bd17563086c | [native] LightboxNavigator | [
{
"change_type": "MODIFY",
"old_path": "native/flow-typed/npm/@react-navigation/core_v3.x.x.js",
"new_path": "native/flow-typed/npm/@react-navigation/core_v3.x.x.js",
"diff": "@@ -219,6 +219,7 @@ declare module '@react-navigation/core' {\n*/\nindex: number,\nroutes: Array<NavigationRoute>,\n+ isTransitioning?: bool,\n};\ndeclare export type NavigationRoute =\n@@ -618,6 +619,7 @@ declare module '@react-navigation/core' {\nisStale: boolean,\nkey: string,\nroute: NavigationRoute,\n+ descriptor: ?NavigationDescriptor,\n};\ndeclare export type NavigationTransitionProps = $Shape<{\n@@ -745,9 +747,9 @@ declare module '@react-navigation/core' {\n}) => NavigationCompleteTransitionAction,\n};\n- declare type NavigationDescriptor = {\n+ declare export type NavigationDescriptor = {\nkey: string,\n- state: NavigationLeafRoute | NavigationStateRoute,\n+ state: NavigationRoute,\nnavigation: NavigationScreenProp<*>,\ngetComponent: () => React$ComponentType<{}>,\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/flow-typed/npm/react-navigation_v3.x.x.js",
"new_path": "native/flow-typed/npm/react-navigation_v3.x.x.js",
"diff": "@@ -241,6 +241,7 @@ declare module 'react-navigation' {\n*/\nindex: number,\nroutes: Array<NavigationRoute>,\n+ isTransitioning?: bool,\n};\ndeclare export type NavigationRoute =\n@@ -471,10 +472,10 @@ declare module 'react-navigation' {\ndisableKeyboardHandling?: boolean,\n|};\n- declare export type StackNavigatorConfig = {|\n+ declare export type StackNavigatorConfig = $Shape<{|\n...NavigationStackViewConfig,\n...NavigationStackRouterConfig,\n- |};\n+ |}>;\n/**\n* Switch Navigator\n@@ -716,6 +717,7 @@ declare module 'react-navigation' {\nisStale: boolean,\nkey: string,\nroute: NavigationRoute,\n+ descriptor: ?NavigationDescriptor,\n};\ndeclare export type NavigationTransitionProps = $Shape<{\n@@ -927,9 +929,9 @@ declare module 'react-navigation' {\nrouter: NavigationRouter<S, O>,\n};\n- declare type NavigationDescriptor = {\n+ declare export type NavigationDescriptor = {\nkey: string,\n- state: NavigationLeafRoute | NavigationStateRoute,\n+ state: NavigationRoute,\nnavigation: NavigationScreenProp<*>,\ngetComponent: () => React$ComponentType<{}>,\n};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/media/lightbox-navigator.react.js",
"diff": "+// @flow\n+\n+import type {\n+ NavigationScreenProp,\n+ NavigationState,\n+ NavigationDescriptor,\n+ NavigationStackScreenOptions,\n+ NavigationRouteConfigMap,\n+ NavigationTransitionProps,\n+ NavigationScene,\n+} from '@react-navigation/core';\n+import type {\n+ StackNavigatorConfig,\n+} from 'react-navigation';\n+\n+import * as React from 'react';\n+import { View, StyleSheet, Animated, Easing } from 'react-native';\n+import {\n+ StackRouter,\n+ createNavigator,\n+ StackActions,\n+} from '@react-navigation/core';\n+import { Transitioner } from 'react-navigation-stack';\n+\n+function createLightboxNavigator(\n+ routeConfigMap: NavigationRouteConfigMap,\n+ stackConfig: StackNavigatorConfig = {},\n+) {\n+ const {\n+ initialRouteName,\n+ initialRouteParams,\n+ paths,\n+ defaultNavigationOptions,\n+ initialRouteKey,\n+ } = stackConfig;\n+ const stackRouterConfig = {\n+ initialRouteName,\n+ initialRouteParams,\n+ paths,\n+ defaultNavigationOptions,\n+ initialRouteKey,\n+ };\n+ return createNavigator<\n+ NavigationStackScreenOptions,\n+ NavigationState,\n+ StackNavigatorConfig,\n+ >(\n+ // $FlowFixMe maybe will be fixed on flow-bin@0.89\n+ Lightbox,\n+ StackRouter(routeConfigMap, stackRouterConfig),\n+ stackConfig,\n+ );\n+}\n+\n+type LightboxProps = {|\n+ navigation: NavigationScreenProp<NavigationState>,\n+ descriptors: { [key: string]: NavigationDescriptor },\n+ navigationConfig: StackNavigatorConfig,\n+|};\n+class Lightbox extends React.PureComponent<LightboxProps> {\n+\n+ render() {\n+ return (\n+ <Transitioner\n+ render={this.renderScenes}\n+ configureTransition={this.configureTransition}\n+ navigation={this.props.navigation}\n+ descriptors={this.props.descriptors}\n+ onTransitionEnd={this.onTransitionEnd}\n+ />\n+ );\n+ }\n+\n+ configureTransition = (\n+ transitionProps: NavigationTransitionProps,\n+ prevTransitionProps: NavigationTransitionProps,\n+ ) => ({\n+ duration: 250,\n+ easing: Easing.inOut(Easing.ease),\n+ timing: Animated.timing,\n+ useNativeDriver: true,\n+ })\n+\n+ onTransitionEnd = (transitionProps: NavigationTransitionProps) => {\n+ if (!transitionProps.navigation.state.isTransitioning) {\n+ return;\n+ }\n+ const { navigation } = this.props;\n+ const transitionDestKey = transitionProps.scene.route.key;\n+ const isCurrentKey =\n+ navigation.state.routes[navigation.state.index].key === transitionDestKey;\n+ if (!isCurrentKey) {\n+ return;\n+ }\n+ navigation.dispatch(\n+ StackActions.completeTransition({ toChildKey: transitionDestKey }),\n+ );\n+ }\n+\n+ renderScenes = (\n+ transitionProps: NavigationTransitionProps,\n+ prevTransitionProps: NavigationTransitionProps,\n+ ) => {\n+ const { scenes } = transitionProps;\n+ const renderScene =\n+ (scene: NavigationScene) => this.renderScene(\n+ scene,\n+ transitionProps,\n+ prevTransitionProps,\n+ );\n+ return (\n+ <React.Fragment>\n+ {scenes.map(renderScene)}\n+ </React.Fragment>\n+ );\n+ }\n+\n+ renderScene(\n+ scene: NavigationScene,\n+ transitionProps: NavigationTransitionProps,\n+ prevTransitionProps: NavigationTransitionProps,\n+ ) {\n+ if (!scene.descriptor) {\n+ return null;\n+ }\n+ const { navigation, getComponent } = scene.descriptor;\n+ const SceneComponent = getComponent();\n+ return (\n+ <View style={styles.scene} key={scene.key}>\n+ <SceneComponent\n+ navigation={navigation}\n+ transitionProps={transitionProps}\n+ prevTransitionProps={prevTransitionProps}\n+ />\n+ </View>\n+ );\n+ }\n+\n+}\n+\n+const styles = StyleSheet.create({\n+ scene: {\n+ position: 'absolute',\n+ top: 0,\n+ bottom: 0,\n+ left: 0,\n+ right: 0,\n+ },\n+});\n+\n+export {\n+ createLightboxNavigator,\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -59,7 +59,7 @@ const styles = StyleSheet.create({\ncontainer: {\nflex: 1,\njustifyContent: \"center\",\n- overflow: 'visible',\n+ overflow: \"visible\",\n},\nbackdrop: {\nposition: \"absolute\",\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation/navigation-setup.js",
"new_path": "native/navigation/navigation-setup.js",
"diff": "@@ -99,6 +99,7 @@ import AddUsersModal from '../chat/settings/add-users-modal.react';\nimport CustomServerModal from '../more/custom-server-modal.react';\nimport ColorPickerModal from '../chat/settings/color-picker-modal.react';\nimport ComposeSubthreadModal from '../chat/settings/compose-subthread-modal.react';\n+import { createLightboxNavigator } from '../media/lightbox-navigator.react';\nimport MultimediaModal from '../media/multimedia-modal.react';\nuseScreens();\n@@ -157,14 +158,11 @@ const TabNavigator = createTabNavigator(\n},\n);\n-const AppNavigator = createStackNavigator(\n+const AppNavigator = createLightboxNavigator(\n{\n[TabNavigatorRouteName]: TabNavigator,\n[MultimediaModalRouteName]: MultimediaModal,\n},\n- {\n- headerMode: 'none',\n- },\n);\ntype WrappedAppNavigatorProps = {|\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] LightboxNavigator |
129,187 | 26.03.2019 15:36:51 | 14,400 | e7e406767869c352923f10fa11d539121ece1348 | Calculate MultimediaModal image dimensions | [
{
"change_type": "MODIFY",
"old_path": "lib/types/media-types.js",
"new_path": "lib/types/media-types.js",
"diff": "import PropTypes from 'prop-types';\n-export type Dimensions = {|\n+export type Dimensions = $ReadOnly<{|\nheight: number,\nwidth: number,\n-|};\n+|}>;\nexport const dimensionsPropType = PropTypes.shape({\nheight: PropTypes.number.isRequired,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -4,12 +4,24 @@ import type {\nNavigationScreenProp,\nNavigationLeafRoute,\n} from 'react-navigation';\n-import { type Media, mediaPropType } from 'lib/types/media-types';\n+import {\n+ type Media,\n+ mediaPropType,\n+ type Dimensions,\n+ dimensionsPropType,\n+} from 'lib/types/media-types';\n+import type { AppState } from '../redux-setup';\nimport * as React from 'react';\nimport { View, StyleSheet, TouchableWithoutFeedback } from 'react-native';\nimport PropTypes from 'prop-types';\n+import { connect } from 'lib/utils/redux-utils';\n+\n+import {\n+ dimensionsSelector,\n+ contentVerticalOffset,\n+} from '../selectors/dimension-selectors';\nimport Multimedia from './multimedia.react';\ntype NavProp = NavigationScreenProp<{|\n@@ -21,6 +33,8 @@ type NavProp = NavigationScreenProp<{|\ntype Props = {|\nnavigation: NavProp,\n+ // Redux state\n+ screenDimensions: Dimensions,\n|};\nclass MultimediaModal extends React.PureComponent<Props> {\n@@ -33,17 +47,44 @@ class MultimediaModal extends React.PureComponent<Props> {\n}).isRequired,\ngoBack: PropTypes.func.isRequired,\n}).isRequired,\n+ screenDimensions: dimensionsPropType.isRequired,\n};\n+ get imageDimensions(): Dimensions {\n+ const { screenDimensions, navigation } = this.props;\n+ const screenHeight = screenDimensions.height - contentVerticalOffset;\n+ const screenWidth = screenDimensions.width;\n+ const { dimensions } = navigation.state.params.media;\n+ if (dimensions.height < screenHeight && dimensions.width < screenWidth) {\n+ return { ...dimensions };\n+ }\n+ const heightRatio = screenHeight / dimensions.height;\n+ const widthRatio = screenWidth / dimensions.width;\n+ if (heightRatio < widthRatio) {\n+ return {\n+ height: screenHeight,\n+ width: dimensions.width * heightRatio,\n+ };\n+ }\n+ return {\n+ width: screenWidth,\n+ height: dimensions.height * widthRatio,\n+ };\n+ }\n+\nrender() {\n- const { media } = this.props.navigation.state.params;\n+ const { navigation, screenDimensions } = this.props;\n+ const { media } = navigation.state.params;\n+ const style = this.imageDimensions;\n+ const screenHeight = screenDimensions.height - contentVerticalOffset;\n+ const containerHeightStyle = { height: screenHeight };\nreturn (\n<View style={styles.container}>\n<TouchableWithoutFeedback onPress={this.close}>\n<View style={styles.backdrop} />\n</TouchableWithoutFeedback>\n- <View style={styles.modal}>\n- <Multimedia media={media} />\n+ <View style={[ styles.media, containerHeightStyle ]}>\n+ <Multimedia media={media} style={style} />\n</View>\n</View>\n);\n@@ -58,23 +99,25 @@ class MultimediaModal extends React.PureComponent<Props> {\nconst styles = StyleSheet.create({\ncontainer: {\nflex: 1,\n- justifyContent: \"center\",\n- overflow: \"visible\",\n+ marginTop: contentVerticalOffset,\n},\nbackdrop: {\nposition: \"absolute\",\n- top: -1000,\n+ top: -1 * contentVerticalOffset,\nbottom: 0,\nleft: 0,\nright: 0,\n- opacity: 0.7,\n+ opacity: 0.9,\nbackgroundColor: \"black\",\n- overflow: 'visible',\n},\n- modal: {\n- flex: 1,\n+ media: {\njustifyContent: \"center\",\n+ alignItems: \"center\",\n},\n});\n-export default MultimediaModal;\n+export default connect(\n+ (state: AppState) => ({\n+ screenDimensions: dimensionsSelector(state),\n+ }),\n+)(MultimediaModal);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia.react.js",
"new_path": "native/media/multimedia.react.js",
"diff": "@@ -53,7 +53,7 @@ class Multimedia extends React.PureComponent<Props, State> {\n<FastImage\nsource={source}\nonLoad={this.onLoad}\n- style={[styles.image, style]}\n+ style={style}\nkey={this.state.attempt}\n/>\n);\n@@ -90,9 +90,6 @@ const styles = StyleSheet.create({\nloadingOverlay: {\nposition: 'absolute',\n},\n- image: {\n- flex: 1,\n- },\n});\nexport default connect(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | Calculate MultimediaModal image dimensions |
129,187 | 27.03.2019 10:55:54 | 14,400 | 08a334eab7e300faa4a4391405e530b943ce9d12 | [native] Disable MessageList scroll when showing TextMessage Tooltip | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -54,6 +54,7 @@ type Props = {|\n|};\ntype State = {|\nfocusedMessageKey: ?string,\n+ scrollDisabled: bool,\n|};\nclass MessageList extends React.PureComponent<Props, State> {\n@@ -70,6 +71,7 @@ class MessageList extends React.PureComponent<Props, State> {\nloadingFromScroll = false;\nstate = {\nfocusedMessageKey: null,\n+ scrollDisabled: false,\n};\ncomponentDidMount() {\n@@ -128,6 +130,7 @@ class MessageList extends React.PureComponent<Props, State> {\nfocused={focused}\nnavigate={this.props.navigate}\ntoggleFocus={this.toggleMessageFocus}\n+ setScrollDisabled={this.setScrollDisabled}\n/>\n);\n}\n@@ -140,6 +143,10 @@ class MessageList extends React.PureComponent<Props, State> {\n}\n}\n+ setScrollDisabled = (scrollDisabled: bool) => {\n+ this.setState({ scrollDisabled });\n+ }\n+\nstatic keyExtractor(item: ChatMessageItemWithHeight) {\nif (item.itemType === \"loader\") {\nreturn \"loader\";\n@@ -190,6 +197,7 @@ class MessageList extends React.PureComponent<Props, State> {\nonViewableItemsChanged={this.onViewableItemsChanged}\nListFooterComponent={footer}\nscrollsToTop={false}\n+ scrollEnabled={!this.state.scrollDisabled}\nextraData={this.state.focusedMessageKey}\n/>\n</View>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message.react.js",
"new_path": "native/chat/message.react.js",
"diff": "@@ -59,6 +59,7 @@ type Props = {|\nfocused: bool,\nnavigate: Navigate,\ntoggleFocus: (messageKey: string) => void,\n+ setScrollDisabled: (scrollDisabled: bool) => void,\n|};\nclass Message extends React.PureComponent<Props> {\n@@ -67,6 +68,7 @@ class Message extends React.PureComponent<Props> {\nfocused: PropTypes.bool.isRequired,\nnavigate: PropTypes.func.isRequired,\ntoggleFocus: PropTypes.func.isRequired,\n+ setScrollDisabled: PropTypes.func.isRequired,\n};\ncomponentWillReceiveProps(nextProps: Props) {\n@@ -94,6 +96,7 @@ class Message extends React.PureComponent<Props> {\nitem={this.props.item}\nfocused={this.props.focused}\ntoggleFocus={this.props.toggleFocus}\n+ setScrollDisabled={this.props.setScrollDisabled}\n/>\n);\n} else if (this.props.item.messageShapeType === \"multimedia\") {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/text-message.react.js",
"new_path": "native/chat/text-message.react.js",
"diff": "@@ -64,6 +64,7 @@ type Props = {|\nitem: ChatTextMessageInfoItemWithHeight,\nfocused: bool,\ntoggleFocus: (messageKey: string) => void,\n+ setScrollDisabled: (scrollDisabled: bool) => void,\n|};\nclass TextMessage extends React.PureComponent<Props> {\n@@ -71,6 +72,7 @@ class TextMessage extends React.PureComponent<Props> {\nitem: chatMessageItemPropType.isRequired,\nfocused: PropTypes.bool.isRequired,\ntoggleFocus: PropTypes.func.isRequired,\n+ setScrollDisabled: PropTypes.func.isRequired,\n};\ntooltipConfig: $ReadOnlyArray<TooltipItemData>;\ntooltip: ?Tooltip;\n@@ -151,12 +153,14 @@ class TextMessage extends React.PureComponent<Props> {\n}\nonFocus = () => {\n+ this.props.setScrollDisabled(true);\nif (!this.props.focused) {\nthis.props.toggleFocus(messageKey(this.props.item.messageInfo));\n}\n}\nonBlur = () => {\n+ this.props.setScrollDisabled(false);\nif (this.props.focused) {\nthis.props.toggleFocus(messageKey(this.props.item.messageInfo));\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Disable MessageList scroll when showing TextMessage Tooltip |
129,187 | 27.03.2019 11:47:08 | 14,400 | d01ebaf5e0395782dfdfab41ebc809150477e75d | [native] Make status bar white in MultimediaModal | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -23,6 +23,7 @@ import {\ncontentVerticalOffset,\n} from '../selectors/dimension-selectors';\nimport Multimedia from './multimedia.react';\n+import ConnectedStatusBar from '../connected-status-bar.react';\ntype NavProp = NavigationScreenProp<{|\n...NavigationLeafRoute,\n@@ -80,6 +81,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nconst containerHeightStyle = { height: screenHeight };\nreturn (\n<View style={styles.container}>\n+ <ConnectedStatusBar barStyle=\"light-content\" />\n<TouchableWithoutFeedback onPress={this.close}>\n<View style={styles.backdrop} />\n</TouchableWithoutFeedback>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Make status bar white in MultimediaModal |
129,187 | 27.03.2019 11:48:02 | 14,400 | 4aad4cfd4857026c5bb39732e80048bc8dbc245d | [native] Use absolute positioning for MultimediaModal Multimedia | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -51,13 +51,20 @@ class MultimediaModal extends React.PureComponent<Props> {\nscreenDimensions: dimensionsPropType.isRequired,\n};\n+ get screenDimensions(): Dimensions {\n+ const { screenDimensions } = this.props;\n+ if (contentVerticalOffset === 0) {\n+ return screenDimensions;\n+ }\n+ const { height, width } = screenDimensions;\n+ return { height: height - contentVerticalOffset, width };\n+ }\n+\nget imageDimensions(): Dimensions {\n- const { screenDimensions, navigation } = this.props;\n- const screenHeight = screenDimensions.height - contentVerticalOffset;\n- const screenWidth = screenDimensions.width;\n- const { dimensions } = navigation.state.params.media;\n+ const { height: screenHeight, width: screenWidth } = this.screenDimensions;\n+ const { dimensions } = this.props.navigation.state.params.media;\nif (dimensions.height < screenHeight && dimensions.width < screenWidth) {\n- return { ...dimensions };\n+ return dimensions;\n}\nconst heightRatio = screenHeight / dimensions.height;\nconst widthRatio = screenWidth / dimensions.width;\n@@ -66,28 +73,37 @@ class MultimediaModal extends React.PureComponent<Props> {\nheight: screenHeight,\nwidth: dimensions.width * heightRatio,\n};\n- }\n+ } else {\nreturn {\nwidth: screenWidth,\nheight: dimensions.height * widthRatio,\n};\n}\n+ }\n+\n+ get imageStyle() {\n+ const { height, width } = this.imageDimensions;\n+ const { height: screenHeight, width: screenWidth } = this.screenDimensions;\n+ const verticalSpace = (screenHeight - height) / 2;\n+ const horizontalSpace = (screenWidth - width) / 2;\n+ return {\n+ position: 'absolute',\n+ height,\n+ width,\n+ top: verticalSpace + contentVerticalOffset,\n+ left: horizontalSpace,\n+ };\n+ }\nrender() {\n- const { navigation, screenDimensions } = this.props;\n- const { media } = navigation.state.params;\n- const style = this.imageDimensions;\n- const screenHeight = screenDimensions.height - contentVerticalOffset;\n- const containerHeightStyle = { height: screenHeight };\n+ const { media } = this.props.navigation.state.params;\nreturn (\n<View style={styles.container}>\n<ConnectedStatusBar barStyle=\"light-content\" />\n<TouchableWithoutFeedback onPress={this.close}>\n<View style={styles.backdrop} />\n</TouchableWithoutFeedback>\n- <View style={[ styles.media, containerHeightStyle ]}>\n- <Multimedia media={media} style={style} />\n- </View>\n+ <Multimedia media={media} style={this.imageStyle} />\n</View>\n);\n}\n@@ -101,21 +117,16 @@ class MultimediaModal extends React.PureComponent<Props> {\nconst styles = StyleSheet.create({\ncontainer: {\nflex: 1,\n- marginTop: contentVerticalOffset,\n},\nbackdrop: {\nposition: \"absolute\",\n- top: -1 * contentVerticalOffset,\n+ top: 0,\nbottom: 0,\nleft: 0,\nright: 0,\nopacity: 0.9,\nbackgroundColor: \"black\",\n},\n- media: {\n- justifyContent: \"center\",\n- alignItems: \"center\",\n- },\n});\nexport default connect(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use absolute positioning for MultimediaModal Multimedia |
129,187 | 27.03.2019 11:59:15 | 14,400 | 7b455a3ac2792dcedb541e9e828c0c956513377b | [native] Ignore LightboxNavigator in activeTab and activeThread | [
{
"change_type": "MODIFY",
"old_path": "native/selectors/nav-selectors.js",
"new_path": "native/selectors/nav-selectors.js",
"diff": "@@ -60,11 +60,11 @@ const baseCreateActiveTabSelector =\nreturn false;\n}\nconst appRoute = assertNavigationRouteNotLeafNode(currentRootSubroute);\n- const currentAppSubroute = appRoute.routes[appRoute.index];\n- if (currentAppSubroute.routeName !== TabNavigatorRouteName) {\n+ const [ appSubroute ] = appRoute.routes;\n+ if (appSubroute.routeName !== TabNavigatorRouteName) {\nreturn false;\n}\n- const tabRoute = assertNavigationRouteNotLeafNode(currentAppSubroute);\n+ const tabRoute = assertNavigationRouteNotLeafNode(appSubroute);\nreturn tabRoute.routes[tabRoute.index].routeName === routeName;\n},\n);\n@@ -78,11 +78,11 @@ const activeThreadSelector = createSelector<*, *, *, *>(\nreturn null;\n}\nconst appRoute = assertNavigationRouteNotLeafNode(currentRootSubroute);\n- const currentAppSubroute = appRoute.routes[appRoute.index];\n- if (currentAppSubroute.routeName !== TabNavigatorRouteName) {\n+ const [ appSubroute ] = appRoute.routes;\n+ if (appSubroute.routeName !== TabNavigatorRouteName) {\nreturn null;\n}\n- const tabRoute = assertNavigationRouteNotLeafNode(currentAppSubroute);\n+ const tabRoute = assertNavigationRouteNotLeafNode(appSubroute);\nconst currentTabSubroute = tabRoute.routes[tabRoute.index];\nif (currentTabSubroute.routeName !== ChatRouteName) {\nreturn null;\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Ignore LightboxNavigator in activeTab and activeThread |
129,187 | 27.03.2019 14:59:58 | 14,400 | 999c5414f70dd7772d86263840320834a1028504 | [native] Animate MultimediaModal opacity | [
{
"change_type": "MODIFY",
"old_path": "native/media/lightbox-navigator.react.js",
"new_path": "native/media/lightbox-navigator.react.js",
"diff": "@@ -52,12 +52,12 @@ function createLightboxNavigator(\n);\n}\n-type LightboxProps = {|\n+type Props = {|\nnavigation: NavigationScreenProp<NavigationState>,\ndescriptors: { [key: string]: NavigationDescriptor },\nnavigationConfig: StackNavigatorConfig,\n|};\n-class Lightbox extends React.PureComponent<LightboxProps> {\n+class Lightbox extends React.PureComponent<Props> {\nrender() {\nreturn (\n@@ -129,6 +129,7 @@ class Lightbox extends React.PureComponent<LightboxProps> {\n<View style={styles.scene} key={scene.key}>\n<SceneComponent\nnavigation={navigation}\n+ scene={scene}\ntransitionProps={transitionProps}\nprevTransitionProps={prevTransitionProps}\n/>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "import type {\nNavigationScreenProp,\nNavigationLeafRoute,\n+ NavigationScene,\n+ NavigationTransitionProps,\n} from 'react-navigation';\nimport {\ntype Media,\n@@ -13,7 +15,12 @@ import {\nimport type { AppState } from '../redux-setup';\nimport * as React from 'react';\n-import { View, StyleSheet, TouchableWithoutFeedback } from 'react-native';\n+import {\n+ View,\n+ StyleSheet,\n+ TouchableWithoutFeedback,\n+ Animated,\n+} from 'react-native';\nimport PropTypes from 'prop-types';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -34,6 +41,8 @@ type NavProp = NavigationScreenProp<{|\ntype Props = {|\nnavigation: NavProp,\n+ scene: NavigationScene,\n+ transitionProps: NavigationTransitionProps,\n// Redux state\nscreenDimensions: Dimensions,\n|};\n@@ -48,6 +57,8 @@ class MultimediaModal extends React.PureComponent<Props> {\n}).isRequired,\ngoBack: PropTypes.func.isRequired,\n}).isRequired,\n+ transitionProps: PropTypes.object.isRequired,\n+ scene: PropTypes.object.isRequired,\nscreenDimensions: dimensionsPropType.isRequired,\n};\n@@ -97,11 +108,19 @@ class MultimediaModal extends React.PureComponent<Props> {\nrender() {\nconst { media } = this.props.navigation.state.params;\n+ const { position } = this.props.transitionProps;\n+ const { index } = this.props.scene;\n+ const backdropStyle = {\n+ opacity: position.interpolate({\n+ inputRange: [ index - 1, index ],\n+ outputRange: ([ 0, 1 ]: number[]),\n+ }),\n+ };\nreturn (\n<View style={styles.container}>\n<ConnectedStatusBar barStyle=\"light-content\" />\n<TouchableWithoutFeedback onPress={this.close}>\n- <View style={styles.backdrop} />\n+ <Animated.View style={[ styles.backdrop, backdropStyle ]} />\n</TouchableWithoutFeedback>\n<Multimedia media={media} style={this.imageStyle} />\n</View>\n@@ -124,7 +143,6 @@ const styles = StyleSheet.create({\nbottom: 0,\nleft: 0,\nright: 0,\n- opacity: 0.9,\nbackgroundColor: \"black\",\n},\n});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Animate MultimediaModal opacity |
129,187 | 27.03.2019 16:42:28 | 14,400 | 3b6eb7b19bf5b9809a0c315649d14e91a6c91650 | [native] Interpolate Multimedia position in MultimediaModal | [
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message-multimedia.react.js",
"new_path": "native/chat/multimedia-message-multimedia.react.js",
"diff": "@@ -24,23 +24,35 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props> {\nmedia: mediaPropType.isRequired,\nnavigate: PropTypes.func.isRequired,\n};\n+ view: ?View;\nrender() {\nconst { media, style } = this.props;\nreturn (\n<TouchableWithoutFeedback onPress={this.onPress}>\n- <View style={[styles.expand, style]}>\n+ <View style={[styles.expand, style]} ref={this.viewRef}>\n<Multimedia media={media} style={styles.expand} />\n</View>\n</TouchableWithoutFeedback>\n);\n}\n+ viewRef = (view: ?View) => {\n+ this.view = view;\n+ }\n+\nonPress = () => {\n+ const { view } = this;\n+ if (!view) {\n+ return;\n+ }\n+ view.measure((x, y, width, height, pageX, pageY) => {\n+ const coordinates = { x: pageX, y: pageY, width, height };\nconst { media, navigate } = this.props;\nnavigate({\nrouteName: MultimediaModalRouteName,\n- params: { media },\n+ params: { media, initialCoordinates: coordinates },\n+ });\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -32,10 +32,17 @@ import {\nimport Multimedia from './multimedia.react';\nimport ConnectedStatusBar from '../connected-status-bar.react';\n+type LayoutCoordinates = $ReadOnly<{|\n+ x: number,\n+ y: number,\n+ width: number,\n+ height: number,\n+|}>;\ntype NavProp = NavigationScreenProp<{|\n...NavigationLeafRoute,\nparams: {|\nmedia: Media,\n+ initialCoordinates: LayoutCoordinates,\n|},\n|}>;\n@@ -53,6 +60,12 @@ class MultimediaModal extends React.PureComponent<Props> {\nstate: PropTypes.shape({\nparams: PropTypes.shape({\nmedia: mediaPropType.isRequired,\n+ initialCoordinates: PropTypes.shape({\n+ x: PropTypes.number.isRequired,\n+ y: PropTypes.number.isRequired,\n+ width: PropTypes.number.isRequired,\n+ height: PropTypes.number.isRequired,\n+ }).isRequired,\n}).isRequired,\n}).isRequired,\ngoBack: PropTypes.func.isRequired,\n@@ -92,37 +105,79 @@ class MultimediaModal extends React.PureComponent<Props> {\n}\n}\n- get imageStyle() {\n+ get imageContainerStyle() {\nconst { height, width } = this.imageDimensions;\nconst { height: screenHeight, width: screenWidth } = this.screenDimensions;\n- const verticalSpace = (screenHeight - height) / 2;\n- const horizontalSpace = (screenWidth - width) / 2;\n+ const top = (screenHeight - height) / 2 + contentVerticalOffset;\n+ const left = (screenWidth - width) / 2;\n+\n+ const { position } = this.props.transitionProps;\n+ const { index } = this.props.scene;\n+ const { initialCoordinates } = this.props.navigation.state.params;\n+\n+ const initialScaleX = initialCoordinates.width / width;\n+ const scaleX = position.interpolate({\n+ inputRange: [ index - 1, index ],\n+ outputRange: ([ initialScaleX, 1 ]: number[]),\n+ });\n+ const initialScaleY = initialCoordinates.height / height;\n+ const scaleY = position.interpolate({\n+ inputRange: [ index - 1, index ],\n+ outputRange: ([ initialScaleY, 1 ]: number[]),\n+ });\n+\n+ const initialTranslateX =\n+ (initialCoordinates.x + initialCoordinates.width / 2)\n+ - (left + width / 2);\n+ const translateX = position.interpolate({\n+ inputRange: [ index - 1, index ],\n+ outputRange: ([ initialTranslateX, 0 ]: number[]),\n+ });\n+ const initialTranslateY =\n+ (initialCoordinates.y + initialCoordinates.height / 2)\n+ - (top + height / 2);\n+ const translateY = position.interpolate({\n+ inputRange: [ index - 1, index ],\n+ outputRange: ([ initialTranslateY, 0 ]: number[]),\n+ });\n+\nreturn {\nposition: 'absolute',\nheight,\nwidth,\n- top: verticalSpace + contentVerticalOffset,\n- left: horizontalSpace,\n+ top,\n+ left,\n+ transform: [\n+ { translateX },\n+ { translateY },\n+ { scaleX },\n+ { scaleY },\n+ ],\n};\n}\n- render() {\n- const { media } = this.props.navigation.state.params;\n+ get backdropStyle() {\nconst { position } = this.props.transitionProps;\nconst { index } = this.props.scene;\n- const backdropStyle = {\n+ return {\nopacity: position.interpolate({\ninputRange: [ index - 1, index ],\noutputRange: ([ 0, 1 ]: number[]),\n}),\n};\n+ }\n+\n+ render() {\n+ const { media } = this.props.navigation.state.params;\nreturn (\n<View style={styles.container}>\n<ConnectedStatusBar barStyle=\"light-content\" />\n<TouchableWithoutFeedback onPress={this.close}>\n- <Animated.View style={[ styles.backdrop, backdropStyle ]} />\n+ <Animated.View style={[ styles.backdrop, this.backdropStyle ]} />\n</TouchableWithoutFeedback>\n- <Multimedia media={media} style={this.imageStyle} />\n+ <Animated.View style={this.imageContainerStyle}>\n+ <Multimedia media={media} style={styles.image} />\n+ </Animated.View>\n</View>\n);\n}\n@@ -145,6 +200,9 @@ const styles = StyleSheet.create({\nright: 0,\nbackgroundColor: \"black\",\n},\n+ image: {\n+ flex: 1,\n+ },\n});\nexport default connect(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Interpolate Multimedia position in MultimediaModal |
129,187 | 27.03.2019 17:04:27 | 14,400 | d4467fea51e530ef6ea27df03939aeb742823968 | [native] Drop MultimediaModal's Multimedia's opacity in last 10% of animation | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -113,8 +113,12 @@ class MultimediaModal extends React.PureComponent<Props> {\nconst { position } = this.props.transitionProps;\nconst { index } = this.props.scene;\n- const { initialCoordinates } = this.props.navigation.state.params;\n+ const opacity = position.interpolate({\n+ inputRange: [ index - 1, index - 0.9 ],\n+ outputRange: ([ 0, 1 ]: number[]),\n+ });\n+ const { initialCoordinates } = this.props.navigation.state.params;\nconst initialScaleX = initialCoordinates.width / width;\nconst scaleX = position.interpolate({\ninputRange: [ index - 1, index ],\n@@ -147,6 +151,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nwidth,\ntop,\nleft,\n+ opacity,\ntransform: [\n{ translateX },\n{ translateY },\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Drop MultimediaModal's Multimedia's opacity in last 10% of animation |
129,187 | 27.03.2019 17:32:07 | 14,400 | 565473464a3967d91de71001920b4da449174b54 | [native] Update Multimedia layout to improve performance | [
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message-multimedia.react.js",
"new_path": "native/chat/multimedia-message-multimedia.react.js",
"diff": "@@ -31,7 +31,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props> {\nreturn (\n<TouchableWithoutFeedback onPress={this.onPress}>\n<View style={[styles.expand, style]} ref={this.viewRef}>\n- <Multimedia media={media} style={styles.expand} />\n+ <Multimedia media={media} />\n</View>\n</TouchableWithoutFeedback>\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -181,7 +181,7 @@ class MultimediaModal extends React.PureComponent<Props> {\n<Animated.View style={[ styles.backdrop, this.backdropStyle ]} />\n</TouchableWithoutFeedback>\n<Animated.View style={this.imageContainerStyle}>\n- <Multimedia media={media} style={styles.image} />\n+ <Multimedia media={media} spinnerColor=\"white\" />\n</Animated.View>\n</View>\n);\n@@ -205,9 +205,6 @@ const styles = StyleSheet.create({\nright: 0,\nbackgroundColor: \"black\",\n},\n- image: {\n- flex: 1,\n- },\n});\nexport default connect(\n"
},
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia.react.js",
"new_path": "native/media/multimedia.react.js",
"diff": "// @flow\nimport { type Media, mediaPropType } from 'lib/types/media-types';\n-import type { ImageStyle } from '../types/styles';\nimport {\ntype ConnectionStatus,\nconnectionStatusPropType,\n@@ -9,6 +8,7 @@ import {\nimport type { AppState } from '../redux-setup';\nimport * as React from 'react';\n+import PropTypes from 'prop-types';\nimport { View, StyleSheet, ActivityIndicator } from 'react-native';\nimport FastImage from 'react-native-fast-image';\n@@ -16,7 +16,7 @@ import { connect } from 'lib/utils/redux-utils';\ntype Props = {|\nmedia: Media,\n- style?: ?ImageStyle,\n+ spinnerColor: \"black\" | \"white\",\n// Redux state\nconnectionStatus: ConnectionStatus,\n|};\n@@ -28,8 +28,12 @@ class Multimedia extends React.PureComponent<Props, State> {\nstatic propTypes = {\nmedia: mediaPropType.isRequired,\n+ spinnerColor: PropTypes.oneOf([ \"black\", \"white\" ]).isRequired,\nconnectionStatus: connectionStatusPropType.isRequired,\n};\n+ static defaultProps = {\n+ spinnerColor: \"black\",\n+ };\nstate = {\nattempt: 0,\nloaded: false,\n@@ -46,35 +50,34 @@ class Multimedia extends React.PureComponent<Props, State> {\n}\nrender() {\n- const { media, style } = this.props;\n+ let spinner = null;\n+ if (!this.state.loaded) {\n+ spinner = (\n+ <View style={styles.spinnerContainer}>\n+ <ActivityIndicator\n+ color={this.props.spinnerColor}\n+ size=\"large\"\n+ />\n+ </View>\n+ );\n+ }\n+\n+ const { media } = this.props;\nconst { uri } = media;\nconst source = { uri };\n- const image = (\n+ return (\n+ <View style={styles.container}>\n+ {spinner}\n<FastImage\nsource={source}\nonLoad={this.onLoad}\n- style={style}\n+ style={styles.image}\nkey={this.state.attempt}\n/>\n- );\n-\n- let loadingOverlay;\n- if (!this.state.loaded) {\n- return (\n- <View style={styles.loadingContainer}>\n- <ActivityIndicator\n- color=\"black\"\n- size=\"large\"\n- style={styles.loadingOverlay}\n- />\n- {image}\n</View>\n);\n}\n- return image;\n- }\n-\nonLoad = () => {\nthis.setState({ loaded: true });\n}\n@@ -82,13 +85,16 @@ class Multimedia extends React.PureComponent<Props, State> {\n}\nconst styles = StyleSheet.create({\n- loadingContainer: {\n+ container: {\n+ flex: 1,\n+ },\n+ image: {\nflex: 1,\n- justifyContent: 'center',\n- alignItems: 'center',\n},\n- loadingOverlay: {\n+ spinnerContainer: {\nposition: 'absolute',\n+ justifyContent: 'center',\n+ alignItems: 'center',\n},\n});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Update Multimedia layout to improve performance |
129,187 | 27.03.2019 17:48:29 | 14,400 | 053736806ad0cdb7f3273a9834846e9356dc5ff6 | [native] Ignore prevTransitionProps in LightboxNavigator | [
{
"change_type": "MODIFY",
"old_path": "native/media/lightbox-navigator.react.js",
"new_path": "native/media/lightbox-navigator.react.js",
"diff": "@@ -52,11 +52,11 @@ function createLightboxNavigator(\n);\n}\n-type Props = {|\n+type Props = $ReadOnly<{|\nnavigation: NavigationScreenProp<NavigationState>,\ndescriptors: { [key: string]: NavigationDescriptor },\nnavigationConfig: StackNavigatorConfig,\n-|};\n+|}>;\nclass Lightbox extends React.PureComponent<Props> {\nrender() {\n@@ -71,10 +71,7 @@ class Lightbox extends React.PureComponent<Props> {\n);\n}\n- configureTransition = (\n- transitionProps: NavigationTransitionProps,\n- prevTransitionProps: NavigationTransitionProps,\n- ) => ({\n+ configureTransition = () => ({\nduration: 250,\neasing: Easing.inOut(Easing.ease),\ntiming: Animated.timing,\n@@ -97,16 +94,12 @@ class Lightbox extends React.PureComponent<Props> {\n);\n}\n- renderScenes = (\n- transitionProps: NavigationTransitionProps,\n- prevTransitionProps: NavigationTransitionProps,\n- ) => {\n+ renderScenes = (transitionProps: NavigationTransitionProps) => {\nconst { scenes } = transitionProps;\nconst renderScene =\n(scene: NavigationScene) => this.renderScene(\nscene,\ntransitionProps,\n- prevTransitionProps,\n);\nreturn (\n<React.Fragment>\n@@ -115,11 +108,7 @@ class Lightbox extends React.PureComponent<Props> {\n);\n}\n- renderScene(\n- scene: NavigationScene,\n- transitionProps: NavigationTransitionProps,\n- prevTransitionProps: NavigationTransitionProps,\n- ) {\n+ renderScene(scene: NavigationScene, transitionProps: NavigationTransitionProps) {\nif (!scene.descriptor) {\nreturn null;\n}\n@@ -131,7 +120,6 @@ class Lightbox extends React.PureComponent<Props> {\nnavigation={navigation}\nscene={scene}\ntransitionProps={transitionProps}\n- prevTransitionProps={prevTransitionProps}\n/>\n</View>\n);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Ignore prevTransitionProps in LightboxNavigator |
129,187 | 27.03.2019 18:45:22 | 14,400 | 8048d79f6fa71cc95ed9a47b8d62935933c59dc4 | [native] Add close button to MultimediaModal | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -20,8 +20,10 @@ import {\nStyleSheet,\nTouchableWithoutFeedback,\nAnimated,\n+ TouchableHighlight,\n} from 'react-native';\nimport PropTypes from 'prop-types';\n+import Icon from 'react-native-vector-icons/Feather';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -85,21 +87,22 @@ class MultimediaModal extends React.PureComponent<Props> {\n}\nget imageDimensions(): Dimensions {\n- const { height: screenHeight, width: screenWidth } = this.screenDimensions;\n+ const { height: screenHeight, width: maxWidth } = this.screenDimensions;\n+ const maxHeight = screenHeight - 100; // space for close button\nconst { dimensions } = this.props.navigation.state.params.media;\n- if (dimensions.height < screenHeight && dimensions.width < screenWidth) {\n+ if (dimensions.height < maxHeight && dimensions.width < maxWidth) {\nreturn dimensions;\n}\n- const heightRatio = screenHeight / dimensions.height;\n- const widthRatio = screenWidth / dimensions.width;\n+ const heightRatio = maxHeight / dimensions.height;\n+ const widthRatio = maxWidth / dimensions.width;\nif (heightRatio < widthRatio) {\nreturn {\n- height: screenHeight,\n+ height: maxHeight,\nwidth: dimensions.width * heightRatio,\n};\n} else {\nreturn {\n- width: screenWidth,\n+ width: maxWidth,\nheight: dimensions.height * widthRatio,\n};\n}\n@@ -116,6 +119,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nconst opacity = position.interpolate({\ninputRange: [ index - 1, index - 0.9 ],\noutputRange: ([ 0, 1 ]: number[]),\n+ extrapolate: 'clamp',\n});\nconst { initialCoordinates } = this.props.navigation.state.params;\n@@ -123,11 +127,13 @@ class MultimediaModal extends React.PureComponent<Props> {\nconst scaleX = position.interpolate({\ninputRange: [ index - 1, index ],\noutputRange: ([ initialScaleX, 1 ]: number[]),\n+ extrapolate: 'clamp',\n});\nconst initialScaleY = initialCoordinates.height / height;\nconst scaleY = position.interpolate({\ninputRange: [ index - 1, index ],\noutputRange: ([ initialScaleY, 1 ]: number[]),\n+ extrapolate: 'clamp',\n});\nconst initialTranslateX =\n@@ -136,6 +142,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nconst translateX = position.interpolate({\ninputRange: [ index - 1, index ],\noutputRange: ([ initialTranslateX, 0 ]: number[]),\n+ extrapolate: 'clamp',\n});\nconst initialTranslateY =\n(initialCoordinates.y + initialCoordinates.height / 2)\n@@ -143,6 +150,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nconst translateY = position.interpolate({\ninputRange: [ index - 1, index ],\noutputRange: ([ initialTranslateY, 0 ]: number[]),\n+ extrapolate: 'clamp',\n});\nreturn {\n@@ -178,7 +186,11 @@ class MultimediaModal extends React.PureComponent<Props> {\n<View style={styles.container}>\n<ConnectedStatusBar barStyle=\"light-content\" />\n<TouchableWithoutFeedback onPress={this.close}>\n- <Animated.View style={[ styles.backdrop, this.backdropStyle ]} />\n+ <Animated.View style={[ styles.backdrop, this.backdropStyle ]}>\n+ <TouchableHighlight onPress={this.close} underlayColor=\"#A0A0A0DD\">\n+ <Icon name=\"x-circle\" style={styles.closeButton} />\n+ </TouchableHighlight>\n+ </Animated.View>\n</TouchableWithoutFeedback>\n<Animated.View style={this.imageContainerStyle}>\n<Multimedia media={media} spinnerColor=\"white\" />\n@@ -205,6 +217,13 @@ const styles = StyleSheet.create({\nright: 0,\nbackgroundColor: \"black\",\n},\n+ closeButton: {\n+ fontSize: 36,\n+ color: \"white\",\n+ position: \"absolute\",\n+ top: contentVerticalOffset,\n+ right: 12,\n+ },\n});\nexport default connect(\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Add close button to MultimediaModal |
129,187 | 27.03.2019 20:23:25 | 14,400 | 7df3cd245a64fbe38082850a0e69f790c4df63a6 | [native] Clip the transitioning Multimedia to within the MessageList | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list.react.js",
"new_path": "native/chat/message-list.react.js",
"diff": "@@ -8,6 +8,7 @@ import type { FetchMessageInfosPayload } from 'lib/types/message-types';\nimport type { DispatchActionPromise } from 'lib/utils/action-utils';\nimport type { ChatMessageItemWithHeight } from './message-list-container.react';\nimport type { Navigate } from '../navigation/route-names';\n+import type { VerticalBounds } from '../media/vertical-bounds';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n@@ -55,6 +56,7 @@ type Props = {|\ntype State = {|\nfocusedMessageKey: ?string,\nscrollDisabled: bool,\n+ messageListVerticalBounds: ?VerticalBounds,\n|};\nclass MessageList extends React.PureComponent<Props, State> {\n@@ -68,11 +70,13 @@ class MessageList extends React.PureComponent<Props, State> {\nfetchMessagesBeforeCursor: PropTypes.func.isRequired,\nfetchMostRecentMessages: PropTypes.func.isRequired,\n};\n- loadingFromScroll = false;\nstate = {\nfocusedMessageKey: null,\nscrollDisabled: false,\n+ messageListVerticalBounds: null,\n};\n+ loadingFromScroll = false;\n+ flatListContainer: ?View;\ncomponentDidMount() {\nconst { threadInfo } = this.props;\n@@ -131,6 +135,7 @@ class MessageList extends React.PureComponent<Props, State> {\nnavigate={this.props.navigate}\ntoggleFocus={this.toggleMessageFocus}\nsetScrollDisabled={this.setScrollDisabled}\n+ verticalBounds={this.state.messageListVerticalBounds}\n/>\n);\n}\n@@ -187,7 +192,11 @@ class MessageList extends React.PureComponent<Props, State> {\nconst { messageListData, startReached } = this.props;\nconst footer = startReached ? MessageList.ListFooterComponent : undefined;\nreturn (\n- <View style={styles.container}>\n+ <View\n+ style={styles.container}\n+ ref={this.flatListContainerRef}\n+ onLayout={this.onFlatListContainerLayout}\n+ >\n<FlatList\ninverted={true}\ndata={messageListData}\n@@ -198,12 +207,26 @@ class MessageList extends React.PureComponent<Props, State> {\nListFooterComponent={footer}\nscrollsToTop={false}\nscrollEnabled={!this.state.scrollDisabled}\n- extraData={this.state.focusedMessageKey}\n+ extraData={this.state}\n/>\n</View>\n);\n}\n+ flatListContainerRef = (flatListContainer: ?View) => {\n+ this.flatListContainer = flatListContainer;\n+ }\n+\n+ onFlatListContainerLayout = () => {\n+ const { flatListContainer } = this;\n+ if (!flatListContainer) {\n+ return;\n+ }\n+ flatListContainer.measure((x, y, width, height, pageX, pageY) => {\n+ this.setState({ messageListVerticalBounds: { height, y: pageY } });\n+ });\n+ }\n+\nonViewableItemsChanged = (info: {\nviewableItems: ViewToken[],\nchanged: ViewToken[],\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/message.react.js",
"new_path": "native/chat/message.react.js",
"diff": "@@ -11,6 +11,10 @@ import type {\n} from './multimedia-message.react';\nimport { chatMessageItemPropType } from 'lib/selectors/chat-selectors';\nimport type { Navigate } from '../navigation/route-names';\n+import {\n+ type VerticalBounds,\n+ verticalBoundsPropType,\n+} from '../media/vertical-bounds';\nimport * as React from 'react';\nimport { Text, StyleSheet, View, LayoutAnimation } from 'react-native';\n@@ -60,6 +64,7 @@ type Props = {|\nnavigate: Navigate,\ntoggleFocus: (messageKey: string) => void,\nsetScrollDisabled: (scrollDisabled: bool) => void,\n+ verticalBounds: ?VerticalBounds,\n|};\nclass Message extends React.PureComponent<Props> {\n@@ -69,6 +74,7 @@ class Message extends React.PureComponent<Props> {\nnavigate: PropTypes.func.isRequired,\ntoggleFocus: PropTypes.func.isRequired,\nsetScrollDisabled: PropTypes.func.isRequired,\n+ verticalBounds: verticalBoundsPropType,\n};\ncomponentWillReceiveProps(nextProps: Props) {\n@@ -105,6 +111,7 @@ class Message extends React.PureComponent<Props> {\nitem={this.props.item}\nnavigate={this.props.navigate}\ntoggleFocus={this.props.toggleFocus}\n+ verticalBounds={this.props.verticalBounds}\n/>\n);\n} else {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message-multimedia.react.js",
"new_path": "native/chat/multimedia-message-multimedia.react.js",
"diff": "@@ -6,6 +6,10 @@ import {\ntype Navigate,\nMultimediaModalRouteName,\n} from '../navigation/route-names';\n+import {\n+ type VerticalBounds,\n+ verticalBoundsPropType,\n+} from '../media/vertical-bounds';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n@@ -16,6 +20,7 @@ import Multimedia from '../media/multimedia.react';\ntype Props = {|\nmedia: Media,\nnavigate: Navigate,\n+ verticalBounds: ?VerticalBounds,\nstyle?: ImageStyle,\n|};\nclass MultimediaMessageMultimedia extends React.PureComponent<Props> {\n@@ -23,6 +28,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props> {\nstatic propTypes = {\nmedia: mediaPropType.isRequired,\nnavigate: PropTypes.func.isRequired,\n+ verticalBounds: verticalBoundsPropType,\n};\nview: ?View;\n@@ -42,8 +48,8 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props> {\n}\nonPress = () => {\n- const { view } = this;\n- if (!view) {\n+ const { view, props: { verticalBounds } } = this;\n+ if (!view || !verticalBounds) {\nreturn;\n}\nview.measure((x, y, width, height, pageX, pageY) => {\n@@ -51,7 +57,7 @@ class MultimediaMessageMultimedia extends React.PureComponent<Props> {\nconst { media, navigate } = this.props;\nnavigate({\nrouteName: MultimediaModalRouteName,\n- params: { media, initialCoordinates: coordinates },\n+ params: { media, initialCoordinates: coordinates, verticalBounds },\n});\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/multimedia-message.react.js",
"new_path": "native/chat/multimedia-message.react.js",
"diff": "@@ -9,6 +9,10 @@ import type { Media } from 'lib/types/media-types';\nimport type { ImageStyle } from '../types/styles';\nimport type { ThreadInfo } from 'lib/types/thread-types';\nimport type { Navigate } from '../navigation/route-names';\n+import {\n+ type VerticalBounds,\n+ verticalBoundsPropType,\n+} from '../media/vertical-bounds';\nimport * as React from 'react';\nimport {\n@@ -107,6 +111,7 @@ type Props = {|\nitem: ChatMultimediaMessageInfoItem,\nnavigate: Navigate,\ntoggleFocus: (messageKey: string) => void,\n+ verticalBounds: ?VerticalBounds,\n|};\nclass MultimediaMessage extends React.PureComponent<Props> {\n@@ -114,6 +119,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\nitem: chatMessageItemPropType.isRequired,\nnavigate: PropTypes.func.isRequired,\ntoggleFocus: PropTypes.func.isRequired,\n+ verticalBounds: verticalBoundsPropType,\n};\nrender() {\n@@ -191,6 +197,7 @@ class MultimediaMessage extends React.PureComponent<Props> {\n<MultimediaMessageMultimedia\nmedia={media}\nnavigate={this.props.navigate}\n+ verticalBounds={this.props.verticalBounds}\nstyle={style}\nkey={media.id}\n/>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -13,6 +13,7 @@ import {\ndimensionsPropType,\n} from 'lib/types/media-types';\nimport type { AppState } from '../redux-setup';\n+import { type VerticalBounds, verticalBoundsPropType } from './vertical-bounds';\nimport * as React from 'react';\nimport {\n@@ -21,6 +22,7 @@ import {\nTouchableWithoutFeedback,\nAnimated,\nTouchableHighlight,\n+ Platform,\n} from 'react-native';\nimport PropTypes from 'prop-types';\nimport Icon from 'react-native-vector-icons/Feather';\n@@ -28,8 +30,9 @@ import Icon from 'react-native-vector-icons/Feather';\nimport { connect } from 'lib/utils/redux-utils';\nimport {\n- dimensionsSelector,\ncontentVerticalOffset,\n+ contentBottomOffset,\n+ dimensionsSelector,\n} from '../selectors/dimension-selectors';\nimport Multimedia from './multimedia.react';\nimport ConnectedStatusBar from '../connected-status-bar.react';\n@@ -45,6 +48,7 @@ type NavProp = NavigationScreenProp<{|\nparams: {|\nmedia: Media,\ninitialCoordinates: LayoutCoordinates,\n+ verticalBounds: VerticalBounds,\n|},\n|}>;\n@@ -68,6 +72,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nwidth: PropTypes.number.isRequired,\nheight: PropTypes.number.isRequired,\n}).isRequired,\n+ verticalBounds: verticalBoundsPropType.isRequired,\n}).isRequired,\n}).isRequired,\ngoBack: PropTypes.func.isRequired,\n@@ -153,12 +158,12 @@ class MultimediaModal extends React.PureComponent<Props> {\nextrapolate: 'clamp',\n});\n+ const { verticalBounds } = this.props.navigation.state.params;\nreturn {\n- position: 'absolute',\nheight,\nwidth,\n- top,\n- left,\n+ marginTop: top - verticalBounds.y,\n+ marginLeft: left,\nopacity,\ntransform: [\n{ translateX },\n@@ -169,6 +174,22 @@ class MultimediaModal extends React.PureComponent<Props> {\n};\n}\n+ get contentContainerStyle() {\n+ const { verticalBounds } = this.props.navigation.state.params;\n+ const fullScreenHeight = this.screenDimensions.height\n+ + contentBottomOffset\n+ + contentVerticalOffset;\n+ const top = verticalBounds.y;\n+ const bottom = fullScreenHeight - verticalBounds.y - verticalBounds.height;\n+\n+ // margin will clip, but padding won't\n+ const { index } = this.props.scene;\n+ const verticalStyle = index === this.props.transitionProps.index\n+ ? { paddingTop: top, paddingBottom: bottom }\n+ : { marginTop: top, marginBottom: bottom };\n+ return [ styles.contentContainer, verticalStyle ];\n+ }\n+\nget backdropStyle() {\nconst { position } = this.props.transitionProps;\nconst { index } = this.props.scene;\n@@ -192,10 +213,15 @@ class MultimediaModal extends React.PureComponent<Props> {\n</TouchableHighlight>\n</Animated.View>\n</TouchableWithoutFeedback>\n+ <View style={this.contentContainerStyle}>\n+ <TouchableWithoutFeedback onPress={this.close}>\n+ <View style={styles.cover} />\n+ </TouchableWithoutFeedback>\n<Animated.View style={this.imageContainerStyle}>\n<Multimedia media={media} spinnerColor=\"white\" />\n</Animated.View>\n</View>\n+ </View>\n);\n}\n@@ -209,6 +235,13 @@ const styles = StyleSheet.create({\ncontainer: {\nflex: 1,\n},\n+ cover: {\n+ position: \"absolute\",\n+ top: 0,\n+ bottom: 0,\n+ left: 0,\n+ right: 0,\n+ },\nbackdrop: {\nposition: \"absolute\",\ntop: 0,\n@@ -221,9 +254,13 @@ const styles = StyleSheet.create({\nfontSize: 36,\ncolor: \"white\",\nposition: \"absolute\",\n- top: contentVerticalOffset,\n+ top: Platform.OS === \"ios\" ? contentVerticalOffset : 6,\nright: 12,\n},\n+ contentContainer: {\n+ flex: 1,\n+ overflow: \"hidden\",\n+ },\n});\nexport default connect(\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/media/vertical-bounds.js",
"diff": "+// @flow\n+\n+import PropTypes from 'prop-types';\n+\n+export type VerticalBounds = $ReadOnly<{|\n+ y: number,\n+ height: number,\n+|}>;\n+\n+export const verticalBoundsPropType = PropTypes.shape({\n+ y: PropTypes.number.isRequired,\n+ height: PropTypes.number.isRequired,\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/dimension-selectors.js",
"new_path": "native/selectors/dimension-selectors.js",
"diff": "@@ -18,33 +18,34 @@ if (Platform.OS === \"android\") {\nstatusBarHeight = 20;\n}\n+// iOS starts the 0 pixel above the status bar,\n+// so we offset our content by the status bar height\n+const contentVerticalOffset = Platform.OS === \"ios\"\n+ ? statusBarHeight\n+ : 0;\n+const contentBottomOffset = isIPhoneX\n+ ? 34 // iPhone X home pill\n+ : 0;\n+\nconst dimensionsSelector = createSelector<*, *, *, *>(\n(state: AppState) => state.dimensions,\n(dimensions: Dimensions): Dimensions => {\nlet { height, width } = dimensions;\n+ height -= contentBottomOffset;\nif (Platform.OS === \"android\") {\n// Android starts the 0 pixel below the status bar height,\n// but doesn't subtract it out of the dimensions\nheight -= statusBarHeight;\n- } else if (isIPhoneX) {\n- // We avoid painting the bottom 34 pixels on the iPhone X,\n- // as they are occupied by the home pill\n- height -= 34;\n}\nreturn { height, width };\n},\n);\n-// iOS starts the 0 pixel above the status bar,\n-// so we offset our content by the status bar height\n-const contentVerticalOffset = Platform.OS === \"ios\"\n- ? statusBarHeight\n- : 0;\n-\nconst tabBarSize = Platform.OS === \"android\" ? 50 : 49;\nexport {\n- dimensionsSelector,\ncontentVerticalOffset,\n+ contentBottomOffset,\n+ dimensionsSelector,\ntabBarSize,\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Clip the transitioning Multimedia to within the MessageList |
129,187 | 27.03.2019 23:17:26 | 14,400 | 95740ae06ede9ad182c29b7863a8ec827ee92fe1 | [native] Make MultimediaModal close button actually usable | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -21,7 +21,7 @@ import {\nStyleSheet,\nTouchableWithoutFeedback,\nAnimated,\n- TouchableHighlight,\n+ TouchableOpacity,\nPlatform,\n} from 'react-native';\nimport PropTypes from 'prop-types';\n@@ -206,13 +206,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nreturn (\n<View style={styles.container}>\n<ConnectedStatusBar barStyle=\"light-content\" />\n- <TouchableWithoutFeedback onPress={this.close}>\n- <Animated.View style={[ styles.backdrop, this.backdropStyle ]}>\n- <TouchableHighlight onPress={this.close} underlayColor=\"#A0A0A0DD\">\n- <Icon name=\"x-circle\" style={styles.closeButton} />\n- </TouchableHighlight>\n- </Animated.View>\n- </TouchableWithoutFeedback>\n+ <Animated.View style={[ styles.backdrop, this.backdropStyle ]} />\n<View style={this.contentContainerStyle}>\n<TouchableWithoutFeedback onPress={this.close}>\n<View style={styles.cover} />\n@@ -221,6 +215,14 @@ class MultimediaModal extends React.PureComponent<Props> {\n<Multimedia media={media} spinnerColor=\"white\" />\n</Animated.View>\n</View>\n+ <Animated.View style={[\n+ styles.closeButtonContainer,\n+ this.backdropStyle,\n+ ]}>\n+ <TouchableOpacity onPress={this.close}>\n+ <Icon name=\"x-circle\" style={styles.closeButton} />\n+ </TouchableOpacity>\n+ </Animated.View>\n</View>\n);\n}\n@@ -235,31 +237,33 @@ const styles = StyleSheet.create({\ncontainer: {\nflex: 1,\n},\n- cover: {\n+ backdrop: {\nposition: \"absolute\",\ntop: 0,\nbottom: 0,\nleft: 0,\nright: 0,\n+ backgroundColor: \"black\",\n},\n- backdrop: {\n+ contentContainer: {\n+ flex: 1,\n+ overflow: \"hidden\",\n+ },\n+ cover: {\nposition: \"absolute\",\ntop: 0,\nbottom: 0,\nleft: 0,\nright: 0,\n- backgroundColor: \"black\",\n},\n- closeButton: {\n- fontSize: 36,\n- color: \"white\",\n+ closeButtonContainer: {\nposition: \"absolute\",\ntop: Platform.OS === \"ios\" ? contentVerticalOffset : 6,\nright: 12,\n},\n- contentContainer: {\n- flex: 1,\n- overflow: \"hidden\",\n+ closeButton: {\n+ fontSize: 36,\n+ color: \"white\",\n},\n});\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Make MultimediaModal close button actually usable |
129,187 | 27.03.2019 23:28:00 | 14,400 | 6b107c3bde5795f08acfff473cfadb6f5bc933d7 | [native] Only use light status bar while MultimediaModal is active | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -174,6 +174,11 @@ class MultimediaModal extends React.PureComponent<Props> {\n};\n}\n+ get isActive() {\n+ const { index } = this.props.scene;\n+ return index === this.props.transitionProps.index;\n+ }\n+\nget contentContainerStyle() {\nconst { verticalBounds } = this.props.navigation.state.params;\nconst fullScreenHeight = this.screenDimensions.height\n@@ -183,8 +188,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nconst bottom = fullScreenHeight - verticalBounds.y - verticalBounds.height;\n// margin will clip, but padding won't\n- const { index } = this.props.scene;\n- const verticalStyle = index === this.props.transitionProps.index\n+ const verticalStyle = this.isActive\n? { paddingTop: top, paddingBottom: bottom }\n: { marginTop: top, marginBottom: bottom };\nreturn [ styles.contentContainer, verticalStyle ];\n@@ -203,9 +207,12 @@ class MultimediaModal extends React.PureComponent<Props> {\nrender() {\nconst { media } = this.props.navigation.state.params;\n+ const statusBar = this.isActive\n+ ? <ConnectedStatusBar barStyle=\"light-content\" />\n+ : null;\nreturn (\n<View style={styles.container}>\n- <ConnectedStatusBar barStyle=\"light-content\" />\n+ {statusBar}\n<Animated.View style={[ styles.backdrop, this.backdropStyle ]} />\n<View style={this.contentContainerStyle}>\n<TouchableWithoutFeedback onPress={this.close}>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Only use light status bar while MultimediaModal is active |
129,187 | 29.03.2019 16:57:23 | 14,400 | 97d37ad0a941a6ea39b7eee19497ae0806831715 | [native] Pinching and panning the MultimediaModal | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -26,6 +26,11 @@ import {\n} from 'react-native';\nimport PropTypes from 'prop-types';\nimport Icon from 'react-native-vector-icons/Feather';\n+import {\n+ PinchGestureHandler,\n+ PanGestureHandler,\n+ State as GestureState,\n+} from 'react-native-gesture-handler';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -82,6 +87,140 @@ class MultimediaModal extends React.PureComponent<Props> {\nscreenDimensions: dimensionsPropType.isRequired,\n};\n+ pinchScale = new Animated.Value(1);\n+ pinchFocalX = new Animated.Value(0);\n+ pinchFocalY = new Animated.Value(0);\n+ pinchEvent = Animated.event(\n+ [{\n+ nativeEvent: {\n+ scale: this.pinchScale,\n+ focalX: this.pinchFocalX,\n+ focalY: this.pinchFocalY,\n+ },\n+ }],\n+ { useNativeDriver: true },\n+ );\n+\n+ panX = new Animated.Value(0);\n+ panY = new Animated.Value(0);\n+ panEvent = Animated.event(\n+ [{\n+ nativeEvent: {\n+ translationX: this.panX,\n+ translationY: this.panY,\n+ },\n+ }],\n+ { useNativeDriver: true },\n+ );\n+\n+ curScaleNum = 1;\n+ curXNum = 0;\n+ curYNum = 0;\n+ curScale = new Animated.Value(1);\n+ curX = new Animated.Value(0);\n+ curY = new Animated.Value(0);\n+\n+ progress: Animated.Value;\n+ scale: Animated.Value;\n+ pinchX: Animated.Value;\n+ pinchY: Animated.Value;\n+ x: Animated.Value;\n+ y: Animated.Value;\n+ imageContainerOpacity: Animated.Value;\n+\n+ constructor(props: Props) {\n+ super(props);\n+\n+ const { height, width } = this.imageDimensions;\n+ const { height: screenHeight, width: screenWidth } = this.screenDimensions;\n+ const top = (screenHeight - height) / 2 + contentVerticalOffset;\n+ const left = (screenWidth - width) / 2;\n+\n+ const { initialCoordinates } = props.navigation.state.params;\n+ const initialScale = new Animated.Value(initialCoordinates.width / width);\n+ const initialTranslateX = new Animated.Value(\n+ (initialCoordinates.x + initialCoordinates.width / 2)\n+ - (left + width / 2),\n+ );\n+ const initialTranslateY = new Animated.Value(\n+ (initialCoordinates.y + initialCoordinates.height / 2)\n+ - (top + height / 2),\n+ );\n+\n+ const { position } = props.transitionProps;\n+ const { index } = props.scene;\n+ this.progress = position.interpolate({\n+ inputRange: [ index - 1, index ],\n+ outputRange: ([ 0, 1 ]: number[]),\n+ extrapolate: 'clamp',\n+ });\n+ this.imageContainerOpacity = this.progress.interpolate({\n+ inputRange: [ 0, 0.1 ],\n+ outputRange: ([ 0, 1 ]: number[]),\n+ extrapolate: 'clamp',\n+ });\n+\n+ const reverseProgress = Animated.subtract(1, this.progress);\n+ this.scale = Animated.add(\n+ Animated.multiply(reverseProgress, initialScale),\n+ Animated.multiply(\n+ this.progress,\n+ Animated.multiply(this.curScale, this.pinchScale),\n+ ),\n+ );\n+\n+ this.pinchX = Animated.multiply(\n+ Animated.subtract(1, this.pinchScale),\n+ Animated.subtract(\n+ Animated.subtract(\n+ this.pinchFocalX,\n+ this.curX,\n+ ),\n+ Animated.divide(\n+ this.props.transitionProps.layout.width,\n+ 2,\n+ ),\n+ ),\n+ );\n+ this.x = Animated.add(\n+ Animated.multiply(reverseProgress, initialTranslateX),\n+ Animated.multiply(\n+ this.progress,\n+ Animated.add(\n+ this.curX,\n+ Animated.add(this.pinchX, this.panX),\n+ ),\n+ ),\n+ );\n+\n+ this.pinchY = Animated.multiply(\n+ Animated.subtract(1, this.pinchScale),\n+ Animated.subtract(\n+ Animated.subtract(\n+ this.pinchFocalY,\n+ this.curY,\n+ ),\n+ Animated.divide(\n+ Animated.add(\n+ this.props.transitionProps.layout.height,\n+ contentVerticalOffset - contentBottomOffset,\n+ ),\n+ 2,\n+ ),\n+ ),\n+ );\n+ this.y = Animated.add(\n+ Animated.multiply(reverseProgress, initialTranslateY),\n+ Animated.multiply(\n+ this.progress,\n+ Animated.add(\n+ this.curY,\n+ Animated.add(this.pinchY, this.panY),\n+ ),\n+ ),\n+ );\n+ }\n+\nget screenDimensions(): Dimensions {\nconst { screenDimensions } = this.props;\nif (contentVerticalOffset === 0) {\n@@ -118,58 +257,17 @@ class MultimediaModal extends React.PureComponent<Props> {\nconst { height: screenHeight, width: screenWidth } = this.screenDimensions;\nconst top = (screenHeight - height) / 2 + contentVerticalOffset;\nconst left = (screenWidth - width) / 2;\n-\n- const { position } = this.props.transitionProps;\n- const { index } = this.props.scene;\n- const opacity = position.interpolate({\n- inputRange: [ index - 1, index - 0.9 ],\n- outputRange: ([ 0, 1 ]: number[]),\n- extrapolate: 'clamp',\n- });\n-\n- const { initialCoordinates } = this.props.navigation.state.params;\n- const initialScaleX = initialCoordinates.width / width;\n- const scaleX = position.interpolate({\n- inputRange: [ index - 1, index ],\n- outputRange: ([ initialScaleX, 1 ]: number[]),\n- extrapolate: 'clamp',\n- });\n- const initialScaleY = initialCoordinates.height / height;\n- const scaleY = position.interpolate({\n- inputRange: [ index - 1, index ],\n- outputRange: ([ initialScaleY, 1 ]: number[]),\n- extrapolate: 'clamp',\n- });\n-\n- const initialTranslateX =\n- (initialCoordinates.x + initialCoordinates.width / 2)\n- - (left + width / 2);\n- const translateX = position.interpolate({\n- inputRange: [ index - 1, index ],\n- outputRange: ([ initialTranslateX, 0 ]: number[]),\n- extrapolate: 'clamp',\n- });\n- const initialTranslateY =\n- (initialCoordinates.y + initialCoordinates.height / 2)\n- - (top + height / 2);\n- const translateY = position.interpolate({\n- inputRange: [ index - 1, index ],\n- outputRange: ([ initialTranslateY, 0 ]: number[]),\n- extrapolate: 'clamp',\n- });\n-\nconst { verticalBounds } = this.props.navigation.state.params;\nreturn {\nheight,\nwidth,\nmarginTop: top - verticalBounds.y,\nmarginLeft: left,\n- opacity,\n+ opacity: this.imageContainerOpacity,\ntransform: [\n- { translateX },\n- { translateY },\n- { scaleX },\n- { scaleY },\n+ { translateX: this.x },\n+ { translateY: this.y },\n+ { scale: this.scale },\n],\n};\n}\n@@ -194,26 +292,16 @@ class MultimediaModal extends React.PureComponent<Props> {\nreturn [ styles.contentContainer, verticalStyle ];\n}\n- get backdropStyle() {\n- const { position } = this.props.transitionProps;\n- const { index } = this.props.scene;\n- return {\n- opacity: position.interpolate({\n- inputRange: [ index - 1, index ],\n- outputRange: ([ 0, 1 ]: number[]),\n- }),\n- };\n- }\n-\nrender() {\nconst { media } = this.props.navigation.state.params;\nconst statusBar = this.isActive\n? <ConnectedStatusBar barStyle=\"light-content\" />\n: null;\n- return (\n- <View style={styles.container}>\n+ const backdropStyle = { opacity: this.progress };\n+ const view = (\n+ <Animated.View style={styles.container}>\n{statusBar}\n- <Animated.View style={[ styles.backdrop, this.backdropStyle ]} />\n+ <Animated.View style={[ styles.backdrop, backdropStyle ]} />\n<View style={this.contentContainerStyle}>\n<TouchableWithoutFeedback onPress={this.close}>\n<View style={styles.cover} />\n@@ -222,15 +310,27 @@ class MultimediaModal extends React.PureComponent<Props> {\n<Multimedia media={media} spinnerColor=\"white\" />\n</Animated.View>\n</View>\n- <Animated.View style={[\n- styles.closeButtonContainer,\n- this.backdropStyle,\n- ]}>\n+ <Animated.View style={[ styles.closeButtonContainer, backdropStyle ]}>\n<TouchableOpacity onPress={this.close}>\n<Icon name=\"x-circle\" style={styles.closeButton} />\n</TouchableOpacity>\n</Animated.View>\n- </View>\n+ </Animated.View>\n+ );\n+ return (\n+ <PinchGestureHandler\n+ onGestureEvent={this.pinchEvent}\n+ onHandlerStateChange={this.onPinchHandlerStateChange}\n+ >\n+ <Animated.View style={styles.container}>\n+ <PanGestureHandler\n+ onGestureEvent={this.panEvent}\n+ onHandlerStateChange={this.onPanHandlerStateChange}\n+ >\n+ {view}\n+ </PanGestureHandler>\n+ </Animated.View>\n+ </PinchGestureHandler>\n);\n}\n@@ -238,6 +338,57 @@ class MultimediaModal extends React.PureComponent<Props> {\nthis.props.navigation.goBack();\n}\n+ onPinchHandlerStateChange = (\n+ event: { nativeEvent: {\n+ state: number,\n+ oldState: number,\n+ scale: number,\n+ focalX: number,\n+ focalY: number,\n+ } },\n+ ) => {\n+ const { state, oldState, scale, focalX, focalY } = event.nativeEvent;\n+ if (state === GestureState.ACTIVE || oldState !== GestureState.ACTIVE) {\n+ return;\n+ }\n+ this.curScaleNum *= event.nativeEvent.scale;\n+ this.curScale.setValue(this.curScaleNum);\n+\n+ // Keep this logic in sync with pinchX/pinchY definitions in constructor.\n+ // Note however that this.screenDimensions.height is not the same as\n+ // this.props.transitionProps.layout.height. The latter includes both\n+ // contentVerticalOffset and contentBottomOffset.\n+ const { height: screenHeight, width: screenWidth } = this.screenDimensions;\n+ this.curXNum += (1 - scale)\n+ * (focalX - this.curXNum - screenWidth / 2);\n+ this.curYNum += (1 - scale)\n+ * (focalY - this.curYNum - screenHeight / 2 - contentVerticalOffset);\n+ this.curX.setValue(this.curXNum);\n+ this.curY.setValue(this.curYNum);\n+\n+ this.pinchScale.setValue(1);\n+ }\n+\n+ onPanHandlerStateChange = (\n+ event: { nativeEvent: {\n+ state: number,\n+ oldState: number,\n+ translationX: number,\n+ translationY: number,\n+ } },\n+ ) => {\n+ const { state, oldState } = event.nativeEvent;\n+ if (state === GestureState.ACTIVE || oldState !== GestureState.ACTIVE) {\n+ return;\n+ }\n+ this.curXNum += event.nativeEvent.translationX;\n+ this.curYNum += event.nativeEvent.translationY;\n+ this.curX.setValue(this.curXNum);\n+ this.curY.setValue(this.curYNum);\n+ this.panX.setValue(0);\n+ this.panY.setValue(0);\n+ }\n+\n}\nconst styles = StyleSheet.create({\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Pinching and panning the MultimediaModal |
129,187 | 29.03.2019 18:10:33 | 14,400 | 19ea1670e1539636d0f0366e879fc33e4d8aaa4d | [native] Handle variable contentVerticalOffset
Also simplify some logic in MultimediaModal with the now-necessary center variables. | [
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -47,7 +47,7 @@ import { connect } from 'lib/utils/redux-utils';\nimport {\ndimensionsSelector,\n- contentVerticalOffset,\n+ contentVerticalOffsetSelector,\n} from '../selectors/dimension-selectors';\nimport LogInPanelContainer from './log-in-panel-container.react';\nimport RegisterPanel from './register-panel.react';\n@@ -85,6 +85,7 @@ type Props = {\nloggedIn: bool,\nisForeground: bool,\ndimensions: Dimensions,\n+ contentVerticalOffset: number,\nsplashStyle: ImageStyle,\n// Redux dispatch functions\ndispatch: Dispatch,\n@@ -116,6 +117,7 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\nloggedIn: PropTypes.bool.isRequired,\nisForeground: PropTypes.bool.isRequired,\ndimensions: dimensionsPropType.isRequired,\n+ contentVerticalOffset: PropTypes.number.isRequired,\ndispatch: PropTypes.func.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\n@@ -359,7 +361,10 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\nmode: LoggedOutMode,\nkeyboardHeight: number,\n) {\n- const windowHeight = this.props.dimensions.height;\n+ const {\n+ dimensions: { height: windowHeight },\n+ contentVerticalOffset,\n+ } = this.props;\nlet containerSize = Platform.OS === \"ios\" ? 62 : 59; // header height\nif (mode === \"log-in\") {\n// We need to make space for the reset password button on smaller devices\n@@ -829,6 +834,7 @@ export default connect(\n!state.currentUserInfo.anonymous && true),\nisForeground: isForegroundSelector(state),\ndimensions: dimensionsSelector(state),\n+ contentVerticalOffset: contentVerticalOffsetSelector(state),\nsplashStyle: splashStyleSelector(state),\n}),\nnull,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/calendar/calendar.react.js",
"new_path": "native/calendar/calendar.react.js",
"diff": "@@ -63,7 +63,7 @@ import { registerFetchKey } from 'lib/reducers/loading-reducer';\nimport { Entry, InternalEntry, entryStyles } from './entry.react';\nimport {\ndimensionsSelector,\n- contentVerticalOffset,\n+ contentVerticalOffsetSelector,\ntabBarSize,\n} from '../selectors/dimension-selectors';\nimport { calendarListData } from '../selectors/calendar-selectors';\n@@ -126,6 +126,7 @@ type Props = {\nendDate: string,\ncalendarFilters: $ReadOnlyArray<CalendarFilter>,\ndimensions: Dimensions,\n+ contentVerticalOffset: number,\n// Redux dispatch functions\ndispatchActionPromise: DispatchActionPromise,\n// async functions that hit server APIs\n@@ -171,6 +172,7 @@ class InnerCalendar extends React.PureComponent<Props, State> {\nendDate: PropTypes.string.isRequired,\ncalendarFilters: PropTypes.arrayOf(calendarFilterPropType).isRequired,\ndimensions: dimensionsPropType.isRequired,\n+ contentVerticalOffset: PropTypes.number.isRequired,\ndispatchActionPromise: PropTypes.func.isRequired,\nupdateCalendarQuery: PropTypes.func.isRequired,\n};\n@@ -776,7 +778,10 @@ class InnerCalendar extends React.PureComponent<Props, State> {\n}\nflatListHeight() {\n- const windowHeight = this.props.dimensions.height;\n+ const {\n+ dimensions: { height: windowHeight },\n+ contentVerticalOffset,\n+ } = this.props;\nreturn windowHeight - contentVerticalOffset - tabBarSize;\n}\n@@ -1127,6 +1132,7 @@ const Calendar = connect(\nendDate: state.navInfo.endDate,\ncalendarFilters: state.calendarFilters,\ndimensions: dimensionsSelector(state),\n+ contentVerticalOffset: contentVerticalOffsetSelector(state),\n}),\n{ updateCalendarQuery },\n)(InnerCalendar);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -22,7 +22,6 @@ import {\nTouchableWithoutFeedback,\nAnimated,\nTouchableOpacity,\n- Platform,\n} from 'react-native';\nimport PropTypes from 'prop-types';\nimport Icon from 'react-native-vector-icons/Feather';\n@@ -35,9 +34,9 @@ import {\nimport { connect } from 'lib/utils/redux-utils';\nimport {\n- contentVerticalOffset,\ncontentBottomOffset,\ndimensionsSelector,\n+ contentVerticalOffsetSelector,\n} from '../selectors/dimension-selectors';\nimport Multimedia from './multimedia.react';\nimport ConnectedStatusBar from '../connected-status-bar.react';\n@@ -63,6 +62,7 @@ type Props = {|\ntransitionProps: NavigationTransitionProps,\n// Redux state\nscreenDimensions: Dimensions,\n+ contentVerticalOffset: number,\n|};\nclass MultimediaModal extends React.PureComponent<Props> {\n@@ -85,8 +85,14 @@ class MultimediaModal extends React.PureComponent<Props> {\ntransitionProps: PropTypes.object.isRequired,\nscene: PropTypes.object.isRequired,\nscreenDimensions: dimensionsPropType.isRequired,\n+ contentVerticalOffset: PropTypes.number.isRequired,\n};\n+ centerXNum: number;\n+ centerYNum: number;\n+ centerX = new Animated.Value(0);\n+ centerY = new Animated.Value(0);\n+\npinchScale = new Animated.Value(1);\npinchFocalX = new Animated.Value(0);\npinchFocalY = new Animated.Value(0);\n@@ -130,10 +136,11 @@ class MultimediaModal extends React.PureComponent<Props> {\nconstructor(props: Props) {\nsuper(props);\n+ this.updateCenter();\nconst { height, width } = this.imageDimensions;\nconst { height: screenHeight, width: screenWidth } = this.screenDimensions;\n- const top = (screenHeight - height) / 2 + contentVerticalOffset;\n+ const top = (screenHeight - height) / 2 + props.contentVerticalOffset;\nconst left = (screenWidth - width) / 2;\nconst { initialCoordinates } = props.navigation.state.params;\n@@ -176,10 +183,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nthis.pinchFocalX,\nthis.curX,\n),\n- Animated.divide(\n- this.props.transitionProps.layout.width,\n- 2,\n- ),\n+ this.centerX,\n),\n);\nthis.x = Animated.add(\n@@ -200,13 +204,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nthis.pinchFocalY,\nthis.curY,\n),\n- Animated.divide(\n- Animated.add(\n- this.props.transitionProps.layout.height,\n- contentVerticalOffset - contentBottomOffset,\n- ),\n- 2,\n- ),\n+ this.centerY,\n),\n);\nthis.y = Animated.add(\n@@ -221,8 +219,25 @@ class MultimediaModal extends React.PureComponent<Props> {\n);\n}\n+ updateCenter() {\n+ const { height: screenHeight, width: screenWidth } = this.screenDimensions;\n+ this.centerXNum = screenWidth / 2;\n+ this.centerYNum = screenHeight / 2 + this.props.contentVerticalOffset;\n+ this.centerX.setValue(this.centerXNum);\n+ this.centerY.setValue(this.centerYNum);\n+ }\n+\n+ componentDidUpdate(prevProps: Props) {\n+ if (\n+ this.props.screenDimensions !== prevProps.screenDimensions ||\n+ this.props.contentVerticalOffset !== prevProps.contentVerticalOffset\n+ ) {\n+ this.updateCenter();\n+ }\n+ }\n+\nget screenDimensions(): Dimensions {\n- const { screenDimensions } = this.props;\n+ const { screenDimensions, contentVerticalOffset } = this.props;\nif (contentVerticalOffset === 0) {\nreturn screenDimensions;\n}\n@@ -231,12 +246,19 @@ class MultimediaModal extends React.PureComponent<Props> {\n}\nget imageDimensions(): Dimensions {\n- const { height: screenHeight, width: maxWidth } = this.screenDimensions;\n- const maxHeight = screenHeight - 100; // space for close button\n+ // Make space for the close button\n+ let { height: maxHeight, width: maxWidth } = this.screenDimensions;\n+ if (maxHeight > maxWidth) {\n+ maxHeight -= 100;\n+ } else {\n+ maxWidth -= 100;\n+ }\n+\nconst { dimensions } = this.props.navigation.state.params.media;\nif (dimensions.height < maxHeight && dimensions.width < maxWidth) {\nreturn dimensions;\n}\n+\nconst heightRatio = maxHeight / dimensions.height;\nconst widthRatio = maxWidth / dimensions.width;\nif (heightRatio < widthRatio) {\n@@ -255,7 +277,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nget imageContainerStyle() {\nconst { height, width } = this.imageDimensions;\nconst { height: screenHeight, width: screenWidth } = this.screenDimensions;\n- const top = (screenHeight - height) / 2 + contentVerticalOffset;\n+ const top = (screenHeight - height) / 2 + this.props.contentVerticalOffset;\nconst left = (screenWidth - width) / 2;\nconst { verticalBounds } = this.props.navigation.state.params;\nreturn {\n@@ -281,7 +303,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nconst { verticalBounds } = this.props.navigation.state.params;\nconst fullScreenHeight = this.screenDimensions.height\n+ contentBottomOffset\n- + contentVerticalOffset;\n+ + this.props.contentVerticalOffset;\nconst top = verticalBounds.y;\nconst bottom = fullScreenHeight - verticalBounds.y - verticalBounds.height;\n@@ -298,6 +320,10 @@ class MultimediaModal extends React.PureComponent<Props> {\n? <ConnectedStatusBar barStyle=\"light-content\" />\n: null;\nconst backdropStyle = { opacity: this.progress };\n+ const closeButtonStyle = {\n+ opacity: this.progress,\n+ top: Math.max(this.props.contentVerticalOffset, 6),\n+ };\nconst view = (\n<Animated.View style={styles.container}>\n{statusBar}\n@@ -310,7 +336,10 @@ class MultimediaModal extends React.PureComponent<Props> {\n<Multimedia media={media} spinnerColor=\"white\" />\n</Animated.View>\n</View>\n- <Animated.View style={[ styles.closeButtonContainer, backdropStyle ]}>\n+ <Animated.View style={[\n+ styles.closeButtonContainer,\n+ closeButtonStyle,\n+ ]}>\n<TouchableOpacity onPress={this.close}>\n<Icon name=\"x-circle\" style={styles.closeButton} />\n</TouchableOpacity>\n@@ -351,22 +380,16 @@ class MultimediaModal extends React.PureComponent<Props> {\nif (state === GestureState.ACTIVE || oldState !== GestureState.ACTIVE) {\nreturn;\n}\n- this.curScaleNum *= event.nativeEvent.scale;\n+\n+ this.curScaleNum *= scale;\nthis.curScale.setValue(this.curScaleNum);\n+ this.pinchScale.setValue(1);\n- // Keep this logic in sync with pinchX/pinchY definitions in constructor.\n- // Note however that this.screenDimensions.height is not the same as\n- // this.props.transitionProps.layout.height. The latter includes both\n- // contentVerticalOffset and contentBottomOffset.\n- const { height: screenHeight, width: screenWidth } = this.screenDimensions;\n- this.curXNum += (1 - scale)\n- * (focalX - this.curXNum - screenWidth / 2);\n- this.curYNum += (1 - scale)\n- * (focalY - this.curYNum - screenHeight / 2 - contentVerticalOffset);\n+ // Keep this logic in sync with pinchX/pinchY definitions in constructor\n+ this.curXNum += (1 - scale) * (focalX - this.curXNum - this.centerXNum);\n+ this.curYNum += (1 - scale) * (focalY - this.curYNum - this.centerYNum);\nthis.curX.setValue(this.curXNum);\nthis.curY.setValue(this.curYNum);\n-\n- this.pinchScale.setValue(1);\n}\nonPanHandlerStateChange = (\n@@ -377,12 +400,12 @@ class MultimediaModal extends React.PureComponent<Props> {\ntranslationY: number,\n} },\n) => {\n- const { state, oldState } = event.nativeEvent;\n+ const { state, oldState, translationX, translationY } = event.nativeEvent;\nif (state === GestureState.ACTIVE || oldState !== GestureState.ACTIVE) {\nreturn;\n}\n- this.curXNum += event.nativeEvent.translationX;\n- this.curYNum += event.nativeEvent.translationY;\n+ this.curXNum += translationX;\n+ this.curYNum += translationY;\nthis.curX.setValue(this.curXNum);\nthis.curY.setValue(this.curYNum);\nthis.panX.setValue(0);\n@@ -416,7 +439,6 @@ const styles = StyleSheet.create({\n},\ncloseButtonContainer: {\nposition: \"absolute\",\n- top: Platform.OS === \"ios\" ? contentVerticalOffset : 6,\nright: 12,\n},\ncloseButton: {\n@@ -428,5 +450,6 @@ const styles = StyleSheet.create({\nexport default connect(\n(state: AppState) => ({\nscreenDimensions: dimensionsSelector(state),\n+ contentVerticalOffset: contentVerticalOffsetSelector(state),\n}),\n)(MultimediaModal);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/selectors/dimension-selectors.js",
"new_path": "native/selectors/dimension-selectors.js",
"diff": "@@ -18,14 +18,8 @@ if (Platform.OS === \"android\") {\nstatusBarHeight = 20;\n}\n-// iOS starts the 0 pixel above the status bar,\n-// so we offset our content by the status bar height\n-const contentVerticalOffset = Platform.OS === \"ios\"\n- ? statusBarHeight\n- : 0;\n-const contentBottomOffset = isIPhoneX\n- ? 34 // iPhone X home pill\n- : 0;\n+// iPhone X home pill\n+const contentBottomOffset = isIPhoneX ? 34 : 0;\nconst dimensionsSelector = createSelector<*, *, *, *>(\n(state: AppState) => state.dimensions,\n@@ -41,11 +35,29 @@ const dimensionsSelector = createSelector<*, *, *, *>(\n},\n);\n+// iOS starts the 0 pixel above the status bar,\n+// so we offset our content by the status bar height\n+const contentVerticalOffsetSelector = createSelector<*, *, *, *>(\n+ (state: AppState) => state.dimensions,\n+ (dimensions: Dimensions): number => {\n+ if (Platform.OS !== \"ios\") {\n+ return 0;\n+ }\n+ const { height, width } = dimensions;\n+ if (width > height) {\n+ // We don't display a status bar at all in landscape mode,\n+ // plus there is no notch for the iPhone X\n+ return 0;\n+ }\n+ return statusBarHeight;\n+ },\n+);\n+\nconst tabBarSize = Platform.OS === \"android\" ? 50 : 49;\nexport {\n- contentVerticalOffset,\ncontentBottomOffset,\ndimensionsSelector,\n+ contentVerticalOffsetSelector,\ntabBarSize,\n};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Handle variable contentVerticalOffset
Also simplify some logic in MultimediaModal with the now-necessary center variables. |
129,187 | 29.03.2019 18:54:03 | 14,400 | 3f5910a9e2029048565f54d659a5ebd86022248b | [native] Allow non-portrait orientation in MultimediaModal | [
{
"change_type": "MODIFY",
"old_path": "native/android/app/build.gradle",
"new_path": "native/android/app/build.gradle",
"diff": "@@ -147,6 +147,7 @@ android {\n}\ndependencies {\n+ implementation project(':react-native-orientation-locker')\nimplementation project(':react-native-fast-image')\ncompile project(':react-native-screens')\ncompile project(':react-native-gesture-handler')\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/app/src/main/java/org/squadcal/MainActivity.java",
"new_path": "native/android/app/src/main/java/org/squadcal/MainActivity.java",
"diff": "@@ -4,6 +4,7 @@ import com.facebook.react.ReactFragmentActivity;\nimport org.devio.rn.splashscreen.SplashScreen;\nimport android.os.Bundle;\nimport android.content.Intent;\n+import android.content.res.Configuration;\npublic class MainActivity extends ReactFragmentActivity {\n@@ -28,4 +29,12 @@ public class MainActivity extends ReactFragmentActivity {\nsetIntent(intent);\n}\n+ @Override\n+ public void onConfigurationChanged(Configuration newConfig) {\n+ super.onConfigurationChanged(newConfig);\n+ Intent intent = new Intent(\"onConfigurationChanged\");\n+ intent.putExtra(\"newConfig\", newConfig);\n+ this.sendBroadcast(intent);\n+ }\n+\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java",
"new_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java",
"diff": "@@ -3,6 +3,7 @@ package org.squadcal;\nimport android.app.Application;\nimport com.facebook.react.ReactApplication;\n+import org.wonday.orientation.OrientationPackage;\nimport com.dylanvann.fastimage.FastImageViewPackage;\nimport com.swmansion.rnscreens.RNScreensPackage;\nimport com.swmansion.gesturehandler.react.RNGestureHandlerPackage;\n@@ -31,6 +32,7 @@ public class MainApplication extends Application implements ReactApplication {\nprotected List<ReactPackage> getPackages() {\nreturn Arrays.<ReactPackage>asList(\nnew MainReactPackage(),\n+ new OrientationPackage(),\nnew FastImageViewPackage(),\nnew RNScreensPackage(),\nnew RNGestureHandlerPackage(),\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/settings.gradle",
"new_path": "native/android/settings.gradle",
"diff": "rootProject.name = 'SquadCal'\n+include ':react-native-orientation-locker'\n+project(':react-native-orientation-locker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-orientation-locker/android')\ninclude ':react-native-fast-image'\nproject(':react-native-fast-image').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fast-image/android')\ninclude ':react-native-screens'\n"
},
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "@@ -44,6 +44,7 @@ import NotificationsIOS from 'react-native-notifications';\nimport InAppNotification from 'react-native-in-app-notification';\nimport FCM, { FCMEvent } from 'react-native-fcm';\nimport SplashScreen from 'react-native-splash-screen';\n+import Orientation from 'react-native-orientation-locker';\nimport { connect } from 'lib/utils/redux-utils';\nimport {\n@@ -164,6 +165,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\nif (this.props.rehydrateConcluded) {\nthis.onReduxRehydrate();\n}\n+ Orientation.lockToPortrait();\n}\nonReduxRehydrate() {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"diff": "140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };\n146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };\n1914154F4B054443B725346F /* Foundation.ttf in Resources */ = {isa = PBXBuildFile; fileRef = EA40FBBA484449FAA8915A48 /* Foundation.ttf */; };\n+ 1BFB77B74B924FA79ACBC2F6 /* libRCTOrientation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 99A8CC0EA47F466EAD201409 /* libRCTOrientation.a */; };\n2D02E4BC1E0B4A80006451C7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };\n2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };\n2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };\nremoteGlobalIDString = 139D7E881E25C6D100323FB7;\nremoteInfo = \"double-conversion\";\n};\n+ 7F16EA62224EBBC00008E483 /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = ED28C047C454400D87062E8C /* RNGestureHandler.xcodeproj */;\n+ proxyType = 2;\n+ remoteGlobalIDString = B5C32A36220C603B000FFB8D;\n+ remoteInfo = \"RNGestureHandler-tvOS\";\n+ };\n+ 7F16EB0D224ED3270008E483 /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = 443E4D8DC396450F8F664A5D /* RCTOrientation.xcodeproj */;\n+ proxyType = 2;\n+ remoteGlobalIDString = 134814201AA4EA6300B7C361;\n+ remoteInfo = RCTOrientation;\n+ };\n7F347C192242A05200F313CE /* PBXContainerItemProxy */ = {\nisa = PBXContainerItemProxy;\ncontainerPortal = 7FA344AAF237451CB8B3424B /* FastImage.xcodeproj */;\n2D04F3CCBAFF4A8184206FAC /* Octicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Octicons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Octicons.ttf\"; sourceTree = \"<group>\"; };\n2D16E6891FA4F8E400B85C8A /* libReact.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; path = libReact.a; sourceTree = BUILT_PRODUCTS_DIR; };\n3430816A291640AEACA13234 /* EvilIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = EvilIcons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/EvilIcons.ttf\"; sourceTree = \"<group>\"; };\n+ 443E4D8DC396450F8F664A5D /* RCTOrientation.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = RCTOrientation.xcodeproj; path = \"../node_modules/react-native-orientation-locker/iOS/RCTOrientation.xcodeproj\"; sourceTree = \"<group>\"; };\n47C86914FEF44D79AD04F880 /* libFastImage.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libFastImage.a; sourceTree = \"<group>\"; };\n4AB1FC0EFD3A4ED1A082E32F /* FontAwesome.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = FontAwesome.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/FontAwesome.ttf\"; sourceTree = \"<group>\"; };\n4ACC468F28D944F293B91ACC /* Ionicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Ionicons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Ionicons.ttf\"; sourceTree = \"<group>\"; };\n8D919BA72D8545CBBBF6B74F /* MaterialCommunityIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = MaterialCommunityIcons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/MaterialCommunityIcons.ttf\"; sourceTree = \"<group>\"; };\n95EA49951E064ECB9B1999EA /* libRNExitApp.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNExitApp.a; sourceTree = \"<group>\"; };\n95EEFC35D4D14053ACA7E064 /* RNKeychain.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = RNKeychain.xcodeproj; path = \"../node_modules/react-native-keychain/RNKeychain.xcodeproj\"; sourceTree = \"<group>\"; };\n+ 99A8CC0EA47F466EAD201409 /* libRCTOrientation.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRCTOrientation.a; sourceTree = \"<group>\"; };\nA06F10E4481746D2B76CA60E /* Feather.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Feather.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Feather.ttf\"; sourceTree = \"<group>\"; };\nAE31AFFF88FB4112A29ADE33 /* SimpleLineIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = SimpleLineIcons.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/SimpleLineIcons.ttf\"; sourceTree = \"<group>\"; };\nBA72871056D240AEB0706398 /* RNScreens.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = RNScreens.xcodeproj; path = \"../node_modules/react-native-screens/ios/RNScreens.xcodeproj\"; sourceTree = \"<group>\"; };\nEFBA858A8D2B4909A08D9FE6 /* libRNGestureHandler.a in Frameworks */,\nA6EF57DD8BDA4D43812D0B13 /* libRNScreens.a in Frameworks */,\nA4B3D66697E04C11B4167EE7 /* libFastImage.a in Frameworks */,\n+ 1BFB77B74B924FA79ACBC2F6 /* libRCTOrientation.a in Frameworks */,\n);\nrunOnlyForDeploymentPostprocessing = 0;\n};\nname = Products;\nsourceTree = \"<group>\";\n};\n+ 7F16EB09224ED3270008E483 /* Products */ = {\n+ isa = PBXGroup;\n+ children = (\n+ 7F16EB0E224ED3270008E483 /* libRCTOrientation.a */,\n+ );\n+ name = Products;\n+ sourceTree = \"<group>\";\n+ };\n7F347C162242A05200F313CE /* Products */ = {\nisa = PBXGroup;\nchildren = (\nE0952482A8094CE88F96C0EB /* libRNGestureHandler.a */,\n7AAA81E566EC47C883CDFA61 /* libRNScreens.a */,\n47C86914FEF44D79AD04F880 /* libFastImage.a */,\n+ 99A8CC0EA47F466EAD201409 /* libRCTOrientation.a */,\n);\nname = \"Recovered References\";\nsourceTree = \"<group>\";\nisa = PBXGroup;\nchildren = (\n7FA2ABDA218E3FC5008EF068 /* libRNGestureHandler.a */,\n+ 7F16EA63224EBBC00008E483 /* libRNGestureHandler-tvOS.a */,\n);\nname = Products;\nsourceTree = \"<group>\";\nED28C047C454400D87062E8C /* RNGestureHandler.xcodeproj */,\nBA72871056D240AEB0706398 /* RNScreens.xcodeproj */,\n7FA344AAF237451CB8B3424B /* FastImage.xcodeproj */,\n+ 443E4D8DC396450F8F664A5D /* RCTOrientation.xcodeproj */,\n);\nname = Libraries;\nsourceTree = \"<group>\";\ndevelopmentRegion = English;\nhasScannedForEncodings = 0;\nknownRegions = (\n+ English,\nen,\nBase,\n);\nProductGroup = 00C302D41ABCB9D200DB3ED1 /* Products */;\nProjectRef = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */;\n},\n+ {\n+ ProductGroup = 7F16EB09224ED3270008E483 /* Products */;\n+ ProjectRef = 443E4D8DC396450F8F664A5D /* RCTOrientation.xcodeproj */;\n+ },\n{\nProductGroup = 139105B71AF99BAD00B5F7CC /* Products */;\nProjectRef = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */;\nremoteRef = 7F033BB11F01B5E100700D63 /* PBXContainerItemProxy */;\nsourceTree = BUILT_PRODUCTS_DIR;\n};\n+ 7F16EA63224EBBC00008E483 /* libRNGestureHandler-tvOS.a */ = {\n+ isa = PBXReferenceProxy;\n+ fileType = archive.ar;\n+ path = \"libRNGestureHandler-tvOS.a\";\n+ remoteRef = 7F16EA62224EBBC00008E483 /* PBXContainerItemProxy */;\n+ sourceTree = BUILT_PRODUCTS_DIR;\n+ };\n+ 7F16EB0E224ED3270008E483 /* libRCTOrientation.a */ = {\n+ isa = PBXReferenceProxy;\n+ fileType = archive.ar;\n+ path = libRCTOrientation.a;\n+ remoteRef = 7F16EB0D224ED3270008E483 /* PBXContainerItemProxy */;\n+ sourceTree = BUILT_PRODUCTS_DIR;\n+ };\n7F347C1A2242A05200F313CE /* libFastImage.a */ = {\nisa = PBXReferenceProxy;\nfileType = archive.ar;\n\"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**\",\n\"$(SRCROOT)/../node_modules/react-native-screens/ios\",\n\"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**\",\n+ \"$(SRCROOT)/../node_modules/react-native-orientation-locker/iOS/RCTOrientation\",\n);\nINFOPLIST_FILE = SquadCalTests/Info.plist;\nIPHONEOS_DEPLOYMENT_TARGET = 9.0;\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**\",\n\"$(SRCROOT)/../node_modules/react-native-screens/ios\",\n\"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**\",\n+ \"$(SRCROOT)/../node_modules/react-native-orientation-locker/iOS/RCTOrientation\",\n);\nINFOPLIST_FILE = SquadCalTests/Info.plist;\nIPHONEOS_DEPLOYMENT_TARGET = 9.0;\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**\",\n\"$(SRCROOT)/../node_modules/react-native-screens/ios\",\n\"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**\",\n+ \"$(SRCROOT)/../node_modules/react-native-orientation-locker/iOS/RCTOrientation\",\n);\nINFOPLIST_FILE = SquadCal/Info.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**\",\n\"$(SRCROOT)/../node_modules/react-native-screens/ios\",\n\"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**\",\n+ \"$(SRCROOT)/../node_modules/react-native-orientation-locker/iOS/RCTOrientation\",\n);\nINFOPLIST_FILE = SquadCal/Info.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**\",\n\"$(SRCROOT)/../node_modules/react-native-screens/ios\",\n\"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**\",\n+ \"$(SRCROOT)/../node_modules/react-native-orientation-locker/iOS/RCTOrientation\",\n);\nINFOPLIST_FILE = \"SquadCal-tvOS/Info.plist\";\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(SRCROOT)/../node_modules/react-native-gesture-handler/ios/**\",\n\"$(SRCROOT)/../node_modules/react-native-screens/ios\",\n\"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**\",\n+ \"$(SRCROOT)/../node_modules/react-native-orientation-locker/iOS/RCTOrientation\",\n);\nINFOPLIST_FILE = \"SquadCal-tvOS/Info.plist\";\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nPRODUCT_BUNDLE_IDENTIFIER = \"com.facebook.REACT.SquadCal-tvOSTests\";\nPRODUCT_NAME = \"$(TARGET_NAME)\";\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nPRODUCT_BUNDLE_IDENTIFIER = \"com.facebook.REACT.SquadCal-tvOSTests\";\nPRODUCT_NAME = \"$(TARGET_NAME)\";\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal/AppDelegate.m",
"new_path": "native/ios/SquadCal/AppDelegate.m",
"diff": "#import <React/RCTLinkingManager.h>\n#import \"RNNotifications.h\"\n#import \"RNSplashScreen.h\"\n+#import \"Orientation.h\"\n@implementation AppDelegate\n[RNNotifications didReceiveLocalNotification:notification];\n}\n+- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {\n+ return [Orientation getOrientation];\n+}\n+\n@end\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal/Info.plist",
"new_path": "native/ios/SquadCal/Info.plist",
"diff": "</dict>\n</dict>\n</dict>\n+ <key>NSLocationAlwaysUsageDescription</key>\n+ <string>React Native binary makes Apple think we use this, but we don't.</string>\n<key>NSLocationWhenInUseUsageDescription</key>\n<string>React Native binary makes Apple think we use this, but we don't.</string>\n<key>UIAppFonts</key>\n<key>UISupportedInterfaceOrientations</key>\n<array>\n<string>UIInterfaceOrientationPortrait</string>\n+ <string>UIInterfaceOrientationLandscapeLeft</string>\n+ <string>UIInterfaceOrientationLandscapeRight</string>\n</array>\n<key>UIViewControllerBasedStatusBarAppearance</key>\n<false/>\n- <key>NSLocationAlwaysUsageDescription</key>\n- <string>React Native binary makes Apple think we use this, but we don't.</string>\n</dict>\n</plist>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -30,6 +30,7 @@ import {\nPanGestureHandler,\nState as GestureState,\n} from 'react-native-gesture-handler';\n+import Orientation from 'react-native-orientation-locker';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -227,6 +228,12 @@ class MultimediaModal extends React.PureComponent<Props> {\nthis.centerY.setValue(this.centerYNum);\n}\n+ componentDidMount() {\n+ if (MultimediaModal.isActive(this.props)) {\n+ Orientation.unlockAllOrientations();\n+ }\n+ }\n+\ncomponentDidUpdate(prevProps: Props) {\nif (\nthis.props.screenDimensions !== prevProps.screenDimensions ||\n@@ -234,6 +241,14 @@ class MultimediaModal extends React.PureComponent<Props> {\n) {\nthis.updateCenter();\n}\n+\n+ const isActive = MultimediaModal.isActive(this.props);\n+ const wasActive = MultimediaModal.isActive(prevProps);\n+ if (isActive && !wasActive) {\n+ Orientation.unlockAllOrientations();\n+ } else if (!isActive && wasActive) {\n+ Orientation.lockToPortrait();\n+ }\n}\nget screenDimensions(): Dimensions {\n@@ -294,9 +309,9 @@ class MultimediaModal extends React.PureComponent<Props> {\n};\n}\n- get isActive() {\n- const { index } = this.props.scene;\n- return index === this.props.transitionProps.index;\n+ static isActive(props) {\n+ const { index } = props.scene;\n+ return index === props.transitionProps.index;\n}\nget contentContainerStyle() {\n@@ -308,7 +323,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nconst bottom = fullScreenHeight - verticalBounds.y - verticalBounds.height;\n// margin will clip, but padding won't\n- const verticalStyle = this.isActive\n+ const verticalStyle = MultimediaModal.isActive(this.props)\n? { paddingTop: top, paddingBottom: bottom }\n: { marginTop: top, marginBottom: bottom };\nreturn [ styles.contentContainer, verticalStyle ];\n@@ -316,7 +331,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nrender() {\nconst { media } = this.props.navigation.state.params;\n- const statusBar = this.isActive\n+ const statusBar = MultimediaModal.isActive(this.props)\n? <ConnectedStatusBar barStyle=\"light-content\" />\n: null;\nconst backdropStyle = { opacity: this.progress };\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react-native-keychain\": \"^3.0.0\",\n\"react-native-notifications\": \"git+https://git@github.com/ashoat/react-native-notifications.git\",\n\"react-native-onepassword\": \"^1.0.6\",\n+ \"react-native-orientation-locker\": \"^1.1.5\",\n\"react-native-screens\": \"1.0.0-alpha.22\",\n\"react-native-segmented-control-tab\": \"^3.2.1\",\n\"react-native-splash-screen\": \"^3.1.1\",\n"
},
{
"change_type": "MODIFY",
"old_path": "yarn.lock",
"new_path": "yarn.lock",
"diff": "@@ -10044,6 +10044,11 @@ react-native-onepassword@^1.0.6:\ndependencies:\n\"1PasswordExtension\" \"git+https://github.com/jjshammas/onepassword-app-extension.git\"\n+react-native-orientation-locker@^1.1.5:\n+ version \"1.1.5\"\n+ resolved \"https://registry.yarnpkg.com/react-native-orientation-locker/-/react-native-orientation-locker-1.1.5.tgz#695babee0e0b97a9620a12bb677792d0b9b88ef8\"\n+ integrity sha512-RY2kwXK1SNq8+nQN0xVCTdi0A08FnUtzR4dOOEm2dGUUIcxSqnseE7adx5cr+oqwd0WUqb043MS+NKDPMUCmMA==\n+\nreact-native-safe-area-view@^0.13.0:\nversion \"0.13.1\"\nresolved \"https://registry.yarnpkg.com/react-native-safe-area-view/-/react-native-safe-area-view-0.13.1.tgz#834bbb6d22f76a7ff07de56725ee5667ba1386b0\"\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Allow non-portrait orientation in MultimediaModal |
129,187 | 29.03.2019 19:21:03 | 14,400 | 72af7b9f71f25679ad96ce7545aac16e467178e3 | [native] Fix react-native-gesture-handler on Android | [
{
"change_type": "MODIFY",
"old_path": "native/android/app/src/main/java/org/squadcal/MainActivity.java",
"new_path": "native/android/app/src/main/java/org/squadcal/MainActivity.java",
"diff": "@@ -6,6 +6,10 @@ import android.os.Bundle;\nimport android.content.Intent;\nimport android.content.res.Configuration;\n+import com.facebook.react.ReactActivityDelegate;\n+import com.facebook.react.ReactRootView;\n+import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;\n+\npublic class MainActivity extends ReactFragmentActivity {\n/**\n@@ -37,4 +41,14 @@ public class MainActivity extends ReactFragmentActivity {\nthis.sendBroadcast(intent);\n}\n+ @Override\n+ protected ReactActivityDelegate createReactActivityDelegate() {\n+ return new ReactActivityDelegate(this, getMainComponentName()) {\n+ @Override\n+ protected ReactRootView createRootView() {\n+ return new RNGestureHandlerEnabledRootView(MainActivity.this);\n+ }\n+ };\n+ }\n+\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Fix react-native-gesture-handler on Android |
129,187 | 29.03.2019 22:20:25 | 14,400 | c28be5798b9b771fa23650fb2003ca1ad62fbc55 | [native] Recenter MultimediaModal after gestures | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -21,6 +21,7 @@ import {\nStyleSheet,\nTouchableWithoutFeedback,\nAnimated,\n+ Easing,\nTouchableOpacity,\n} from 'react-native';\nimport PropTypes from 'prop-types';\n@@ -398,13 +399,18 @@ class MultimediaModal extends React.PureComponent<Props> {\nthis.curScaleNum *= scale;\nthis.curScale.setValue(this.curScaleNum);\n- this.pinchScale.setValue(1);\n// Keep this logic in sync with pinchX/pinchY definitions in constructor\nthis.curXNum += (1 - scale) * (focalX - this.curXNum - this.centerXNum);\nthis.curYNum += (1 - scale) * (focalY - this.curYNum - this.centerYNum);\nthis.curX.setValue(this.curXNum);\nthis.curY.setValue(this.curYNum);\n+\n+ this.pinchScale.setValue(1);\n+ this.pinchFocalX.setValue(0);\n+ this.pinchFocalY.setValue(0);\n+\n+ this.recenter();\n}\nonPanHandlerStateChange = (\n@@ -419,12 +425,116 @@ class MultimediaModal extends React.PureComponent<Props> {\nif (state === GestureState.ACTIVE || oldState !== GestureState.ACTIVE) {\nreturn;\n}\n+\nthis.curXNum += translationX;\nthis.curYNum += translationY;\nthis.curX.setValue(this.curXNum);\nthis.curY.setValue(this.curYNum);\n+\nthis.panX.setValue(0);\nthis.panY.setValue(0);\n+\n+ this.recenter();\n+ }\n+\n+ // Figures out what we need to add to this.curX to make it \"centered\"\n+ get deltaX() {\n+ if (this.curXNum === 0) {\n+ return 0;\n+ }\n+\n+ const nextScale = Math.max(this.curScaleNum, 1);\n+ const { width } = this.imageDimensions;\n+ const apparentWidth = nextScale * width;\n+ const screenWidth = this.screenDimensions.width;\n+ if (apparentWidth < screenWidth) {\n+ return this.curXNum * -1;\n+ }\n+\n+ const horizPop = (apparentWidth - screenWidth) / 2;\n+ const deltaLeft = this.curXNum - horizPop;\n+ if (deltaLeft > 0) {\n+ return deltaLeft * -1;\n+ }\n+\n+ const deltaRight = this.curXNum + horizPop;\n+ if (deltaRight < 0) {\n+ return deltaRight * -1;\n+ }\n+\n+ return 0;\n+ }\n+\n+ // Figures out what we need to add to this.curY to make it \"centered\"\n+ get deltaY() {\n+ if (this.curYNum === 0) {\n+ return 0;\n+ }\n+\n+ const nextScale = Math.max(this.curScaleNum, 1);\n+ const { height } = this.imageDimensions;\n+ const apparentHeight = nextScale * height;\n+ const screenHeight = this.screenDimensions.height\n+ + this.props.contentVerticalOffset + contentBottomOffset;\n+ if (apparentHeight < screenHeight) {\n+ return this.curYNum * -1;\n+ }\n+\n+ const vertPop = (apparentHeight - screenHeight) / 2;\n+ const deltaTop = this.curYNum - vertPop;\n+ if (deltaTop > 0) {\n+ return deltaTop * -1;\n+ }\n+\n+ const deltaBottom = this.curYNum + vertPop;\n+ if (deltaBottom < 0) {\n+ return deltaBottom * -1;\n+ }\n+\n+ return 0;\n+ }\n+\n+ recenter() {\n+ const nextScale = Math.max(this.curScaleNum, 1);\n+ const { deltaX, deltaY } = this;\n+\n+ const animations = [];\n+ const config = {\n+ duration: 250,\n+ useNativeDriver: true,\n+ easing: Easing.out(Easing.ease),\n+ };\n+ if (nextScale !== this.curScaleNum) {\n+ this.curScaleNum = nextScale;\n+ animations.push(\n+ Animated.timing(\n+ this.curScale,\n+ { ...config, toValue: this.curScaleNum },\n+ ),\n+ );\n+ }\n+ if (deltaX !== 0) {\n+ this.curXNum += deltaX;\n+ animations.push(\n+ Animated.timing(\n+ this.curX,\n+ { ...config, toValue: this.curXNum },\n+ ),\n+ );\n+ }\n+ if (deltaY !== 0) {\n+ this.curYNum += deltaY;\n+ animations.push(\n+ Animated.timing(\n+ this.curY,\n+ { ...config, toValue: this.curYNum },\n+ ),\n+ );\n+ }\n+\n+ if (animations.length > 0) {\n+ Animated.parallel(animations).start();\n+ }\n}\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Recenter MultimediaModal after gestures |
129,187 | 30.03.2019 01:39:11 | 14,400 | a9bb25593b8ff419522ae74dfa765bffd1663738 | [native] Downgrade to | [
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react-native-notifications\": \"git+https://git@github.com/ashoat/react-native-notifications.git\",\n\"react-native-onepassword\": \"^1.0.6\",\n\"react-native-orientation-locker\": \"^1.1.5\",\n- \"react-native-screens\": \"1.0.0-alpha.22\",\n+ \"react-native-screens\": \"1.0.0-alpha.17\",\n\"react-native-segmented-control-tab\": \"^3.2.1\",\n\"react-native-splash-screen\": \"^3.1.1\",\n\"react-native-vector-icons\": \"^4.5.0\",\n"
},
{
"change_type": "MODIFY",
"old_path": "yarn.lock",
"new_path": "yarn.lock",
"diff": "@@ -10056,10 +10056,10 @@ react-native-safe-area-view@^0.13.0:\ndependencies:\nhoist-non-react-statics \"^2.3.1\"\n-react-native-screens@1.0.0-alpha.22:\n- version \"1.0.0-alpha.22\"\n- resolved \"https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-1.0.0-alpha.22.tgz#7a120377b52aa9bbb94d0b8541a014026be9289b\"\n- integrity sha512-kSyAt0AeVU6N7ZonfV6dP6iZF8B7Bce+tk3eujXhzBGsLg0VSLnU7uE9VqJF0xdQrHR91ZjGgVMieo/8df9KTA==\n+react-native-screens@1.0.0-alpha.17:\n+ version \"1.0.0-alpha.17\"\n+ resolved \"https://registry.yarnpkg.com/react-native-screens/-/react-native-screens-1.0.0-alpha.17.tgz#8c1a7224b967c476670963fce7d06b946e7158e9\"\n+ integrity sha512-BvLtqbMpteXsY3XofCCX0c2LM6X14PhjN5FZraROEXuEnw8n8ImDTuXxUPDYZqq2Wjb1bLlm1zE5+c6dcGlY+Q==\n\"react-native-screens@^1.0.0 || ^1.0.0-alpha\":\nversion \"1.0.0-alpha.16\"\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Downgrade to react-native-screens@1.0.0-alpha.17
https://github.com/kmagiera/react-native-screens/issues/61 |
129,187 | 30.03.2019 01:56:45 | 14,400 | 81d383cf67a1d35d86d54b6b1378921c173f282c | [native] Fix some ref cases broken by earlier commit
was the culprit | [
{
"change_type": "MODIFY",
"old_path": "native/account/log-in-panel-container.react.js",
"new_path": "native/account/log-in-panel-container.react.js",
"diff": "@@ -36,6 +36,7 @@ type Props = {|\nopacityValue: Animated.Value,\nforgotPasswordLinkOpacity: Animated.Value,\nlogInState: StateContainer<LogInState>,\n+ innerRef: (container: ?LogInPanelContainer) => void,\n// Redux state\ndimensions: Dimensions,\n|};\n@@ -52,6 +53,7 @@ class LogInPanelContainer extends React.PureComponent<Props, State> {\nopacityValue: PropTypes.object.isRequired,\nforgotPasswordLinkOpacity: PropTypes.object.isRequired,\nlogInState: stateContainerPropType.isRequired,\n+ innerRef: PropTypes.func.isRequired,\ndimensions: dimensionsPropType.isRequired,\n};\nstate = {\n@@ -61,6 +63,14 @@ class LogInPanelContainer extends React.PureComponent<Props, State> {\n};\nlogInPanel: ?InnerLogInPanel = null;\n+ componentDidMount() {\n+ this.props.innerRef(this);\n+ }\n+\n+ componentWillUnmount() {\n+ this.props.innerRef(null);\n+ }\n+\nrender() {\nconst windowWidth = this.props.dimensions.width;\nconst logInPanelDynamicStyle = {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -596,7 +596,7 @@ class LoggedOutModal extends React.PureComponent<Props, State> {\nopacityValue={this.state.panelOpacity}\nforgotPasswordLinkOpacity={this.state.forgotPasswordLinkOpacity}\nlogInState={this.state.logInState}\n- ref={this.logInPanelContainerRef}\n+ innerRef={this.logInPanelContainerRef}\n/>\n);\n} else if (this.state.mode === \"register\") {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/compose-thread.react.js",
"new_path": "native/chat/compose-thread.react.js",
"diff": "@@ -328,7 +328,7 @@ class InnerComposeThread extends React.PureComponent<Props, State> {\nonChangeText={this.setUsernameInputText}\nlabelExtractor={this.tagDataLabelExtractor}\ninputProps={inputProps}\n- ref={this.tagInputRef}\n+ innerRef={this.tagInputRef}\n/>\n</View>\n</View>\n"
},
{
"change_type": "MODIFY",
"old_path": "native/chat/settings/add-users-modal.react.js",
"new_path": "native/chat/settings/add-users-modal.react.js",
"diff": "@@ -240,7 +240,7 @@ class AddUsersModal extends React.PureComponent<Props, State> {\ndefaultInputWidth={160}\nmaxHeight={36}\ninputProps={tagInputProps}\n- ref={this.tagInputRef}\n+ innerRef={this.tagInputRef}\n/>\n<UserList\nuserInfos={this.state.userSearchResults}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/components/tag-input.react.js",
"new_path": "native/components/tag-input.react.js",
"diff": "@@ -89,6 +89,7 @@ type Props<T> = {\n* value and the new value, which looks sketchy.\n*/\ndefaultInputWidth: number,\n+ innerRef?: (tagInput: ?TagInput<T>) => void,\n// Redux state\ndimensions: Dimensions,\n};\n@@ -114,6 +115,7 @@ class TagInput<T> extends React.PureComponent<Props<T>, State> {\nmaxHeight: PropTypes.number,\nonHeightChange: PropTypes.func,\ndefaultInputWidth: PropTypes.number,\n+ innerRef: PropTypes.func,\ndimensions: dimensionsPropType.isRequired,\n};\nwrapperWidth: number;\n@@ -159,6 +161,18 @@ class TagInput<T> extends React.PureComponent<Props<T>, State> {\nthis.wrapperWidth = props.dimensions.width;\n}\n+ componentDidMount() {\n+ if (this.props.innerRef) {\n+ this.props.innerRef(this);\n+ }\n+ }\n+\n+ componentWillUnmount() {\n+ if (this.props.innerRef) {\n+ this.props.innerRef(null);\n+ }\n+ }\n+\ncomponentWillReceiveProps(nextProps: Props<T>) {\nconst inputWidth = TagInput.inputWidth(\nnextProps.text,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Fix some ref cases broken by earlier commit
6ef25752b36aac5f3c69b2532ac259896b71e768 was the culprit |
129,187 | 30.03.2019 02:07:15 | 14,400 | 8c134c5609d06db2eb4a9afe29dddde95d57a67d | [native] Use this.props in MessageListContainer threadInfo comparison
Otherwise we can get in an infinite loop because prevProps will never have the updated value | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-container.react.js",
"new_path": "native/chat/message-list-container.react.js",
"diff": "@@ -161,7 +161,7 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n}\ncomponentDidUpdate(prevProps: Props) {\n- const oldThreadInfo = MessageListContainer.getThreadInfo(prevProps);\n+ const oldThreadInfo = MessageListContainer.getThreadInfo(this.props);\nconst newThreadInfo = this.props.threadInfo;\nconst threadInfoChanged = !_isEqual(newThreadInfo)(oldThreadInfo);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use this.props in MessageListContainer threadInfo comparison
Otherwise we can get in an infinite loop because prevProps will never have the updated value |
129,187 | 01.04.2019 14:27:01 | 14,400 | 56f6215a9e24b5032ed28810b7cbd4b1cc92c63e | [native] Use simultaneousHandlers in MultimediaModal
Enables pan/pinch interplay on Android. | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -95,6 +95,7 @@ class MultimediaModal extends React.PureComponent<Props> {\ncenterX = new Animated.Value(0);\ncenterY = new Animated.Value(0);\n+ pinchHandler: React.Ref<PinchGestureHandler> = React.createRef();\npinchScale = new Animated.Value(1);\npinchFocalX = new Animated.Value(0);\npinchFocalY = new Animated.Value(0);\n@@ -366,11 +367,14 @@ class MultimediaModal extends React.PureComponent<Props> {\n<PinchGestureHandler\nonGestureEvent={this.pinchEvent}\nonHandlerStateChange={this.onPinchHandlerStateChange}\n+ ref={this.pinchHandler}\n>\n<Animated.View style={styles.container}>\n<PanGestureHandler\nonGestureEvent={this.panEvent}\nonHandlerStateChange={this.onPanHandlerStateChange}\n+ simultaneousHandlers={this.pinchHandler}\n+ avgTouches\n>\n{view}\n</PanGestureHandler>\n@@ -397,6 +401,10 @@ class MultimediaModal extends React.PureComponent<Props> {\nreturn;\n}\n+ this.pinchScale.setValue(1);\n+ this.pinchFocalX.setValue(0);\n+ this.pinchFocalY.setValue(0);\n+\nthis.curScaleNum *= scale;\nthis.curScale.setValue(this.curScaleNum);\n@@ -406,10 +414,6 @@ class MultimediaModal extends React.PureComponent<Props> {\nthis.curX.setValue(this.curXNum);\nthis.curY.setValue(this.curYNum);\n- this.pinchScale.setValue(1);\n- this.pinchFocalX.setValue(0);\n- this.pinchFocalY.setValue(0);\n-\nthis.recenter();\n}\n@@ -426,14 +430,14 @@ class MultimediaModal extends React.PureComponent<Props> {\nreturn;\n}\n+ this.panX.setValue(0);\n+ this.panY.setValue(0);\n+\nthis.curXNum += translationX;\nthis.curYNum += translationY;\nthis.curX.setValue(this.curXNum);\nthis.curY.setValue(this.curYNum);\n- this.panX.setValue(0);\n- this.panY.setValue(0);\n-\nthis.recenter();\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Use simultaneousHandlers in MultimediaModal
Enables pan/pinch interplay on Android. |
129,187 | 01.04.2019 14:32:51 | 14,400 | 3c95fd495debfdcbaa2180ae74390f65b6ea0b9b | [native] Hack to get around incorrect focal values on Android | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -23,6 +23,7 @@ import {\nAnimated,\nEasing,\nTouchableOpacity,\n+ Platform,\n} from 'react-native';\nimport PropTypes from 'prop-types';\nimport Icon from 'react-native-vector-icons/Feather';\n@@ -220,6 +221,11 @@ class MultimediaModal extends React.PureComponent<Props> {\n),\n),\n);\n+\n+ if (Platform.OS === \"android\") {\n+ this.pinchFocalX.addListener(() => { });\n+ this.pinchFocalY.addListener(() => { });\n+ }\n}\nupdateCenter() {\n@@ -396,11 +402,18 @@ class MultimediaModal extends React.PureComponent<Props> {\nfocalY: number,\n} },\n) => {\n- const { state, oldState, scale, focalX, focalY } = event.nativeEvent;\n+ const { state, oldState, scale } = event.nativeEvent;\nif (state === GestureState.ACTIVE || oldState !== GestureState.ACTIVE) {\nreturn;\n}\n+ // https://github.com/kmagiera/react-native-gesture-handler/issues/546\n+ let { focalX, focalY } = event.nativeEvent;\n+ if (Platform.OS === \"android\") {\n+ focalX = this.pinchFocalX.__getValue();\n+ focalY = this.pinchFocalY.__getValue();\n+ }\n+\nthis.pinchScale.setValue(1);\nthis.pinchFocalX.setValue(0);\nthis.pinchFocalY.setValue(0);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Hack to get around incorrect focal values on Android
https://github.com/kmagiera/react-native-gesture-handler/issues/546 |
129,187 | 01.04.2019 15:19:12 | 14,400 | 7c9445922cc223671892bca62fa11fa6472188a3 | [native] Only reset MultimediaModal's curNum constants after recenter finishes
This allows pan and pinch handlers to call `recenter` at the same time without issue. | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -522,35 +522,39 @@ class MultimediaModal extends React.PureComponent<Props> {\neasing: Easing.out(Easing.ease),\n};\nif (nextScale !== this.curScaleNum) {\n- this.curScaleNum = nextScale;\nanimations.push(\nAnimated.timing(\nthis.curScale,\n- { ...config, toValue: this.curScaleNum },\n+ { ...config, toValue: nextScale },\n),\n);\n}\nif (deltaX !== 0) {\n- this.curXNum += deltaX;\nanimations.push(\nAnimated.timing(\nthis.curX,\n- { ...config, toValue: this.curXNum },\n+ { ...config, toValue: this.curXNum + deltaX },\n),\n);\n}\nif (deltaY !== 0) {\n- this.curYNum += deltaY;\nanimations.push(\nAnimated.timing(\nthis.curY,\n- { ...config, toValue: this.curYNum },\n+ { ...config, toValue: this.curYNum + deltaY },\n),\n);\n}\nif (animations.length > 0) {\n- Animated.parallel(animations).start();\n+ Animated.parallel(animations).start(({ finished }) => {\n+ if (!finished) {\n+ return;\n+ }\n+ this.curScaleNum = nextScale;\n+ this.curXNum += deltaX;\n+ this.curYNum += deltaY;\n+ });\n}\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Only reset MultimediaModal's curNum constants after recenter finishes
This allows pan and pinch handlers to call `recenter` at the same time without issue. |
129,187 | 01.04.2019 16:25:31 | 14,400 | 9a30f6e1167d6292600a0ac32958a0c39c7b3e70 | [native] Fix MessageListContainer setState recursion loop
Diff Redux with its own old state to avoid infinite nested `setState` calls. | [
{
"change_type": "MODIFY",
"old_path": "native/chat/message-list-container.react.js",
"new_path": "native/chat/message-list-container.react.js",
"diff": "@@ -20,7 +20,6 @@ import type { ChatMessageInfoItemWithHeight } from './message.react';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\nimport { View, Platform, StyleSheet, ActivityIndicator } from 'react-native';\n-import _isEqual from 'lodash/fp/isEqual';\nimport _differenceWith from 'lodash/fp/differenceWith';\nimport invariant from 'invariant';\n@@ -161,12 +160,10 @@ class MessageListContainer extends React.PureComponent<Props, State> {\n}\ncomponentDidUpdate(prevProps: Props) {\n- const oldThreadInfo = MessageListContainer.getThreadInfo(this.props);\n- const newThreadInfo = this.props.threadInfo;\n- const threadInfoChanged = !_isEqual(newThreadInfo)(oldThreadInfo);\n-\n- if (newThreadInfo && threadInfoChanged) {\n- this.props.navigation.setParams({ threadInfo: newThreadInfo });\n+ const oldReduxThreadInfo = prevProps.threadInfo;\n+ const newReduxThreadInfo = this.props.threadInfo;\n+ if (newReduxThreadInfo && newReduxThreadInfo !== oldReduxThreadInfo) {\n+ this.props.navigation.setParams({ threadInfo: newReduxThreadInfo });\n}\nconst oldListData = prevProps.messageListData;\n@@ -180,7 +177,10 @@ class MessageListContainer extends React.PureComponent<Props, State> {\nif (!newListData) {\nreturn;\n}\n- if (newListData === oldListData && !threadInfoChanged) {\n+\n+ const oldNavThreadInfo = MessageListContainer.getThreadInfo(prevProps);\n+ const newNavThreadInfo = MessageListContainer.getThreadInfo(this.props);\n+ if (newListData === oldListData && newNavThreadInfo === oldNavThreadInfo) {\nreturn;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Fix MessageListContainer setState recursion loop
Diff Redux with its own old state to avoid infinite nested `setState` calls. |
129,187 | 01.04.2019 16:26:30 | 14,400 | c3eeedb9bd352f9b9f11ad5859875cf7e70c1a05 | [lib] Avoid changing threadStore in updateActivityActionTypes.success | [
{
"change_type": "MODIFY",
"old_path": "lib/reducers/thread-reducer.js",
"new_path": "lib/reducers/thread-reducer.js",
"diff": "@@ -325,15 +325,24 @@ export default function reduceThreadInfos(\n],\n};\n} else if (action.type === updateActivityActionTypes.success) {\n- const newThreadInfos = { ...state.threadInfos };\n+ const updatedThreadInfos = {};\nfor (let setToUnread of action.payload.result.unfocusedToUnread) {\n- const threadInfo = newThreadInfos[setToUnread];\n- if (threadInfo) {\n- threadInfo.currentUser.unread = true;\n+ const threadInfo = state.threadInfos[setToUnread];\n+ if (threadInfo && !threadInfo.currentUser.unread) {\n+ updatedThreadInfos[setToUnread] = {\n+ ...threadInfo,\n+ currentUser: {\n+ ...threadInfo.currentUser,\n+ unread: true,\n+ },\n+ };\n+ }\n}\n+ if (Object.keys(updatedThreadInfos).length === 0) {\n+ return state;\n}\nreturn {\n- threadInfos: newThreadInfos,\n+ threadInfos: { ...state.threadInfos, ...updatedThreadInfos },\ninconsistencyResponses: state.inconsistencyResponses,\n};\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Avoid changing threadStore in updateActivityActionTypes.success |
129,187 | 01.04.2019 17:25:17 | 14,400 | 7a8c74391884da9a72261c6af29adb27d1e54f77 | [native] Get rid of tap-backdrop-to-close in MultimediaModal | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -20,7 +20,6 @@ import {\nView,\nText,\nStyleSheet,\n- TouchableWithoutFeedback,\nAnimated,\nEasing,\nTouchableOpacity,\n@@ -352,9 +351,6 @@ class MultimediaModal extends React.PureComponent<Props> {\n{statusBar}\n<Animated.View style={[ styles.backdrop, backdropStyle ]} />\n<View style={this.contentContainerStyle}>\n- <TouchableWithoutFeedback onPress={this.close}>\n- <View style={styles.cover} />\n- </TouchableWithoutFeedback>\n<Animated.View style={this.imageContainerStyle}>\n<Multimedia media={media} spinnerColor=\"white\" />\n</Animated.View>\n@@ -578,13 +574,6 @@ const styles = StyleSheet.create({\nflex: 1,\noverflow: \"hidden\",\n},\n- cover: {\n- position: \"absolute\",\n- top: 0,\n- bottom: 0,\n- left: 0,\n- right: 0,\n- },\ncloseButtonContainer: {\nposition: \"absolute\",\nright: 12,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Get rid of tap-backdrop-to-close in MultimediaModal |
129,187 | 01.04.2019 18:55:07 | 14,400 | 786484cd7cbb9798e38d97c71c8b0ad8351587c6 | [native] Reset focal coordinates to center in MultimediaModal | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -413,8 +413,8 @@ class MultimediaModal extends React.PureComponent<Props> {\n}\nthis.pinchScale.setValue(1);\n- this.pinchFocalX.setValue(0);\n- this.pinchFocalY.setValue(0);\n+ this.pinchFocalX.setValue(this.centerXNum);\n+ this.pinchFocalY.setValue(this.centerYNum);\nthis.curScaleNum *= scale;\nthis.curScale.setValue(this.curScaleNum);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Reset focal coordinates to center in MultimediaModal |
129,187 | 02.04.2019 17:32:07 | 14,400 | d1f896213f673a6dc40052f3dd814d6f6942290b | [lib] Use HTTP for CREATE_REPORT
Sockets don't even support customizable timeouts yet, so we definitely shouldn't be using them for error reports. Plus error reports commonly happen in situations where the socket is down... | [
{
"change_type": "MODIFY",
"old_path": "lib/types/endpoints.js",
"new_path": "lib/types/endpoints.js",
"diff": "@@ -9,7 +9,8 @@ export type SocketAPIHandler = (request: APIRequest) => Promise<Object>;\nexport type Endpoint =\n| HTTPOnlyEndpoint\n| SocketOnlyEndpoint\n- | SocketSafeEndpoint;\n+ | HTTPPreferredEndpoint\n+ | SocketPreferredEndpoint;\n// Endpoints that can cause session changes should occur over HTTP, since the\n// socket code does not currently support changing sessions. In the future they\n@@ -44,7 +45,7 @@ const socketOnlyEndpoints = Object.freeze({\n});\ntype SocketOnlyEndpoint = $Values<typeof socketOnlyEndpoints>;\n-const socketSafeEndpoints = Object.freeze({\n+const socketPreferredEndpoints = Object.freeze({\nUPDATE_USER_SUBSCRIPTION: 'update_user_subscription',\nUPDATE_DEVICE_TOKEN: 'update_device_token',\nUPDATE_ACCOUNT: 'update_account',\n@@ -71,15 +72,28 @@ const socketSafeEndpoints = Object.freeze({\nCREATE_ERROR_REPORT: 'create_error_report',\nFETCH_ERROR_REPORT_INFOS: 'fetch_error_report_infos',\nREQUEST_ACCESS: 'request_access',\n- CREATE_REPORT: 'create_report',\nCREATE_MULTIMEDIA_MESSAGE: 'create_multimedia_message',\nDELETE_UPLOAD: 'delete_upload',\n});\n-type SocketSafeEndpoint = $Values<typeof socketSafeEndpoints>;\n+type SocketPreferredEndpoint = $Values<typeof socketPreferredEndpoints>;\n+\n+const httpPreferredEndpoints = Object.freeze({\n+ CREATE_REPORT: 'create_report',\n+});\n+type HTTPPreferredEndpoint = $Values<typeof httpPreferredEndpoints>;\n+\n+const socketPreferredEndpointSet = new Set([\n+ ...Object.values(socketOnlyEndpoints),\n+ ...Object.values(socketPreferredEndpoints),\n+]);\n+export function endpointIsSocketPreferred(endpoint: Endpoint): bool {\n+ return socketPreferredEndpointSet.has(endpoint);\n+}\nconst socketSafeEndpointSet = new Set([\n- ...Object.values(socketSafeEndpoints),\n...Object.values(socketOnlyEndpoints),\n+ ...Object.values(socketPreferredEndpoints),\n+ ...Object.values(httpPreferredEndpoints),\n]);\nexport function endpointIsSocketSafe(endpoint: Endpoint): bool {\nreturn socketSafeEndpointSet.has(endpoint);\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/utils/fetch-json.js",
"new_path": "lib/utils/fetch-json.js",
"diff": "import {\ntype Endpoint,\ntype SocketAPIHandler,\n- endpointIsSocketSafe,\n+ endpointIsSocketPreferred,\nendpointIsSocketOnly,\n} from '../types/endpoints';\nimport type {\n@@ -84,7 +84,7 @@ async function fetchJSON(\n}\nif (\n- endpointIsSocketSafe(endpoint) &&\n+ endpointIsSocketPreferred(endpoint) &&\nconnectionStatus === \"connected\" &&\nsocketAPIHandler\n) {\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Use HTTP for CREATE_REPORT
Sockets don't even support customizable timeouts yet, so we definitely shouldn't be using them for error reports. Plus error reports commonly happen in situations where the socket is down... |
129,187 | 03.04.2019 12:05:47 | 14,400 | c3f25a266a4a582b509cca34a2bf163cec51871f | [native] Move DimensionsUpdater into new redux folder | [
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "@@ -87,7 +87,7 @@ import { AppRouteName } from './navigation/route-names';\nimport MessageStorePruner from './chat/message-store-pruner.react';\nimport DisconnectedBarVisibilityHandler\nfrom './navigation/disconnected-bar-visibility-handler.react';\n-import DimensionsUpdater from './dimensions-updater.react';\n+import DimensionsUpdater from './redux/dimensions-updater.react';\nimport Socket from './socket.react';\nif (Platform.OS === \"android\") {\n"
},
{
"change_type": "RENAME",
"old_path": "native/dimensions-updater.react.js",
"new_path": "native/redux/dimensions-updater.react.js",
"diff": "@@ -9,7 +9,7 @@ import { Dimensions as NativeDimensions } from 'react-native';\nimport { connect } from 'lib/utils/redux-utils';\n-import { updateDimensionsActiveType } from './navigation/action-types';\n+import { updateDimensionsActiveType } from '../navigation/action-types';\ntype Props = {|\n// Redux dispatch functions\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Move DimensionsUpdater into new redux folder |
129,187 | 03.04.2019 12:13:15 | 14,400 | eb9f11f8f572d83e4938755592861c4b723c5f70 | [native] Move action-types to new redux folder | [
{
"change_type": "MODIFY",
"old_path": "native/account/logged-out-modal.react.js",
"new_path": "native/account/logged-out-modal.react.js",
"diff": "@@ -56,7 +56,7 @@ import { createIsForegroundSelector } from '../selectors/nav-selectors';\nimport {\nnavigateToAppActionType,\nresetUserStateActionType,\n-} from '../navigation/action-types';\n+} from '../redux/action-types';\nimport { splashBackgroundURI } from './background-info';\nimport { splashStyleSelector } from '../splash';\nimport {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/account/verification-modal.react.js",
"new_path": "native/account/verification-modal.react.js",
"diff": "@@ -51,7 +51,7 @@ import { dimensionsSelector } from '../selectors/dimension-selectors';\nimport ConnectedStatusBar from '../connected-status-bar.react';\nimport ResetPasswordPanel from './reset-password-panel.react';\nimport { createIsForegroundSelector } from '../selectors/nav-selectors';\n-import { navigateToAppActionType } from '../navigation/action-types';\n+import { navigateToAppActionType } from '../redux/action-types';\nimport { splashBackgroundURI } from './background-info';\nimport { splashStyleSelector } from '../splash';\nimport {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "@@ -67,7 +67,7 @@ import {\nrecordNotifPermissionAlertActionType,\nrecordAndroidNotificationActionType,\nclearAndroidNotificationActionType,\n-} from './navigation/action-types';\n+} from './redux/action-types';\nimport { store, appBecameInactive } from './redux/redux-setup';\nimport ConnectedStatusBar from './connected-status-bar.react';\nimport {\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation/navigation-setup.js",
"new_path": "native/navigation/navigation-setup.js",
"diff": "@@ -93,7 +93,7 @@ import {\nimport {\nhandleURLActionType,\nnavigateToAppActionType,\n-} from './action-types';\n+} from '../redux/action-types';\nimport ThreadPickerModal from '../calendar/thread-picker-modal.react';\nimport AddUsersModal from '../chat/settings/add-users-modal.react';\nimport CustomServerModal from '../more/custom-server-modal.react';\n"
},
{
"change_type": "MODIFY",
"old_path": "native/push/android.js",
"new_path": "native/push/android.js",
"diff": "@@ -5,7 +5,7 @@ import FCM from 'react-native-fcm';\nimport {\nrecordAndroidNotificationActionType,\nclearAndroidNotificationActionType,\n-} from '../navigation/action-types';\n+} from '../redux/action-types';\nasync function requestAndroidPushPermissions(): Promise<?string> {\nconst requestResult = await FCM.requestPermissions();\n"
},
{
"change_type": "RENAME",
"old_path": "native/navigation/action-types.js",
"new_path": "native/redux/action-types.js",
"diff": ""
},
{
"change_type": "MODIFY",
"old_path": "native/redux/dimensions-updater.react.js",
"new_path": "native/redux/dimensions-updater.react.js",
"diff": "@@ -9,7 +9,7 @@ import { Dimensions as NativeDimensions } from 'react-native';\nimport { connect } from 'lib/utils/redux-utils';\n-import { updateDimensionsActiveType } from '../navigation/action-types';\n+import { updateDimensionsActiveType } from './action-types';\ntype Props = {|\n// Redux dispatch functions\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux/redux-setup.js",
"new_path": "native/redux/redux-setup.js",
"diff": "@@ -61,7 +61,7 @@ import {\nrecordAndroidNotificationActionType,\nclearAndroidNotificationActionType,\nupdateDimensionsActiveType,\n-} from '../navigation/action-types';\n+} from './action-types';\nimport {\ndefaultNavInfo,\nreduceNavInfo,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Move action-types to new redux folder |
129,187 | 03.04.2019 12:27:08 | 14,400 | dc1452c1f30dc790e1d98a2f3098018fb93814b2 | [native] Introduce ConnectivityUpdater and store connectivity state in Redux | [
{
"change_type": "MODIFY",
"old_path": "native/app.react.js",
"new_path": "native/app.react.js",
"diff": "@@ -88,6 +88,7 @@ import MessageStorePruner from './chat/message-store-pruner.react';\nimport DisconnectedBarVisibilityHandler\nfrom './navigation/disconnected-bar-visibility-handler.react';\nimport DimensionsUpdater from './redux/dimensions-updater.react';\n+import ConnectivityUpdater from './redux/connectivity-updater.react';\nimport Socket from './socket.react';\nif (Platform.OS === \"android\") {\n@@ -672,6 +673,7 @@ class AppWithNavigationState extends React.PureComponent<Props> {\n<MessageStorePruner />\n<DisconnectedBarVisibilityHandler />\n<DimensionsUpdater />\n+ <ConnectivityUpdater />\n</View>\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/navigation/disconnected-bar-visibility-handler.react.js",
"new_path": "native/navigation/disconnected-bar-visibility-handler.react.js",
"diff": "@@ -7,10 +7,13 @@ import {\n} from 'lib/types/socket-types';\nimport type { DispatchActionPayload } from 'lib/utils/action-utils';\nimport type { AppState } from '../redux/redux-setup';\n+import {\n+ type ConnectivityInfo,\n+ connectivityInfoPropType,\n+} from '../types/connectivity';\nimport * as React from 'react';\nimport PropTypes from 'prop-types';\n-import { NetInfo } from 'react-native';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -19,6 +22,7 @@ type Props = {|\nshowDisconnectedBar: bool,\nconnectionStatus: ConnectionStatus,\nsomeRequestIsLate: bool,\n+ connectivity: ConnectivityInfo,\n// Redux dispatch functions\ndispatchActionPayload: DispatchActionPayload,\n|};\n@@ -28,6 +32,7 @@ class DisconnectedBarVisibilityHandler extends React.PureComponent<Props> {\nshowDisconnectedBar: PropTypes.bool.isRequired,\nconnectionStatus: connectionStatusPropType.isRequired,\nsomeRequestIsLate: PropTypes.bool.isRequired,\n+ connectivity: connectivityInfoPropType.isRequired,\ndispatchActionPayload: PropTypes.func.isRequired,\n};\nnetworkActive = true;\n@@ -47,28 +52,22 @@ class DisconnectedBarVisibilityHandler extends React.PureComponent<Props> {\n}\ncomponentDidMount() {\n- NetInfo.isConnected.addEventListener(\n- 'connectionChange',\n- this.handleConnectionChange,\n- );\n- NetInfo.isConnected.fetch().then(this.handleConnectionChange);\n+ this.handleConnectionChange();\n}\n- componentWillUnmount() {\n- NetInfo.isConnected.removeEventListener(\n- 'connectionChange',\n- this.handleConnectionChange,\n- );\n- }\n-\n- handleConnectionChange = isConnected => {\n- this.networkActive = isConnected;\n+ handleConnectionChange() {\n+ this.networkActive = this.props.connectivity.connected;\nif (!this.networkActive) {\nthis.setDisconnected(true);\n}\n}\ncomponentDidUpdate(prevProps: Props) {\n+ const { connected } = this.props.connectivity;\n+ if (connected !== prevProps.connectivity.connected) {\n+ this.handleConnectionChange();\n+ }\n+\nconst { connectionStatus: status, someRequestIsLate } = this.props;\nif (status === \"connected\" && prevProps.connectionStatus !== \"connected\") {\n// Sometimes NetInfo misses the network coming back online for some\n@@ -95,6 +94,7 @@ export default connect(\nshowDisconnectedBar: state.connection.showDisconnectedBar,\nconnectionStatus: state.connection.status,\nsomeRequestIsLate: state.connection.lateResponses.length !== 0,\n+ connectivity: state.connectivity,\n}),\nnull,\ntrue,\n"
},
{
"change_type": "MODIFY",
"old_path": "native/persist.js",
"new_path": "native/persist.js",
"diff": "@@ -21,6 +21,7 @@ const baseBlacklist = [\n'foreground',\n'messageSentFromRoute',\n'dimensions',\n+ 'connectivity',\n];\nconst blacklist = __DEV__\n? baseBlacklist\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux/action-types.js",
"new_path": "native/redux/action-types.js",
"diff": "@@ -9,3 +9,4 @@ export const recordAndroidNotificationActionType =\n\"RECORD_ANDROID_NOTIFICATION\";\nexport const clearAndroidNotificationActionType = \"CLEAR_ANDROID_NOTIFICATION\";\nexport const updateDimensionsActiveType = \"UPDATE_DIMENSIONS\";\n+export const updateConnectivityActiveType = \"UPDATE_CONNECTIVITY\";\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/redux/connectivity-updater.react.js",
"diff": "+// @flow\n+\n+import type { DispatchActionPayload } from 'lib/utils/action-utils';\n+import type { AppState } from './redux-setup';\n+import {\n+ type ConnectivityInfo,\n+ connectivityInfoPropType,\n+} from '../types/connectivity';\n+\n+import * as React from 'react';\n+import PropTypes from 'prop-types';\n+import { NetInfo } from 'react-native';\n+\n+import { connect } from 'lib/utils/redux-utils';\n+\n+import { updateConnectivityActiveType } from './action-types';\n+\n+type Props = {|\n+ // Redux state\n+ connectivity: ConnectivityInfo,\n+ // Redux dispatch functions\n+ dispatchActionPayload: DispatchActionPayload,\n+|};\n+class ConnectivityUpdater extends React.PureComponent<Props> {\n+\n+ static propTypes = {\n+ connectivity: connectivityInfoPropType.isRequired,\n+ dispatchActionPayload: PropTypes.func.isRequired,\n+ };\n+\n+ componentDidMount() {\n+ NetInfo.addEventListener('connectionChange', this.onConnectionChange);\n+ NetInfo.getConnectionInfo().then(this.onConnectionChange);\n+ }\n+\n+ componentWillUnmount() {\n+ NetInfo.removeEventListener('connectionChange', this.onConnectionChange);\n+ }\n+\n+ onConnectionChange = ({ type }) => {\n+ const connected = type !== 'none' && type !== 'unknown';\n+ const hasWiFi = type === \"wifi\";\n+ if (\n+ connected === this.props.connectivity.connected &&\n+ hasWiFi === this.props.connectivity.hasWiFi\n+ ) {\n+ return;\n+ }\n+ this.props.dispatchActionPayload(\n+ updateConnectivityActiveType,\n+ { connected, hasWiFi },\n+ );\n+ }\n+\n+ render() {\n+ return null;\n+ }\n+\n+}\n+\n+export default connect(\n+ (state: AppState) => ({\n+ connectivity: state.connectivity,\n+ }),\n+ null,\n+ true,\n+)(ConnectivityUpdater);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/redux/redux-setup.js",
"new_path": "native/redux/redux-setup.js",
"diff": "@@ -25,6 +25,10 @@ import {\nincrementalStateSyncActionType,\n} from 'lib/types/socket-types';\nimport type { Dimensions } from 'lib/types/media-types';\n+import {\n+ type ConnectivityInfo,\n+ defaultConnectivityInfo,\n+} from '../types/connectivity';\nimport React from 'react';\nimport invariant from 'invariant';\n@@ -61,6 +65,7 @@ import {\nrecordAndroidNotificationActionType,\nclearAndroidNotificationActionType,\nupdateDimensionsActiveType,\n+ updateConnectivityActiveType,\n} from './action-types';\nimport {\ndefaultNavInfo,\n@@ -116,6 +121,7 @@ export type AppState = {|\n_persist: ?PersistState,\nsessionID?: void,\ndimensions: Dimensions,\n+ connectivity: ConnectivityInfo,\n|};\nconst { height, width } = NativeDimensions.get('window');\n@@ -156,6 +162,7 @@ const defaultState = ({\nnextLocalID: 0,\n_persist: null,\ndimensions: { height, width },\n+ connectivity: defaultConnectivityInfo,\n}: AppState);\nfunction chatRouteFromNavInfo(navInfo: NavInfo): NavigationStateRoute {\n@@ -208,6 +215,11 @@ function reducer(state: AppState = defaultState, action: *) {\n...state,\ndimensions: action.payload,\n};\n+ } else if (action.type === updateConnectivityActiveType) {\n+ return {\n+ ...state,\n+ connectivity: action.payload,\n+ };\n}\nconst oldState = state;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/types/connectivity.js",
"diff": "+// @flow\n+\n+import PropTypes from 'prop-types';\n+\n+export type ConnectivityInfo = {|\n+ connected: bool,\n+ hasWiFi: bool,\n+|};\n+\n+export const connectivityInfoPropType = PropTypes.shape({\n+ connected: PropTypes.bool.isRequired,\n+ hasWiFi: PropTypes.bool.isRequired,\n+});\n+\n+export const defaultConnectivityInfo = {\n+ connected: true,\n+ hasWiFi: false,\n+};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Introduce ConnectivityUpdater and store connectivity state in Redux |
129,187 | 03.04.2019 21:01:52 | 14,400 | cc9689a5b12ccfb60529226236ea47ff16806460 | [native] Don't pass null onPress to DefaultNotificationBody | [
{
"change_type": "MODIFY",
"old_path": "native/push/notification-body.react.js",
"new_path": "native/push/notification-body.react.js",
"diff": "import type { ImageSource } from 'react-native/Libraries/Image/ImageSource';\n-import React from 'react';\n+import * as React from 'react';\nimport { View, StyleSheet, DeviceInfo, Platform } from 'react-native';\nimport DefaultNotificationBody\nfrom 'react-native-in-app-notification/DefaultNotificationBody';\n@@ -17,23 +17,38 @@ type Props = {\nvibrate: bool,\nonClose: () => void,\n};\n-function NotificationBody(props: Props) {\n+class NotificationBody extends React.PureComponent<Props> {\n+\n+ render() {\nreturn (\n<View style={styles.notificationBodyContainer}>\n<DefaultNotificationBody\n- title={props.title}\n- message={props.message}\n- onPress={props.onPress}\n- isOpen={props.isOpen}\n- iconApp={props.iconApp}\n- icon={props.icon}\n- vibrate={props.vibrate}\n- onClose={props.onClose}\n+ title={this.props.title}\n+ message={this.props.message}\n+ onPress={this.onPress}\n+ isOpen={this.props.isOpen}\n+ iconApp={this.props.iconApp}\n+ icon={this.props.icon}\n+ vibrate={this.props.vibrate}\n+ onClose={this.props.onClose}\n/>\n</View>\n);\n}\n+ onPress = () => {\n+ const { onPress } = this.props;\n+ if (onPress) {\n+ // onPress is null when the notification is animating closed. It's not\n+ // clear why this needs to be the case, but isn't fixed as of\n+ // react-native-in-app-notification@3.0.0. Especially weird given that\n+ // DefaultNotificationBody crashes if passed a null onPress and pressed.\n+ onPress();\n+ }\n+ }\n+\n+}\n+\nconst styles = StyleSheet.create({\nnotificationBodyContainer: {\nflex: 1,\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Don't pass null onPress to DefaultNotificationBody |
129,187 | 04.04.2019 16:56:23 | 14,400 | 4e36fe0b89e99847fe361bb1829e3e35bc9409c6 | [lib] Make sure socket can close after timeout
Also includes a dumb typo fix in `reduxLogger`. | [
{
"change_type": "MODIFY",
"old_path": "lib/socket/inflight-requests.js",
"new_path": "lib/socket/inflight-requests.js",
"diff": "@@ -223,6 +223,10 @@ class InflightRequests {\nrejectAll(error: Error) {\nfor (let inflightRequest of this.data) {\n+ // Though the promise rejection below should call clearRequest when it's\n+ // caught in fetchResponse, that doesn't happen synchronously. Socket\n+ // won't close unless all requests are resolved, so we clear immediately\n+ this.clearRequest(inflightRequest);\nconst { reject } = inflightRequest;\nreject(error);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "lib/utils/redux-logger.js",
"new_path": "lib/utils/redux-logger.js",
"diff": "@@ -46,7 +46,7 @@ class ReduxLogger {\nconst sanitized = sanitizeAction(action);\nlet summary, length, depth = 3;\ndo {\n- summary = inspect(action, { depth });\n+ summary = inspect(sanitized, { depth });\nlength = summary.length;\ndepth--;\n} while (length > maxActionSummaryLength && depth > 0);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [lib] Make sure socket can close after timeout
Also includes a dumb typo fix in `reduxLogger`. |
129,187 | 04.04.2019 17:22:46 | 14,400 | 0caada4ec8935c70235ec7aca7673480042c6ba6 | [native] Center Multimedia loading spinner | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia.react.js",
"new_path": "native/media/multimedia.react.js",
"diff": "@@ -93,6 +93,10 @@ const styles = StyleSheet.create({\n},\nspinnerContainer: {\nposition: 'absolute',\n+ top: 0,\n+ bottom: 0,\n+ left: 0,\n+ right: 0,\njustifyContent: 'center',\nalignItems: 'center',\n},\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Center Multimedia loading spinner |
129,187 | 05.04.2019 11:01:41 | 14,400 | 28a523a495b755d4f97d5df24419fac0acb569b1 | [native] Leave vertical space for offsets in MultimediaModal | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -489,19 +489,20 @@ class MultimediaModal extends React.PureComponent<Props> {\nconst nextScale = Math.max(this.curScaleNum, 1);\nconst { height } = this.imageDimensions;\nconst apparentHeight = nextScale * height;\n- const screenHeight = this.screenDimensions.height\n- + this.props.contentVerticalOffset + contentBottomOffset;\n- if (apparentHeight < screenHeight) {\n+ const viewableScreenHeight = this.screenDimensions.height;\n+ if (apparentHeight < viewableScreenHeight) {\nreturn this.curYNum * -1;\n}\n- const vertPop = (apparentHeight - screenHeight) / 2;\n- const deltaTop = this.curYNum - vertPop;\n+ const fullScreenHeight = viewableScreenHeight\n+ + this.props.contentVerticalOffset + contentBottomOffset;\n+ const vertPop = (apparentHeight - fullScreenHeight) / 2;\n+ const deltaTop = this.curYNum - vertPop - this.props.contentVerticalOffset;\nif (deltaTop > 0) {\nreturn deltaTop * -1;\n}\n- const deltaBottom = this.curYNum + vertPop;\n+ const deltaBottom = this.curYNum + vertPop + contentBottomOffset;\nif (deltaBottom < 0) {\nreturn deltaBottom * -1;\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Leave vertical space for offsets in MultimediaModal |
129,187 | 05.04.2019 12:01:01 | 14,400 | 88f7e9899b7f5fbf7b43c97c5e58de2cbb30f1ab | [native] Simplify centerDeltaX/centerDeltaY calculations in MultimediaModal
Also extracts out `horizontalPanSpace`/`verticalPanSpace`, so we can use them elsewhere. | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -452,67 +452,66 @@ class MultimediaModal extends React.PureComponent<Props> {\nthis.recenter();\n}\n- // Figures out what we need to add to this.curX to make it \"centered\"\n- get deltaX() {\n- if (this.curXNum === 0) {\n- return 0;\n+ get nextScale() {\n+ return Math.max(this.curScaleNum, 1);\n}\n- const nextScale = Math.max(this.curScaleNum, 1);\n+ // How much space do we have to pan the image horizontally?\n+ get horizontalPanSpace() {\n+ const { nextScale } = this;\nconst { width } = this.imageDimensions;\nconst apparentWidth = nextScale * width;\nconst screenWidth = this.screenDimensions.width;\n- if (apparentWidth < screenWidth) {\n- return this.curXNum * -1;\n+ const horizPop = (apparentWidth - screenWidth) / 2;\n+ return Math.max(horizPop, 0);\n}\n- const horizPop = (apparentWidth - screenWidth) / 2;\n- const deltaLeft = this.curXNum - horizPop;\n- if (deltaLeft > 0) {\n- return deltaLeft * -1;\n+ // How much space do we have to pan the image vertically?\n+ get verticalPanSpace() {\n+ const { nextScale } = this;\n+ const { height } = this.imageDimensions;\n+ const apparentHeight = nextScale * height;\n+ const screenHeight = this.screenDimensions.height;\n+ const vertPop = (apparentHeight - screenHeight) / 2;\n+ return Math.max(vertPop, 0);\n}\n- const deltaRight = this.curXNum + horizPop;\n- if (deltaRight < 0) {\n- return deltaRight * -1;\n+ // Figures out what we need to add to this.curX to make it \"centered\"\n+ get centerDeltaX() {\n+ const { curXNum, horizontalPanSpace } = this;\n+\n+ const rightOverscroll = curXNum - horizontalPanSpace;\n+ if (rightOverscroll > 0) {\n+ return rightOverscroll * -1;\n}\n- return 0;\n+ const leftOverscroll = curXNum + horizontalPanSpace;\n+ if (leftOverscroll < 0) {\n+ return leftOverscroll * -1;\n}\n- // Figures out what we need to add to this.curY to make it \"centered\"\n- get deltaY() {\n- if (this.curYNum === 0) {\nreturn 0;\n}\n- const nextScale = Math.max(this.curScaleNum, 1);\n- const { height } = this.imageDimensions;\n- const apparentHeight = nextScale * height;\n- const viewableScreenHeight = this.screenDimensions.height;\n- if (apparentHeight < viewableScreenHeight) {\n- return this.curYNum * -1;\n- }\n+ // Figures out what we need to add to this.curY to make it \"centered\"\n+ get centerDeltaY() {\n+ const { curYNum, verticalPanSpace } = this;\n- const fullScreenHeight = viewableScreenHeight\n- + this.props.contentVerticalOffset + contentBottomOffset;\n- const vertPop = (apparentHeight - fullScreenHeight) / 2;\n- const deltaTop = this.curYNum - vertPop - this.props.contentVerticalOffset;\n- if (deltaTop > 0) {\n- return deltaTop * -1;\n+ const bottomOverscroll = curYNum - verticalPanSpace;\n+ if (bottomOverscroll > 0) {\n+ return bottomOverscroll * -1;\n}\n- const deltaBottom = this.curYNum + vertPop + contentBottomOffset;\n- if (deltaBottom < 0) {\n- return deltaBottom * -1;\n+ const topOverscroll = curYNum + verticalPanSpace;\n+ if (topOverscroll < 0) {\n+ return topOverscroll * -1;\n}\nreturn 0;\n}\nrecenter() {\n- const nextScale = Math.max(this.curScaleNum, 1);\n- const { deltaX, deltaY } = this;\n+ const { nextScale, centerDeltaX, centerDeltaY } = this;\nconst animations = [];\nconst config = {\n@@ -528,19 +527,19 @@ class MultimediaModal extends React.PureComponent<Props> {\n),\n);\n}\n- if (deltaX !== 0) {\n+ if (centerDeltaX !== 0) {\nanimations.push(\nAnimated.timing(\nthis.curX,\n- { ...config, toValue: this.curXNum + deltaX },\n+ { ...config, toValue: this.curXNum + centerDeltaX },\n),\n);\n}\n- if (deltaY !== 0) {\n+ if (centerDeltaY !== 0) {\nanimations.push(\nAnimated.timing(\nthis.curY,\n- { ...config, toValue: this.curYNum + deltaY },\n+ { ...config, toValue: this.curYNum + centerDeltaY },\n),\n);\n}\n@@ -551,8 +550,8 @@ class MultimediaModal extends React.PureComponent<Props> {\nreturn;\n}\nthis.curScaleNum = nextScale;\n- this.curXNum += deltaX;\n- this.curYNum += deltaY;\n+ this.curXNum += centerDeltaX;\n+ this.curYNum += centerDeltaY;\n});\n}\n}\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Simplify centerDeltaX/centerDeltaY calculations in MultimediaModal
Also extracts out `horizontalPanSpace`/`verticalPanSpace`, so we can use them elsewhere. |
129,187 | 05.04.2019 15:49:54 | 14,400 | cd54331489ec1b2436feaadb002323598bf568b5 | [native] react-native-reanimated | [
{
"change_type": "MODIFY",
"old_path": "native/android/app/build.gradle",
"new_path": "native/android/app/build.gradle",
"diff": "@@ -147,6 +147,7 @@ android {\n}\ndependencies {\n+ implementation project(':react-native-reanimated')\nimplementation project(':react-native-orientation-locker')\nimplementation project(':react-native-fast-image')\ncompile project(':react-native-screens')\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java",
"new_path": "native/android/app/src/main/java/org/squadcal/MainApplication.java",
"diff": "@@ -3,6 +3,7 @@ package org.squadcal;\nimport android.app.Application;\nimport com.facebook.react.ReactApplication;\n+import com.swmansion.reanimated.ReanimatedPackage;\nimport org.wonday.orientation.OrientationPackage;\nimport com.dylanvann.fastimage.FastImageViewPackage;\nimport com.swmansion.rnscreens.RNScreensPackage;\n@@ -32,6 +33,7 @@ public class MainApplication extends Application implements ReactApplication {\nprotected List<ReactPackage> getPackages() {\nreturn Arrays.<ReactPackage>asList(\nnew MainReactPackage(),\n+ new ReanimatedPackage(),\nnew OrientationPackage(),\nnew FastImageViewPackage(),\nnew RNScreensPackage(),\n"
},
{
"change_type": "MODIFY",
"old_path": "native/android/settings.gradle",
"new_path": "native/android/settings.gradle",
"diff": "rootProject.name = 'SquadCal'\n+include ':react-native-reanimated'\n+project(':react-native-reanimated').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-reanimated/android')\ninclude ':react-native-orientation-locker'\nproject(':react-native-orientation-locker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-orientation-locker/android')\ninclude ':react-native-fast-image'\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/flow-typed/npm/react-native-reanimated_vx.x.x.js",
"diff": "+// flow-typed signature: feef1aa13026cab685e240b7a200fcbf\n+// flow-typed version: <<STUB>>/react-native-reanimated_v^1.0.0/flow_v0.86.0\n+\n+/**\n+ * This is an autogenerated libdef stub for:\n+ *\n+ * 'react-native-reanimated'\n+ *\n+ * Fill this stub out by replacing all the `any` types.\n+ *\n+ * Once filled out, we encourage you to share your work with the\n+ * community by sending a pull request to:\n+ * https://github.com/flowtype/flow-typed\n+ */\n+\n+declare module 'react-native-reanimated' {\n+ declare module.exports: any;\n+}\n+\n+/**\n+ * We include stubs for each file inside this npm package in case you need to\n+ * require those files directly. Feel free to delete any files that aren't\n+ * needed.\n+ */\n+declare module 'react-native-reanimated/src/__mocks__/ReanimatedEventEmitter' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/__mocks__/ReanimatedModule' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/Animated' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/Animated.test' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/animations/Animation' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/animations/backwardCompatibleAnimWrapper' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/animations/decay' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/animations/DecayAnimation' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/animations/spring' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/animations/SpringAnimation' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/animations/timing' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/animations/TimingAnimation' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/base' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/ConfigHelper' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/__mocks__/AnimatedProps' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedAlways' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedBezier' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedBlock' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedCall' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedClock' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedClockTest' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedCode' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedConcat' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedCond' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedDebug' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedEvent' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedNode' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedOperator' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedProps' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedSet' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedStartClock' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedStopClock' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedStyle' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedTransform' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/AnimatedValue' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/core/createEventObjectProxyPolyfill' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/createAnimatedComponent' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/derived/__mocks__/evaluateOnce' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/derived/abs' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/derived/acc' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/derived/ceil' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/derived/color' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/derived/diff' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/derived/diffClamp' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/derived/evaluateOnce' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/derived/floor' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/derived/index' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/derived/interpolate' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/derived/interpolate.test' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/derived/max' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/derived/min' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/derived/onChange' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/Easing' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/ReanimatedEventEmitter' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/ReanimatedModule' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/SpringConfig' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/Transitioning' {\n+ declare module.exports: any;\n+}\n+\n+declare module 'react-native-reanimated/src/utils' {\n+ declare module.exports: any;\n+}\n+\n+// Filename aliases\n+declare module 'react-native-reanimated/src/__mocks__/ReanimatedEventEmitter.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/__mocks__/ReanimatedEventEmitter'>;\n+}\n+declare module 'react-native-reanimated/src/__mocks__/ReanimatedModule.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/__mocks__/ReanimatedModule'>;\n+}\n+declare module 'react-native-reanimated/src/Animated.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/Animated'>;\n+}\n+declare module 'react-native-reanimated/src/Animated.test.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/Animated.test'>;\n+}\n+declare module 'react-native-reanimated/src/animations/Animation.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/animations/Animation'>;\n+}\n+declare module 'react-native-reanimated/src/animations/backwardCompatibleAnimWrapper.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/animations/backwardCompatibleAnimWrapper'>;\n+}\n+declare module 'react-native-reanimated/src/animations/decay.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/animations/decay'>;\n+}\n+declare module 'react-native-reanimated/src/animations/DecayAnimation.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/animations/DecayAnimation'>;\n+}\n+declare module 'react-native-reanimated/src/animations/spring.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/animations/spring'>;\n+}\n+declare module 'react-native-reanimated/src/animations/SpringAnimation.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/animations/SpringAnimation'>;\n+}\n+declare module 'react-native-reanimated/src/animations/timing.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/animations/timing'>;\n+}\n+declare module 'react-native-reanimated/src/animations/TimingAnimation.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/animations/TimingAnimation'>;\n+}\n+declare module 'react-native-reanimated/src/base.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/base'>;\n+}\n+declare module 'react-native-reanimated/src/ConfigHelper.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/ConfigHelper'>;\n+}\n+declare module 'react-native-reanimated/src/core/__mocks__/AnimatedProps.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/__mocks__/AnimatedProps'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedAlways.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedAlways'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedBezier.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedBezier'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedBlock.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedBlock'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedCall.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedCall'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedClock.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedClock'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedClockTest.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedClockTest'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedCode.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedCode'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedConcat.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedConcat'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedCond.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedCond'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedDebug.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedDebug'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedEvent.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedEvent'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedNode.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedNode'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedOperator.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedOperator'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedProps.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedProps'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedSet.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedSet'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedStartClock.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedStartClock'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedStopClock.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedStopClock'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedStyle.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedStyle'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedTransform.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedTransform'>;\n+}\n+declare module 'react-native-reanimated/src/core/AnimatedValue.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/AnimatedValue'>;\n+}\n+declare module 'react-native-reanimated/src/core/createEventObjectProxyPolyfill.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/core/createEventObjectProxyPolyfill'>;\n+}\n+declare module 'react-native-reanimated/src/createAnimatedComponent.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/createAnimatedComponent'>;\n+}\n+declare module 'react-native-reanimated/src/derived/__mocks__/evaluateOnce.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/derived/__mocks__/evaluateOnce'>;\n+}\n+declare module 'react-native-reanimated/src/derived/abs.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/derived/abs'>;\n+}\n+declare module 'react-native-reanimated/src/derived/acc.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/derived/acc'>;\n+}\n+declare module 'react-native-reanimated/src/derived/ceil.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/derived/ceil'>;\n+}\n+declare module 'react-native-reanimated/src/derived/color.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/derived/color'>;\n+}\n+declare module 'react-native-reanimated/src/derived/diff.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/derived/diff'>;\n+}\n+declare module 'react-native-reanimated/src/derived/diffClamp.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/derived/diffClamp'>;\n+}\n+declare module 'react-native-reanimated/src/derived/evaluateOnce.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/derived/evaluateOnce'>;\n+}\n+declare module 'react-native-reanimated/src/derived/floor.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/derived/floor'>;\n+}\n+declare module 'react-native-reanimated/src/derived/index.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/derived/index'>;\n+}\n+declare module 'react-native-reanimated/src/derived/interpolate.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/derived/interpolate'>;\n+}\n+declare module 'react-native-reanimated/src/derived/interpolate.test.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/derived/interpolate.test'>;\n+}\n+declare module 'react-native-reanimated/src/derived/max.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/derived/max'>;\n+}\n+declare module 'react-native-reanimated/src/derived/min.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/derived/min'>;\n+}\n+declare module 'react-native-reanimated/src/derived/onChange.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/derived/onChange'>;\n+}\n+declare module 'react-native-reanimated/src/Easing.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/Easing'>;\n+}\n+declare module 'react-native-reanimated/src/ReanimatedEventEmitter.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/ReanimatedEventEmitter'>;\n+}\n+declare module 'react-native-reanimated/src/ReanimatedModule.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/ReanimatedModule'>;\n+}\n+declare module 'react-native-reanimated/src/SpringConfig.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/SpringConfig'>;\n+}\n+declare module 'react-native-reanimated/src/Transitioning.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/Transitioning'>;\n+}\n+declare module 'react-native-reanimated/src/utils.js' {\n+ declare module.exports: $Exports<'react-native-reanimated/src/utils'>;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"new_path": "native/ios/SquadCal.xcodeproj/project.pbxproj",
"diff": "569C48070423498795574595 /* EvilIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 3430816A291640AEACA13234 /* EvilIcons.ttf */; };\n5E9157361DD0AC6A00FF2AA8 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */; };\n62E897586C0F47F7AFADFE11 /* libRNExitApp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 95EA49951E064ECB9B1999EA /* libRNExitApp.a */; };\n+ 63CCE55F632C4A96B5BDBFD7 /* libRNReanimated.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 067F7283F74C4423A00B9690 /* libRNReanimated.a */; };\n781ED432789E4AFC93FA578A /* Entypo.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 1E94F1BD692B4E6EBE1BFBFB /* Entypo.ttf */; };\n7E350429243446AAA3856078 /* MaterialCommunityIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 8D919BA72D8545CBBBF6B74F /* MaterialCommunityIcons.ttf */; };\n7F033BB61F01B5E400700D63 /* libOnePassword.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7FB58AD41E80C21000B4C1B1 /* libOnePassword.a */; };\nremoteGlobalIDString = ED296FEE214C9CF800B7C4FE;\nremoteInfo = \"jsiexecutor-tvOS\";\n};\n+ 7F9DDC4D2257D85600CECAC3 /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = 443E4D8DC396450F8F664A5D /* RCTOrientation.xcodeproj */;\n+ proxyType = 2;\n+ remoteGlobalIDString = B59029A92237E1A400A9DA7D;\n+ remoteInfo = \"RCTOrientation-tvOS\";\n+ };\n+ 7F9DDC742257D85600CECAC3 /* PBXContainerItemProxy */ = {\n+ isa = PBXContainerItemProxy;\n+ containerPortal = F1A54F24F713488E94B93044 /* RNReanimated.xcodeproj */;\n+ proxyType = 2;\n+ remoteGlobalIDString = 134814201AA4EA6300B7C361;\n+ remoteInfo = RNReanimated;\n+ };\n7FA2ABCF218E3FC5008EF068 /* PBXContainerItemProxy */ = {\nisa = PBXContainerItemProxy;\ncontainerPortal = 95EEFC35D4D14053ACA7E064 /* RNKeychain.xcodeproj */;\n00E356EE1AD99517003FC87E /* SquadCalTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SquadCalTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };\n00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = \"<group>\"; };\n00E356F21AD99517003FC87E /* SquadCalTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SquadCalTests.m; sourceTree = \"<group>\"; };\n+ 067F7283F74C4423A00B9690 /* libRNReanimated.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNReanimated.a; sourceTree = \"<group>\"; };\n139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTSettings.xcodeproj; path = \"../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj\"; sourceTree = \"<group>\"; };\n139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = \"wrapper.pb-project\"; name = RCTWebSocket.xcodeproj; path = \"../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj\"; sourceTree = \"<group>\"; };\n13B07F961A680F5B00A75B9A /* SquadCal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SquadCal.app; sourceTree = BUILT_PRODUCTS_DIR; };\nEA40FBBA484449FAA8915A48 /* Foundation.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Foundation.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Foundation.ttf\"; sourceTree = \"<group>\"; };\nEBD8879422144B0188A8336F /* Zocial.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Zocial.ttf; path = \"../node_modules/react-native-vector-icons/Fonts/Zocial.ttf\"; sourceTree = \"<group>\"; };\nED28C047C454400D87062E8C /* RNGestureHandler.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = RNGestureHandler.xcodeproj; path = \"../node_modules/react-native-gesture-handler/ios/RNGestureHandler.xcodeproj\"; sourceTree = \"<group>\"; };\n+ F1A54F24F713488E94B93044 /* RNReanimated.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = \"wrapper.pb-project\"; name = RNReanimated.xcodeproj; path = \"../node_modules/react-native-reanimated/ios/RNReanimated.xcodeproj\"; sourceTree = \"<group>\"; };\n/* End PBXFileReference section */\n/* Begin PBXFrameworksBuildPhase section */\nA6EF57DD8BDA4D43812D0B13 /* libRNScreens.a in Frameworks */,\nA4B3D66697E04C11B4167EE7 /* libFastImage.a in Frameworks */,\n1BFB77B74B924FA79ACBC2F6 /* libRCTOrientation.a in Frameworks */,\n+ 63CCE55F632C4A96B5BDBFD7 /* libRNReanimated.a in Frameworks */,\n);\nrunOnlyForDeploymentPostprocessing = 0;\n};\nisa = PBXGroup;\nchildren = (\n7F16EB0E224ED3270008E483 /* libRCTOrientation.a */,\n+ 7F9DDC4E2257D85600CECAC3 /* libRCTOrientation-tvOS.a */,\n);\nname = Products;\nsourceTree = \"<group>\";\n7AAA81E566EC47C883CDFA61 /* libRNScreens.a */,\n47C86914FEF44D79AD04F880 /* libFastImage.a */,\n99A8CC0EA47F466EAD201409 /* libRCTOrientation.a */,\n+ 067F7283F74C4423A00B9690 /* libRNReanimated.a */,\n);\nname = \"Recovered References\";\nsourceTree = \"<group>\";\nname = Products;\nsourceTree = \"<group>\";\n};\n+ 7F9DDC712257D85600CECAC3 /* Products */ = {\n+ isa = PBXGroup;\n+ children = (\n+ 7F9DDC752257D85600CECAC3 /* libRNReanimated.a */,\n+ );\n+ name = Products;\n+ sourceTree = \"<group>\";\n+ };\n7FA2ABD4218E3FC5008EF068 /* Products */ = {\nisa = PBXGroup;\nchildren = (\nBA72871056D240AEB0706398 /* RNScreens.xcodeproj */,\n7FA344AAF237451CB8B3424B /* FastImage.xcodeproj */,\n443E4D8DC396450F8F664A5D /* RCTOrientation.xcodeproj */,\n+ F1A54F24F713488E94B93044 /* RNReanimated.xcodeproj */,\n);\nname = Libraries;\nsourceTree = \"<group>\";\nProductGroup = 7F5B10E52005349D00FE096A /* Products */;\nProjectRef = 143FA99006A442AFB7B24B3A /* RNNotifications.xcodeproj */;\n},\n+ {\n+ ProductGroup = 7F9DDC712257D85600CECAC3 /* Products */;\n+ ProjectRef = F1A54F24F713488E94B93044 /* RNReanimated.xcodeproj */;\n+ },\n{\nProductGroup = 7FA2ABD4218E3FC5008EF068 /* Products */;\nProjectRef = BA72871056D240AEB0706398 /* RNScreens.xcodeproj */;\nremoteRef = 7F761E562201141E001B6FB7 /* PBXContainerItemProxy */;\nsourceTree = BUILT_PRODUCTS_DIR;\n};\n+ 7F9DDC4E2257D85600CECAC3 /* libRCTOrientation-tvOS.a */ = {\n+ isa = PBXReferenceProxy;\n+ fileType = archive.ar;\n+ path = \"libRCTOrientation-tvOS.a\";\n+ remoteRef = 7F9DDC4D2257D85600CECAC3 /* PBXContainerItemProxy */;\n+ sourceTree = BUILT_PRODUCTS_DIR;\n+ };\n+ 7F9DDC752257D85600CECAC3 /* libRNReanimated.a */ = {\n+ isa = PBXReferenceProxy;\n+ fileType = archive.ar;\n+ path = libRNReanimated.a;\n+ remoteRef = 7F9DDC742257D85600CECAC3 /* PBXContainerItemProxy */;\n+ sourceTree = BUILT_PRODUCTS_DIR;\n+ };\n7FA2ABD0218E3FC5008EF068 /* libRNKeychain.a */ = {\nisa = PBXReferenceProxy;\nfileType = archive.ar;\n\"$(SRCROOT)/../node_modules/react-native-screens/ios\",\n\"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**\",\n\"$(SRCROOT)/../node_modules/react-native-orientation-locker/iOS/RCTOrientation\",\n+ \"$(SRCROOT)/../node_modules/react-native-reanimated/ios/**\",\n);\nINFOPLIST_FILE = SquadCalTests/Info.plist;\nIPHONEOS_DEPLOYMENT_TARGET = 9.0;\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(SRCROOT)/../node_modules/react-native-screens/ios\",\n\"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**\",\n\"$(SRCROOT)/../node_modules/react-native-orientation-locker/iOS/RCTOrientation\",\n+ \"$(SRCROOT)/../node_modules/react-native-reanimated/ios/**\",\n);\nINFOPLIST_FILE = SquadCalTests/Info.plist;\nIPHONEOS_DEPLOYMENT_TARGET = 9.0;\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(SRCROOT)/../node_modules/react-native-screens/ios\",\n\"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**\",\n\"$(SRCROOT)/../node_modules/react-native-orientation-locker/iOS/RCTOrientation\",\n+ \"$(SRCROOT)/../node_modules/react-native-reanimated/ios/**\",\n);\nINFOPLIST_FILE = SquadCal/Info.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"$(SRCROOT)/../node_modules/react-native-screens/ios\",\n\"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**\",\n\"$(SRCROOT)/../node_modules/react-native-orientation-locker/iOS/RCTOrientation\",\n+ \"$(SRCROOT)/../node_modules/react-native-reanimated/ios/**\",\n);\nINFOPLIST_FILE = SquadCal/Info.plist;\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"$(SRCROOT)/../node_modules/react-native-screens/ios\",\n\"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**\",\n\"$(SRCROOT)/../node_modules/react-native-orientation-locker/iOS/RCTOrientation\",\n+ \"$(SRCROOT)/../node_modules/react-native-reanimated/ios/**\",\n);\nINFOPLIST_FILE = \"SquadCal-tvOS/Info.plist\";\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"$(SRCROOT)/../node_modules/react-native-screens/ios\",\n\"$(SRCROOT)/../node_modules/react-native-fast-image/ios/FastImage/**\",\n\"$(SRCROOT)/../node_modules/react-native-orientation-locker/iOS/RCTOrientation\",\n+ \"$(SRCROOT)/../node_modules/react-native-reanimated/ios/**\",\n);\nINFOPLIST_FILE = \"SquadCal-tvOS/Info.plist\";\nLD_RUNPATH_SEARCH_PATHS = \"$(inherited) @executable_path/Frameworks\";\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nOTHER_LDFLAGS = (\n\"-ObjC\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nPRODUCT_BUNDLE_IDENTIFIER = \"com.facebook.REACT.SquadCal-tvOSTests\";\nPRODUCT_NAME = \"$(TARGET_NAME)\";\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n\"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n+ \"\\\"$(SRCROOT)/$(TARGET_NAME)\\\"\",\n);\nPRODUCT_BUNDLE_IDENTIFIER = \"com.facebook.REACT.SquadCal-tvOSTests\";\nPRODUCT_NAME = \"$(TARGET_NAME)\";\n"
},
{
"change_type": "MODIFY",
"old_path": "native/media/lightbox-navigator.react.js",
"new_path": "native/media/lightbox-navigator.react.js",
"diff": "@@ -14,13 +14,19 @@ import type {\n} from 'react-navigation';\nimport * as React from 'react';\n-import { View, StyleSheet, Animated, Easing } from 'react-native';\n+import {\n+ View,\n+ StyleSheet,\n+ Animated as BaseAnimated,\n+ Easing as BaseEasing,\n+} from 'react-native';\nimport {\nStackRouter,\ncreateNavigator,\nStackActions,\n} from '@react-navigation/core';\nimport { Transitioner } from 'react-navigation-stack';\n+import Animated, { Easing } from 'react-native-reanimated';\nfunction createLightboxNavigator(\nrouteConfigMap: NavigationRouteConfigMap,\n@@ -59,6 +65,13 @@ type Props = $ReadOnly<{|\n|}>;\nclass Lightbox extends React.PureComponent<Props> {\n+ position: Animated.Value;\n+\n+ constructor(props: Props) {\n+ super(props);\n+ this.position = new Animated.Value(props.navigation.state.index);\n+ }\n+\nrender() {\nreturn (\n<Transitioner\n@@ -66,6 +79,7 @@ class Lightbox extends React.PureComponent<Props> {\nconfigureTransition={this.configureTransition}\nnavigation={this.props.navigation}\ndescriptors={this.props.descriptors}\n+ onTransitionStart={this.onTransitionStart}\nonTransitionEnd={this.onTransitionEnd}\n/>\n);\n@@ -73,11 +87,23 @@ class Lightbox extends React.PureComponent<Props> {\nconfigureTransition = () => ({\nduration: 250,\n- easing: Easing.inOut(Easing.ease),\n- timing: Animated.timing,\n+ easing: BaseEasing.inOut(BaseEasing.ease),\n+ timing: BaseAnimated.timing,\nuseNativeDriver: true,\n})\n+ onTransitionStart = (transitionProps: NavigationTransitionProps) => {\n+ const { index } = transitionProps.navigation.state;\n+ Animated.timing(\n+ this.position,\n+ {\n+ duration: 250,\n+ easing: Easing.inOut(Easing.ease),\n+ toValue: index,\n+ },\n+ ).start();\n+ }\n+\nonTransitionEnd = (transitionProps: NavigationTransitionProps) => {\nif (!transitionProps.navigation.state.isTransitioning) {\nreturn;\n@@ -120,6 +146,7 @@ class Lightbox extends React.PureComponent<Props> {\nnavigation={navigation}\nscene={scene}\ntransitionProps={transitionProps}\n+ position={this.position}\n/>\n</View>\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -20,10 +20,7 @@ import {\nView,\nText,\nStyleSheet,\n- Animated,\n- Easing,\nTouchableOpacity,\n- Platform,\n} from 'react-native';\nimport PropTypes from 'prop-types';\nimport {\n@@ -32,6 +29,7 @@ import {\nState as GestureState,\n} from 'react-native-gesture-handler';\nimport Orientation from 'react-native-orientation-locker';\n+import Animated, { Easing } from 'react-native-reanimated';\nimport { connect } from 'lib/utils/redux-utils';\n@@ -62,6 +60,7 @@ type Props = {|\nnavigation: NavProp,\nscene: NavigationScene,\ntransitionProps: NavigationTransitionProps,\n+ position: Animated.Value,\n// Redux state\nscreenDimensions: Dimensions,\ncontentVerticalOffset: number,\n@@ -85,6 +84,7 @@ class MultimediaModal extends React.PureComponent<Props> {\ngoBack: PropTypes.func.isRequired,\n}).isRequired,\ntransitionProps: PropTypes.object.isRequired,\n+ position: PropTypes.instanceOf(Animated.Value).isRequired,\nscene: PropTypes.object.isRequired,\nscreenDimensions: dimensionsPropType.isRequired,\ncontentVerticalOffset: PropTypes.number.isRequired,\n@@ -99,28 +99,22 @@ class MultimediaModal extends React.PureComponent<Props> {\npinchScale = new Animated.Value(1);\npinchFocalX = new Animated.Value(0);\npinchFocalY = new Animated.Value(0);\n- pinchEvent = Animated.event(\n- [{\n+ pinchEvent = Animated.event([{\nnativeEvent: {\nscale: this.pinchScale,\nfocalX: this.pinchFocalX,\nfocalY: this.pinchFocalY,\n},\n- }],\n- { useNativeDriver: true },\n- );\n+ }]);\npanX = new Animated.Value(0);\npanY = new Animated.Value(0);\n- panEvent = Animated.event(\n- [{\n+ panEvent = Animated.event([{\nnativeEvent: {\ntranslationX: this.panX,\ntranslationY: this.panY,\n},\n- }],\n- { useNativeDriver: true },\n- );\n+ }]);\ncurScaleNum = 1;\ncurXNum = 0;\n@@ -157,20 +151,26 @@ class MultimediaModal extends React.PureComponent<Props> {\n- (top + height / 2),\n);\n- const { position } = props.transitionProps;\n+ const { position } = props;\nconst { index } = props.scene;\n- this.progress = position.interpolate({\n+ this.progress = Animated.interpolate(\n+ position,\n+ {\ninputRange: [ index - 1, index ],\noutputRange: ([ 0, 1 ]: number[]),\nextrapolate: 'clamp',\n- });\n- this.imageContainerOpacity = this.progress.interpolate({\n+ },\n+ );\n+ this.imageContainerOpacity = Animated.interpolate(\n+ this.progress,\n+ {\ninputRange: [ 0, 0.1 ],\noutputRange: ([ 0, 1 ]: number[]),\nextrapolate: 'clamp',\n- });\n+ },\n+ );\n- const reverseProgress = Animated.subtract(1, this.progress);\n+ const reverseProgress = Animated.sub(1, this.progress);\nthis.scale = Animated.add(\nAnimated.multiply(reverseProgress, initialScale),\nAnimated.multiply(\n@@ -180,12 +180,10 @@ class MultimediaModal extends React.PureComponent<Props> {\n);\nthis.pinchX = Animated.multiply(\n- Animated.subtract(1, this.pinchScale),\n- Animated.subtract(\n- Animated.subtract(\n+ Animated.sub(1, this.pinchScale),\n+ Animated.sub(\nthis.pinchFocalX,\nthis.curX,\n- ),\nthis.centerX,\n),\n);\n@@ -195,18 +193,17 @@ class MultimediaModal extends React.PureComponent<Props> {\nthis.progress,\nAnimated.add(\nthis.curX,\n- Animated.add(this.pinchX, this.panX),\n+ this.pinchX,\n+ this.panX,\n),\n),\n);\nthis.pinchY = Animated.multiply(\n- Animated.subtract(1, this.pinchScale),\n- Animated.subtract(\n- Animated.subtract(\n+ Animated.sub(1, this.pinchScale),\n+ Animated.sub(\nthis.pinchFocalY,\nthis.curY,\n- ),\nthis.centerY,\n),\n);\n@@ -216,15 +213,11 @@ class MultimediaModal extends React.PureComponent<Props> {\nthis.progress,\nAnimated.add(\nthis.curY,\n- Animated.add(this.pinchY, this.panY),\n+ this.pinchY,\n+ this.panY,\n),\n),\n);\n-\n- if (Platform.OS === \"android\") {\n- this.pinchFocalX.addListener(() => { });\n- this.pinchFocalY.addListener(() => { });\n- }\n}\nupdateCenter() {\n@@ -400,18 +393,11 @@ class MultimediaModal extends React.PureComponent<Props> {\nfocalY: number,\n} },\n) => {\n- const { state, oldState, scale } = event.nativeEvent;\n+ const { state, oldState, scale, focalX, focalY } = event.nativeEvent;\nif (state === GestureState.ACTIVE || oldState !== GestureState.ACTIVE) {\nreturn;\n}\n- // https://github.com/kmagiera/react-native-gesture-handler/issues/546\n- let { focalX, focalY } = event.nativeEvent;\n- if (Platform.OS === \"android\") {\n- focalX = this.pinchFocalX.__getValue();\n- focalY = this.pinchFocalY.__getValue();\n- }\n-\nthis.pinchScale.setValue(1);\nthis.pinchFocalX.setValue(this.centerXNum);\nthis.pinchFocalY.setValue(this.centerYNum);\n@@ -513,44 +499,40 @@ class MultimediaModal extends React.PureComponent<Props> {\nrecenter() {\nconst { nextScale, centerDeltaX, centerDeltaY } = this;\n- const animations = [];\nconst config = {\nduration: 250,\n- useNativeDriver: true,\neasing: Easing.out(Easing.ease),\n};\nif (nextScale !== this.curScaleNum) {\n- animations.push(\nAnimated.timing(\nthis.curScale,\n{ ...config, toValue: nextScale },\n- ),\n- );\n+ ).start(({ finished }) => {\n+ if (!finished) {\n+ return;\n+ }\n+ this.curScaleNum = nextScale;\n+ });\n}\nif (centerDeltaX !== 0) {\n- animations.push(\nAnimated.timing(\nthis.curX,\n{ ...config, toValue: this.curXNum + centerDeltaX },\n- ),\n- );\n+ ).start(({ finished }) => {\n+ if (!finished) {\n+ return;\n+ }\n+ this.curXNum += centerDeltaX;\n+ });\n}\nif (centerDeltaY !== 0) {\n- animations.push(\nAnimated.timing(\nthis.curY,\n{ ...config, toValue: this.curYNum + centerDeltaY },\n- ),\n- );\n- }\n-\n- if (animations.length > 0) {\n- Animated.parallel(animations).start(({ finished }) => {\n+ ).start(({ finished }) => {\nif (!finished) {\nreturn;\n}\n- this.curScaleNum = nextScale;\n- this.curXNum += centerDeltaX;\nthis.curYNum += centerDeltaY;\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "native/package.json",
"new_path": "native/package.json",
"diff": "\"react-native-notifications\": \"git+https://git@github.com/ashoat/react-native-notifications.git\",\n\"react-native-onepassword\": \"^1.0.6\",\n\"react-native-orientation-locker\": \"^1.1.5\",\n+ \"react-native-reanimated\": \"^1.0.0\",\n\"react-native-screens\": \"1.0.0-alpha.17\",\n\"react-native-segmented-control-tab\": \"^3.2.1\",\n\"react-native-splash-screen\": \"^3.1.1\",\n"
},
{
"change_type": "MODIFY",
"old_path": "yarn.lock",
"new_path": "yarn.lock",
"diff": "@@ -10049,6 +10049,11 @@ react-native-orientation-locker@^1.1.5:\nresolved \"https://registry.yarnpkg.com/react-native-orientation-locker/-/react-native-orientation-locker-1.1.5.tgz#695babee0e0b97a9620a12bb677792d0b9b88ef8\"\nintegrity sha512-RY2kwXK1SNq8+nQN0xVCTdi0A08FnUtzR4dOOEm2dGUUIcxSqnseE7adx5cr+oqwd0WUqb043MS+NKDPMUCmMA==\n+react-native-reanimated@^1.0.0:\n+ version \"1.0.0\"\n+ resolved \"https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-1.0.0.tgz#d4e356e852ec55611de565d8791542eeb25a45ae\"\n+ integrity sha512-jfg+lYZ2QeeV+JMibjXwHoLDZIRVwZT2qdvDDmbAsMmxRNGI95evMPXKWa3BqkzWLb2SlZ2T/MBSGrqt/CiCAQ==\n+\nreact-native-safe-area-view@^0.13.0:\nversion \"0.13.1\"\nresolved \"https://registry.yarnpkg.com/react-native-safe-area-view/-/react-native-safe-area-view-0.13.1.tgz#834bbb6d22f76a7ff07de56725ee5667ba1386b0\"\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] react-native-reanimated |
129,187 | 06.04.2019 01:15:32 | 14,400 | 2fa5f56e3f82bbe07716318f274732e1c42eeade | [native] Redo MultimediaModal animations using Reanimated's declarative style
So much smoother! | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -40,6 +40,96 @@ import {\n} from '../selectors/dimension-selectors';\nimport Multimedia from './multimedia.react';\nimport ConnectedStatusBar from '../connected-status-bar.react';\n+import { clamp } from '../utils/animation-utils';\n+\n+const {\n+ Value,\n+ Clock,\n+ event,\n+ Extrapolate,\n+ set,\n+ cond,\n+ not,\n+ and,\n+ or,\n+ eq,\n+ neq,\n+ add,\n+ sub,\n+ multiply,\n+ divide,\n+ max,\n+ interpolate,\n+ startClock,\n+ stopClock,\n+ clockRunning,\n+ timing,\n+} = Animated;\n+\n+function scaleDelta(value: Value, gestureActive: Value) {\n+ const diffThisFrame = new Value(1);\n+ const prevValue = new Value(1);\n+ return cond(\n+ gestureActive,\n+ [\n+ set(diffThisFrame, divide(value, prevValue)),\n+ set(prevValue, value),\n+ diffThisFrame,\n+ ],\n+ set(prevValue, 1),\n+ );\n+}\n+\n+function panDelta(value: Value, gestureActive: Value) {\n+ const diffThisFrame = new Value(0);\n+ const prevValue = new Value(0);\n+ return cond(\n+ gestureActive,\n+ [\n+ set(diffThisFrame, sub(value, prevValue)),\n+ set(prevValue, value),\n+ diffThisFrame,\n+ ],\n+ set(prevValue, 0),\n+ );\n+}\n+\n+function runTiming(\n+ clock: Clock,\n+ initialValue: Value,\n+ finalValue: Value,\n+): Value {\n+ const state = {\n+ finished: new Value(0),\n+ position: new Value(0),\n+ frameTime: new Value(0),\n+ time: new Value(0),\n+ };\n+ const config = {\n+ toValue: new Value(0),\n+ duration: 250,\n+ easing: Easing.out(Easing.ease),\n+ };\n+ return [\n+ cond(\n+ not(clockRunning(clock)),\n+ [\n+ set(state.finished, 0),\n+ set(state.frameTime, 0),\n+ set(state.time, 0),\n+ set(state.position, initialValue),\n+ set(config.toValue, finalValue),\n+ startClock(clock),\n+ ],\n+ ),\n+ timing(clock, state, config),\n+ cond(\n+ state.finished,\n+ stopClock(clock),\n+ ),\n+ state.position,\n+ ];\n+}\ntype LayoutCoordinates = $ReadOnly<{|\nx: number,\n@@ -60,7 +150,7 @@ type Props = {|\nnavigation: NavProp,\nscene: NavigationScene,\ntransitionProps: NavigationTransitionProps,\n- position: Animated.Value,\n+ position: Value,\n// Redux state\nscreenDimensions: Dimensions,\ncontentVerticalOffset: number,\n@@ -84,148 +174,310 @@ class MultimediaModal extends React.PureComponent<Props> {\ngoBack: PropTypes.func.isRequired,\n}).isRequired,\ntransitionProps: PropTypes.object.isRequired,\n- position: PropTypes.instanceOf(Animated.Value).isRequired,\n+ position: PropTypes.instanceOf(Value).isRequired,\nscene: PropTypes.object.isRequired,\nscreenDimensions: dimensionsPropType.isRequired,\ncontentVerticalOffset: PropTypes.number.isRequired,\n};\n- centerXNum: number;\n- centerYNum: number;\n- centerX = new Animated.Value(0);\n- centerY = new Animated.Value(0);\n-\n- pinchHandler: React.Ref<PinchGestureHandler> = React.createRef();\n- pinchScale = new Animated.Value(1);\n- pinchFocalX = new Animated.Value(0);\n- pinchFocalY = new Animated.Value(0);\n- pinchEvent = Animated.event([{\n- nativeEvent: {\n- scale: this.pinchScale,\n- focalX: this.pinchFocalX,\n- focalY: this.pinchFocalY,\n- },\n- }]);\n+ centerX = new Value(0);\n+ centerY = new Value(0);\n+ screenWidth = new Value(0);\n+ screenHeight = new Value(0);\n+ imageWidth = new Value(0);\n+ imageHeight = new Value(0);\n- panX = new Animated.Value(0);\n- panY = new Animated.Value(0);\n- panEvent = Animated.event([{\n- nativeEvent: {\n- translationX: this.panX,\n- translationY: this.panY,\n- },\n- }]);\n+ pinchHandler = React.createRef();\n+ pinchEvent;\n+ panEvent;\n- curScaleNum = 1;\n- curXNum = 0;\n- curYNum = 0;\n- curScale = new Animated.Value(1);\n- curX = new Animated.Value(0);\n- curY = new Animated.Value(0);\n-\n- progress: Animated.Value;\n- scale: Animated.Value;\n- pinchX: Animated.Value;\n- pinchY: Animated.Value;\n- x: Animated.Value;\n- y: Animated.Value;\n- imageContainerOpacity: Animated.Value;\n+ progress: Value;\n+ scale: Value;\n+ x: Value;\n+ y: Value;\n+ imageContainerOpacity: Value;\nconstructor(props: Props) {\nsuper(props);\n- this.updateCenter();\n+ this.updateDimensions();\n- const { height, width } = this.imageDimensions;\n- const { height: screenHeight, width: screenWidth } = this.screenDimensions;\n- const top = (screenHeight - height) / 2 + props.contentVerticalOffset;\n- const left = (screenWidth - width) / 2;\n+ const { screenWidth, screenHeight, imageWidth, imageHeight } = this;\n+ const left = sub(this.centerX, divide(imageWidth, 2));\n+ const top = sub(this.centerY, divide(imageHeight, 2));\nconst { initialCoordinates } = props.navigation.state.params;\n- const initialScale = new Animated.Value(initialCoordinates.width / width);\n- const initialTranslateX = new Animated.Value(\n- (initialCoordinates.x + initialCoordinates.width / 2)\n- - (left + width / 2),\n+ const initialScale = divide(\n+ initialCoordinates.width,\n+ imageWidth,\n+ );\n+ const initialTranslateX = sub(\n+ initialCoordinates.x + initialCoordinates.width / 2,\n+ add(left, divide(imageWidth, 2)),\n);\n- const initialTranslateY = new Animated.Value(\n- (initialCoordinates.y + initialCoordinates.height / 2)\n- - (top + height / 2),\n+ const initialTranslateY = sub(\n+ initialCoordinates.y + initialCoordinates.height / 2,\n+ add(top, divide(imageHeight, 2)),\n);\nconst { position } = props;\nconst { index } = props.scene;\n- this.progress = Animated.interpolate(\n+ this.progress = interpolate(\nposition,\n{\ninputRange: [ index - 1, index ],\n- outputRange: ([ 0, 1 ]: number[]),\n- extrapolate: 'clamp',\n+ outputRange: [ 0, 1 ],\n+ extrapolate: Extrapolate.CLAMP,\n},\n);\n- this.imageContainerOpacity = Animated.interpolate(\n+ this.imageContainerOpacity = interpolate(\nthis.progress,\n{\ninputRange: [ 0, 0.1 ],\n- outputRange: ([ 0, 1 ]: number[]),\n- extrapolate: 'clamp',\n+ outputRange: [ 0, 1 ],\n+ extrapolate: Extrapolate.CLAMP,\n},\n);\n- const reverseProgress = Animated.sub(1, this.progress);\n- this.scale = Animated.add(\n- Animated.multiply(reverseProgress, initialScale),\n- Animated.multiply(\n- this.progress,\n- Animated.multiply(this.curScale, this.pinchScale),\n+ // The inputs we receive from PanGestureHandler\n+ const panState = new Value(-1);\n+ const panTranslationX = new Value(0);\n+ const panTranslationY = new Value(0);\n+ this.panEvent = event([{\n+ nativeEvent: {\n+ state: panState,\n+ translationX: panTranslationX,\n+ translationY: panTranslationY,\n+ },\n+ }]);\n+ const panActive = eq(panState, GestureState.ACTIVE);\n+\n+ // The inputs we receive from PinchGestureHandler\n+ const pinchState = new Value(-1);\n+ const pinchScale = new Value(1);\n+ const pinchFocalX = new Value(0);\n+ const pinchFocalY = new Value(0);\n+ this.pinchEvent = event([{\n+ nativeEvent: {\n+ state: pinchState,\n+ scale: pinchScale,\n+ focalX: pinchFocalX,\n+ focalY: pinchFocalY,\n+ },\n+ }]);\n+ const pinchActive = eq(pinchState, GestureState.ACTIVE);\n+\n+ // Shared between Pan/Pinch. After a gesture completes, values are\n+ // moved to these variables and then animated back to valid ranges\n+ const curScale = new Value(1);\n+ const curX = new Value(0);\n+ const curY = new Value(0);\n+\n+ // The centered variables help us know if we need to be recentered\n+ const recenteredScale = max(curScale, 1);\n+ const horizontalPanSpace = this.horizontalPanSpace(recenteredScale);\n+ const verticalPanSpace = this.verticalPanSpace(recenteredScale);\n+\n+ const resetScaleClock = new Clock();\n+ const resetXClock = new Clock();\n+ const resetYClock = new Clock();\n+ const gestureActive = or(pinchActive, panActive);\n+\n+ const updates = [\n+ this.pinchUpdate(\n+ pinchActive,\n+ pinchScale,\n+ pinchFocalX,\n+ pinchFocalY,\n+ curScale,\n+ curX,\n+ curY,\n),\n+ this.panUpdate(\n+ panActive,\n+ panTranslationX,\n+ panTranslationY,\n+ curX,\n+ curY,\n+ ),\n+ this.recenter(\n+ resetScaleClock,\n+ resetXClock,\n+ resetYClock,\n+ gestureActive,\n+ recenteredScale,\n+ horizontalPanSpace,\n+ verticalPanSpace,\n+ curScale,\n+ curX,\n+ curY,\n+ ),\n+ ];\n+ const updatedScale = [ updates, curScale ];\n+ const updatedCurX = [ updates, curX ];\n+ const updatedCurY = [ updates, curY ];\n+\n+ const reverseProgress = sub(1, this.progress);\n+ this.scale = add(\n+ multiply(reverseProgress, initialScale),\n+ multiply(this.progress, updatedScale),\n+ );\n+ this.x = add(\n+ multiply(reverseProgress, initialTranslateX),\n+ multiply(this.progress, updatedCurX),\n+ );\n+ this.y = add(\n+ multiply(reverseProgress, initialTranslateY),\n+ multiply(this.progress, updatedCurY),\n);\n+ }\n- this.pinchX = Animated.multiply(\n- Animated.sub(1, this.pinchScale),\n- Animated.sub(\n- this.pinchFocalX,\n- this.curX,\n+ // How much space do we have to pan the image horizontally?\n+ horizontalPanSpace(scale: Value) {\n+ const apparentWidth = multiply(this.imageWidth, scale);\n+ const horizPop = divide(\n+ sub(apparentWidth, this.screenWidth),\n+ 2,\n+ );\n+ return max(horizPop, 0);\n+ }\n+\n+ // How much space do we have to pan the image vertically?\n+ verticalPanSpace(scale: Value) {\n+ const apparentHeight = multiply(this.imageHeight, scale);\n+ const vertPop = divide(\n+ sub(apparentHeight, this.screenHeight),\n+ 2,\n+ );\n+ return max(vertPop, 0);\n+ }\n+\n+ pinchUpdate(\n+ // Inputs\n+ pinchActive: Value,\n+ pinchScale: Value,\n+ pinchFocalX: Value,\n+ pinchFocalY: Value,\n+ // Outputs\n+ curScale: Value,\n+ curX: Value,\n+ curY: Value,\n+ ): Value {\n+ const deltaScale = scaleDelta(pinchScale, pinchActive);\n+ const deltaPinchX = multiply(\n+ sub(1, deltaScale),\n+ sub(\n+ pinchFocalX,\n+ curX,\nthis.centerX,\n),\n);\n- this.x = Animated.add(\n- Animated.multiply(reverseProgress, initialTranslateX),\n- Animated.multiply(\n- this.progress,\n- Animated.add(\n- this.curX,\n- this.pinchX,\n- this.panX,\n- ),\n+ const deltaPinchY = multiply(\n+ sub(1, deltaScale),\n+ sub(\n+ pinchFocalY,\n+ curY,\n+ this.centerY,\n),\n);\n- this.pinchY = Animated.multiply(\n- Animated.sub(1, this.pinchScale),\n- Animated.sub(\n- this.pinchFocalY,\n- this.curY,\n- this.centerY,\n- ),\n+ return cond(\n+ [ deltaScale, pinchActive ],\n+ [\n+ set(curX, add(curX, deltaPinchX)),\n+ set(curY, add(curY, deltaPinchY)),\n+ set(curScale, multiply(curScale, deltaScale)),\n+ ],\n);\n- this.y = Animated.add(\n- Animated.multiply(reverseProgress, initialTranslateY),\n- Animated.multiply(\n- this.progress,\n- Animated.add(\n- this.curY,\n- this.pinchY,\n- this.panY,\n+ }\n+\n+ panUpdate(\n+ // Inputs\n+ panActive: Value,\n+ panTranslationX: Value,\n+ panTranslationY: Value,\n+ // Outputs\n+ curX: Value,\n+ curY: Value,\n+ ): Value {\n+ const deltaX = panDelta(panTranslationX, panActive);\n+ const deltaY = panDelta(panTranslationY, panActive);\n+ return cond(\n+ [ deltaX, deltaY, panActive ],\n+ [\n+ set(curX, add(curX, deltaX)),\n+ set(curY, add(curY, deltaY)),\n+ ],\n+ );\n+ }\n+\n+ recenter(\n+ // Inputs\n+ resetScaleClock: Clock,\n+ resetXClock: Clock,\n+ resetYClock: Clock,\n+ gestureActive: Value,\n+ recenteredScale: Value,\n+ horizontalPanSpace: Value,\n+ verticalPanSpace: Value,\n+ // Outputs\n+ curScale: Value,\n+ curX: Value,\n+ curY: Value,\n+ ): Value {\n+ const recenteredX = clamp(\n+ curX,\n+ multiply(-1, horizontalPanSpace),\n+ horizontalPanSpace,\n+ );\n+ const recenteredY = clamp(\n+ curY,\n+ multiply(-1, verticalPanSpace),\n+ verticalPanSpace,\n+ );\n+ return cond(\n+ gestureActive,\n+ [\n+ stopClock(resetScaleClock),\n+ stopClock(resetXClock),\n+ stopClock(resetYClock),\n+ ],\n+ [\n+ cond(\n+ or(\n+ clockRunning(resetScaleClock),\n+ neq(recenteredScale, curScale),\n+ ),\n+ set(curScale, runTiming(resetScaleClock, curScale, recenteredScale)),\n+ ),\n+ cond(\n+ or(\n+ clockRunning(resetXClock),\n+ neq(recenteredX, curX),\n+ ),\n+ set(curX, runTiming(resetXClock, curX, recenteredX)),\n),\n+ cond(\n+ or(\n+ clockRunning(resetYClock),\n+ neq(recenteredY, curY),\n),\n+ set(curY, runTiming(resetYClock, curY, recenteredY)),\n+ ),\n+ ],\n);\n}\n- updateCenter() {\n- const { height: screenHeight, width: screenWidth } = this.screenDimensions;\n- this.centerXNum = screenWidth / 2;\n- this.centerYNum = screenHeight / 2 + this.props.contentVerticalOffset;\n- this.centerX.setValue(this.centerXNum);\n- this.centerY.setValue(this.centerYNum);\n+ updateDimensions() {\n+ const { width: screenWidth, height: screenHeight } = this.screenDimensions;\n+ this.screenWidth.setValue(screenWidth);\n+ this.screenHeight.setValue(screenHeight);\n+\n+ this.centerX.setValue(screenWidth / 2);\n+ this.centerY.setValue(screenHeight / 2 + this.props.contentVerticalOffset);\n+\n+ const { width, height } = this.imageDimensions;\n+ this.imageWidth.setValue(width);\n+ this.imageHeight.setValue(height);\n}\ncomponentDidMount() {\n@@ -239,7 +491,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nthis.props.screenDimensions !== prevProps.screenDimensions ||\nthis.props.contentVerticalOffset !== prevProps.contentVerticalOffset\n) {\n- this.updateCenter();\n+ this.updateDimensions();\n}\nconst isActive = MultimediaModal.isActive(this.props);\n@@ -363,13 +615,13 @@ class MultimediaModal extends React.PureComponent<Props> {\nreturn (\n<PinchGestureHandler\nonGestureEvent={this.pinchEvent}\n- onHandlerStateChange={this.onPinchHandlerStateChange}\n+ onHandlerStateChange={this.pinchEvent}\nref={this.pinchHandler}\n>\n<Animated.View style={styles.container}>\n<PanGestureHandler\nonGestureEvent={this.panEvent}\n- onHandlerStateChange={this.onPanHandlerStateChange}\n+ onHandlerStateChange={this.panEvent}\nsimultaneousHandlers={this.pinchHandler}\navgTouches\n>\n@@ -384,160 +636,6 @@ class MultimediaModal extends React.PureComponent<Props> {\nthis.props.navigation.goBack();\n}\n- onPinchHandlerStateChange = (\n- event: { nativeEvent: {\n- state: number,\n- oldState: number,\n- scale: number,\n- focalX: number,\n- focalY: number,\n- } },\n- ) => {\n- const { state, oldState, scale, focalX, focalY } = event.nativeEvent;\n- if (state === GestureState.ACTIVE || oldState !== GestureState.ACTIVE) {\n- return;\n- }\n-\n- this.pinchScale.setValue(1);\n- this.pinchFocalX.setValue(this.centerXNum);\n- this.pinchFocalY.setValue(this.centerYNum);\n-\n- this.curScaleNum *= scale;\n- this.curScale.setValue(this.curScaleNum);\n-\n- // Keep this logic in sync with pinchX/pinchY definitions in constructor\n- this.curXNum += (1 - scale) * (focalX - this.curXNum - this.centerXNum);\n- this.curYNum += (1 - scale) * (focalY - this.curYNum - this.centerYNum);\n- this.curX.setValue(this.curXNum);\n- this.curY.setValue(this.curYNum);\n-\n- this.recenter();\n- }\n-\n- onPanHandlerStateChange = (\n- event: { nativeEvent: {\n- state: number,\n- oldState: number,\n- translationX: number,\n- translationY: number,\n- } },\n- ) => {\n- const { state, oldState, translationX, translationY } = event.nativeEvent;\n- if (state === GestureState.ACTIVE || oldState !== GestureState.ACTIVE) {\n- return;\n- }\n-\n- this.panX.setValue(0);\n- this.panY.setValue(0);\n-\n- this.curXNum += translationX;\n- this.curYNum += translationY;\n- this.curX.setValue(this.curXNum);\n- this.curY.setValue(this.curYNum);\n-\n- this.recenter();\n- }\n-\n- get nextScale() {\n- return Math.max(this.curScaleNum, 1);\n- }\n-\n- // How much space do we have to pan the image horizontally?\n- get horizontalPanSpace() {\n- const { nextScale } = this;\n- const { width } = this.imageDimensions;\n- const apparentWidth = nextScale * width;\n- const screenWidth = this.screenDimensions.width;\n- const horizPop = (apparentWidth - screenWidth) / 2;\n- return Math.max(horizPop, 0);\n- }\n-\n- // How much space do we have to pan the image vertically?\n- get verticalPanSpace() {\n- const { nextScale } = this;\n- const { height } = this.imageDimensions;\n- const apparentHeight = nextScale * height;\n- const screenHeight = this.screenDimensions.height;\n- const vertPop = (apparentHeight - screenHeight) / 2;\n- return Math.max(vertPop, 0);\n- }\n-\n- // Figures out what we need to add to this.curX to make it \"centered\"\n- get centerDeltaX() {\n- const { curXNum, horizontalPanSpace } = this;\n-\n- const rightOverscroll = curXNum - horizontalPanSpace;\n- if (rightOverscroll > 0) {\n- return rightOverscroll * -1;\n- }\n-\n- const leftOverscroll = curXNum + horizontalPanSpace;\n- if (leftOverscroll < 0) {\n- return leftOverscroll * -1;\n- }\n-\n- return 0;\n- }\n-\n- // Figures out what we need to add to this.curY to make it \"centered\"\n- get centerDeltaY() {\n- const { curYNum, verticalPanSpace } = this;\n-\n- const bottomOverscroll = curYNum - verticalPanSpace;\n- if (bottomOverscroll > 0) {\n- return bottomOverscroll * -1;\n- }\n-\n- const topOverscroll = curYNum + verticalPanSpace;\n- if (topOverscroll < 0) {\n- return topOverscroll * -1;\n- }\n-\n- return 0;\n- }\n-\n- recenter() {\n- const { nextScale, centerDeltaX, centerDeltaY } = this;\n-\n- const config = {\n- duration: 250,\n- easing: Easing.out(Easing.ease),\n- };\n- if (nextScale !== this.curScaleNum) {\n- Animated.timing(\n- this.curScale,\n- { ...config, toValue: nextScale },\n- ).start(({ finished }) => {\n- if (!finished) {\n- return;\n- }\n- this.curScaleNum = nextScale;\n- });\n- }\n- if (centerDeltaX !== 0) {\n- Animated.timing(\n- this.curX,\n- { ...config, toValue: this.curXNum + centerDeltaX },\n- ).start(({ finished }) => {\n- if (!finished) {\n- return;\n- }\n- this.curXNum += centerDeltaX;\n- });\n- }\n- if (centerDeltaY !== 0) {\n- Animated.timing(\n- this.curY,\n- { ...config, toValue: this.curYNum + centerDeltaY },\n- ).start(({ finished }) => {\n- if (!finished) {\n- return;\n- }\n- this.curYNum += centerDeltaY;\n- });\n- }\n- }\n-\n}\nconst styles = StyleSheet.create({\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "native/utils/animation-utils.js",
"diff": "+// @flow\n+\n+import Animated from 'react-native-reanimated';\n+\n+const {\n+ Value,\n+ Clock,\n+ cond,\n+ greaterThan,\n+} = Animated;\n+\n+function clamp(value: Value, minValue: Value, maxValue: Value): Value {\n+ return cond(\n+ greaterThan(value, maxValue),\n+ maxValue,\n+ cond(\n+ greaterThan(minValue, value),\n+ minValue,\n+ value,\n+ ),\n+ );\n+}\n+\n+export {\n+ clamp,\n+};\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Redo MultimediaModal animations using Reanimated's declarative style
So much smoother! |
129,187 | 06.04.2019 02:58:42 | 14,400 | 16584e82510458a049571dd1e617e2a5ecaf1317 | [native] Fling MultimediaModal | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -64,6 +64,7 @@ const {\nstopClock,\nclockRunning,\ntiming,\n+ decay,\n} = Animated;\nfunction scaleDelta(value: Value, gestureActive: Value) {\n@@ -131,6 +132,39 @@ function runTiming(\n];\n}\n+function runDecay(\n+ clock: Clock,\n+ velocity: Value,\n+ initialPosition: Value,\n+): Value {\n+ const state = {\n+ finished: new Value(0),\n+ velocity: new Value(0),\n+ position: new Value(0),\n+ time: new Value(0),\n+ };\n+ const config = { deceleration: 0.99 };\n+ return [\n+ cond(\n+ not(clockRunning(clock)),\n+ [\n+ set(state.finished, 0),\n+ set(state.velocity, velocity),\n+ set(state.position, initialPosition),\n+ set(state.time, 0),\n+ startClock(clock),\n+ ],\n+ ),\n+ decay(clock, state, config),\n+ set(velocity, state.velocity),\n+ cond(\n+ state.finished,\n+ stopClock(clock),\n+ ),\n+ state.position,\n+ ];\n+}\n+\ntype LayoutCoordinates = $ReadOnly<{|\nx: number,\ny: number,\n@@ -242,11 +276,15 @@ class MultimediaModal extends React.PureComponent<Props> {\nconst panState = new Value(-1);\nconst panTranslationX = new Value(0);\nconst panTranslationY = new Value(0);\n+ const panVelocityX = new Value(0);\n+ const panVelocityY = new Value(0);\nthis.panEvent = event([{\nnativeEvent: {\nstate: panState,\ntranslationX: panTranslationX,\ntranslationY: panTranslationY,\n+ velocityX: panVelocityX,\n+ velocityY: panVelocityY,\n},\n}]);\nconst panActive = eq(panState, GestureState.ACTIVE);\n@@ -280,6 +318,8 @@ class MultimediaModal extends React.PureComponent<Props> {\nconst resetScaleClock = new Clock();\nconst resetXClock = new Clock();\nconst resetYClock = new Clock();\n+ const flingXClock = new Clock();\n+ const flingYClock = new Clock();\nconst gestureActive = or(pinchActive, panActive);\nconst updates = [\n@@ -311,6 +351,19 @@ class MultimediaModal extends React.PureComponent<Props> {\ncurX,\ncurY,\n),\n+ this.flingUpdate(\n+ flingXClock,\n+ flingYClock,\n+ resetXClock,\n+ resetYClock,\n+ gestureActive,\n+ panVelocityX,\n+ panVelocityY,\n+ horizontalPanSpace,\n+ verticalPanSpace,\n+ curX,\n+ curY,\n+ ),\n];\nconst updatedScale = [ updates, curScale ];\nconst updatedCurX = [ updates, curX ];\n@@ -467,6 +520,60 @@ class MultimediaModal extends React.PureComponent<Props> {\n);\n}\n+ flingUpdate(\n+ // Inputs\n+ flingXClock: Clock,\n+ flingYClock: Clock,\n+ resetXClock: Clock,\n+ resetYClock: Clock,\n+ gestureActive: Value,\n+ panVelocityX: Value,\n+ panVelocityY: Value,\n+ horizontalPanSpace: Value,\n+ verticalPanSpace: Value,\n+ // Outputs\n+ curX: Value,\n+ curY: Value,\n+ ): Value {\n+ const decayX = runDecay(flingXClock, panVelocityX, curX);\n+ const recenteredX = clamp(\n+ decayX,\n+ multiply(-1, horizontalPanSpace),\n+ horizontalPanSpace,\n+ );\n+ const decayY = runDecay(flingYClock, panVelocityY, curY);\n+ const recenteredY = clamp(\n+ decayY,\n+ multiply(-1, verticalPanSpace),\n+ verticalPanSpace,\n+ );\n+ return cond(\n+ gestureActive,\n+ [\n+ stopClock(flingXClock),\n+ stopClock(flingYClock),\n+ ],\n+ [\n+ cond(\n+ and(\n+ not(clockRunning(resetXClock)),\n+ eq(decayX, recenteredX),\n+ ),\n+ set(curX, decayX),\n+ stopClock(flingXClock),\n+ ),\n+ cond(\n+ and(\n+ not(clockRunning(resetYClock)),\n+ eq(decayY, recenteredY),\n+ ),\n+ set(curY, decayY),\n+ stopClock(flingYClock),\n+ ),\n+ ],\n+ );\n+ }\n+\nupdateDimensions() {\nconst { width: screenWidth, height: screenHeight } = this.screenDimensions;\nthis.screenWidth.setValue(screenWidth);\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] Fling MultimediaModal |
129,187 | 07.04.2019 22:55:00 | 14,400 | 73ee646f79dbcbe5260449b80927e30834ddd5e1 | [native] MultimediaModal now supports double-tap-to-zoom | [
{
"change_type": "MODIFY",
"old_path": "native/media/multimedia-modal.react.js",
"new_path": "native/media/multimedia-modal.react.js",
"diff": "@@ -26,6 +26,7 @@ import PropTypes from 'prop-types';\nimport {\nPinchGestureHandler,\nPanGestureHandler,\n+ TapGestureHandler,\nState as GestureState,\n} from 'react-native-gesture-handler';\nimport Orientation from 'react-native-orientation-locker';\n@@ -54,11 +55,13 @@ const {\nor,\neq,\nneq,\n+ greaterThan,\nadd,\nsub,\nmultiply,\ndivide,\nmax,\n+ round,\ninterpolate,\nstartClock,\nstopClock,\n@@ -95,10 +98,23 @@ function panDelta(value: Value, gestureActive: Value) {\n);\n}\n+function gestureJustEnded(tapState: Value) {\n+ const prevValue = new Value(-1);\n+ return cond(\n+ eq(prevValue, tapState),\n+ 0,\n+ [\n+ set(prevValue, tapState),\n+ eq(tapState, GestureState.END),\n+ ],\n+ );\n+}\n+\nfunction runTiming(\nclock: Clock,\n- initialValue: Value,\n- finalValue: Value,\n+ initialValue: Value | number,\n+ finalValue: Value | number,\n+ startStopClock: bool = true,\n): Value {\nconst state = {\nfinished: new Value(0),\n@@ -120,13 +136,13 @@ function runTiming(\nset(state.time, 0),\nset(state.position, initialValue),\nset(config.toValue, finalValue),\n- startClock(clock),\n+ startStopClock && startClock(clock),\n],\n),\ntiming(clock, state, config),\ncond(\nstate.finished,\n- stopClock(clock),\n+ startStopClock && stopClock(clock),\n),\nstate.position,\n];\n@@ -222,8 +238,14 @@ class MultimediaModal extends React.PureComponent<Props> {\nimageHeight = new Value(0);\npinchHandler = React.createRef();\n+ panHandler = React.createRef();\n+ tapHandler = React.createRef();\n+ handlerRefs = [ this.pinchHandler, this.panHandler, this.tapHandler ];\n+ priorityHandlerRefs = [ this.pinchHandler, this.panHandler ];\n+\npinchEvent;\npanEvent;\n+ tapEvent;\nprogress: Value;\nscale: Value;\n@@ -304,6 +326,19 @@ class MultimediaModal extends React.PureComponent<Props> {\n}]);\nconst pinchActive = eq(pinchState, GestureState.ACTIVE);\n+ // The inputs we receive from TapGestureHandler\n+ const tapState = new Value(-1);\n+ const tapX = new Value(0);\n+ const tapY = new Value(0);\n+ this.tapEvent = event([{\n+ nativeEvent: {\n+ state: tapState,\n+ x: tapX,\n+ y: tapY,\n+ },\n+ }]);\n+ const tapActive = gestureJustEnded(tapState);\n+\n// Shared between Pan/Pinch. After a gesture completes, values are\n// moved to these variables and then animated back to valid ranges\nconst curScale = new Value(1);\n@@ -320,7 +355,9 @@ class MultimediaModal extends React.PureComponent<Props> {\nconst resetYClock = new Clock();\nconst flingXClock = new Clock();\nconst flingYClock = new Clock();\n+ const zoomClock = new Clock();\nconst gestureActive = or(pinchActive, panActive);\n+ const gestureOrZoomActive = or(gestureActive, clockRunning(zoomClock));\nconst updates = [\nthis.pinchUpdate(\n@@ -339,11 +376,21 @@ class MultimediaModal extends React.PureComponent<Props> {\ncurX,\ncurY,\n),\n+ this.doubleTapUpdate(\n+ tapActive,\n+ tapX,\n+ tapY,\n+ zoomClock,\n+ gestureActive,\n+ curScale,\n+ curX,\n+ curY,\n+ ),\nthis.recenter(\nresetScaleClock,\nresetXClock,\nresetYClock,\n- gestureActive,\n+ gestureOrZoomActive,\nrecenteredScale,\nhorizontalPanSpace,\nverticalPanSpace,\n@@ -356,7 +403,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nflingYClock,\nresetXClock,\nresetYClock,\n- gestureActive,\n+ gestureOrZoomActive,\npanVelocityX,\npanVelocityY,\nhorizontalPanSpace,\n@@ -463,12 +510,80 @@ class MultimediaModal extends React.PureComponent<Props> {\n);\n}\n+ doubleTapUpdate(\n+ tapActive: Value,\n+ tapX: Value,\n+ tapY: Value,\n+ zoomClock: Clock,\n+ gestureActive: Value,\n+ curScale: Value,\n+ curX: Value,\n+ curY: Value,\n+ ): Value {\n+ const zoomClockRunning = clockRunning(zoomClock);\n+ const zoomActive = and(not(gestureActive), zoomClockRunning);\n+\n+ const roundedCurScale = divide(round(multiply(curScale, 1000)), 1000);\n+ const targetScale = cond(greaterThan(roundedCurScale, 1), 1, 3);\n+\n+ const tapXDiff = sub(tapX, this.centerX, curX);\n+ const tapYDiff = sub(tapY, this.centerY, curY);\n+ const tapXPercent = divide(tapXDiff, this.imageWidth, curScale);\n+ const tapYPercent = divide(tapYDiff, this.imageHeight, curScale);\n+\n+ const horizPanSpace = this.horizontalPanSpace(targetScale);\n+ const vertPanSpace = this.verticalPanSpace(targetScale);\n+ const horizPanPercent = divide(horizPanSpace, this.imageWidth, targetScale);\n+ const vertPanPercent = divide(vertPanSpace, this.imageHeight, targetScale);\n+\n+ const tapXPercentClamped = clamp(\n+ tapXPercent,\n+ multiply(-1, horizPanPercent),\n+ horizPanPercent,\n+ );\n+ const tapYPercentClamped = clamp(\n+ tapYPercent,\n+ multiply(-1, vertPanPercent),\n+ vertPanPercent,\n+ );\n+ const targetX = multiply(tapXPercentClamped, this.imageWidth, targetScale);\n+ const targetY = multiply(tapYPercentClamped, this.imageHeight, targetScale);\n+\n+ const targetRelativeScale = divide(targetScale, curScale);\n+ const targetRelativeX = multiply(-1, add(targetX, curX));\n+ const targetRelativeY = multiply(-1, add(targetY, curY));\n+\n+ const zoomScale = runTiming(zoomClock, 1, targetRelativeScale);\n+ const zoomX = runTiming(zoomClock, 0, targetRelativeX, false);\n+ const zoomY = runTiming(zoomClock, 0, targetRelativeY, false);\n+\n+ const deltaScale = scaleDelta(zoomScale, zoomActive);\n+ const deltaX = panDelta(zoomX, zoomActive);\n+ const deltaY = panDelta(zoomY, zoomActive);\n+\n+ return cond(\n+ [ deltaX, deltaY, deltaScale, gestureActive ],\n+ stopClock(zoomClock),\n+ cond(\n+ or(zoomClockRunning, tapActive),\n+ [\n+ zoomX,\n+ zoomY,\n+ zoomScale,\n+ set(curX, add(curX, deltaX)),\n+ set(curY, add(curY, deltaY)),\n+ set(curScale, multiply(curScale, deltaScale)),\n+ ],\n+ ),\n+ );\n+ }\n+\nrecenter(\n// Inputs\nresetScaleClock: Clock,\nresetXClock: Clock,\nresetYClock: Clock,\n- gestureActive: Value,\n+ gestureOrZoomActive: Value,\nrecenteredScale: Value,\nhorizontalPanSpace: Value,\nverticalPanSpace: Value,\n@@ -488,7 +603,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nverticalPanSpace,\n);\nreturn cond(\n- gestureActive,\n+ gestureOrZoomActive,\n[\nstopClock(resetScaleClock),\nstopClock(resetXClock),\n@@ -526,7 +641,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nflingYClock: Clock,\nresetXClock: Clock,\nresetYClock: Clock,\n- gestureActive: Value,\n+ gestureOrZoomActive: Value,\npanVelocityX: Value,\npanVelocityY: Value,\nhorizontalPanSpace: Value,\n@@ -548,7 +663,7 @@ class MultimediaModal extends React.PureComponent<Props> {\nverticalPanSpace,\n);\nreturn cond(\n- gestureActive,\n+ gestureOrZoomActive,\n[\nstopClock(flingXClock),\nstopClock(flingYClock),\n@@ -723,16 +838,28 @@ class MultimediaModal extends React.PureComponent<Props> {\n<PinchGestureHandler\nonGestureEvent={this.pinchEvent}\nonHandlerStateChange={this.pinchEvent}\n+ simultaneousHandlers={this.handlerRefs}\nref={this.pinchHandler}\n>\n<Animated.View style={styles.container}>\n<PanGestureHandler\nonGestureEvent={this.panEvent}\nonHandlerStateChange={this.panEvent}\n- simultaneousHandlers={this.pinchHandler}\n+ simultaneousHandlers={this.handlerRefs}\n+ ref={this.panHandler}\navgTouches\n+ >\n+ <Animated.View style={styles.container}>\n+ <TapGestureHandler\n+ onHandlerStateChange={this.tapEvent}\n+ simultaneousHandlers={this.handlerRefs}\n+ ref={this.tapHandler}\n+ waitFor={this.priorityHandlerRefs}\n+ numberOfTaps={2}\n>\n{view}\n+ </TapGestureHandler>\n+ </Animated.View>\n</PanGestureHandler>\n</Animated.View>\n</PinchGestureHandler>\n"
}
] | JavaScript | BSD 3-Clause New or Revised License | comme2e/comm | [native] MultimediaModal now supports double-tap-to-zoom |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.