Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Commit

Permalink
Fixes navigation error; fixes a redux error
Browse files Browse the repository at this point in the history
Signed-off-by: andrew <[email protected]>
  • Loading branch information
andrewxhill committed Aug 8, 2019
1 parent 5188a88 commit 7c92a17
Show file tree
Hide file tree
Showing 16 changed files with 87 additions and 48 deletions.
2 changes: 1 addition & 1 deletion App/Components/ProcessingThread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ const mapDispatchToProps = (dispatch: Dispatch<RootAction>): DispatchProps => {
)
},
retryInternal: (inviteId: string, threadName?: string) => {
dispatch(ThreadsActions.acceptInviteRequest(inviteId, threadName))
dispatch(ThreadsActions.acceptInviteRequest(inviteId, threadName, true))
},
dismiss: (inviteId: string) => {
dispatch(ThreadsActions.acceptInviteDismiss(inviteId))
Expand Down
9 changes: 6 additions & 3 deletions App/Containers/AddCaptionScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class AddCaptionScreen extends React.Component<Props> {

static navigationOptions = ({ navigation }: NavigationScreenProps) => {
const params = navigation.state.params || {}
// I can't explain why yet, but the two callbacks remain null for 500ms after page loads
// if you click and these are null, nothing happens.
const unavailable = !params.shareToNewThread
return {
headerTitle: 'Share Photo',
headerLeft: (
Expand All @@ -70,11 +73,11 @@ class AddCaptionScreen extends React.Component<Props> {
headerRight: (
<TextileHeaderButtons>
<Item
color={params.disableShare ? '#99c0ef' : 'blue'}
color={unavailable || params.disableShare ? '#99c0ef' : 'blue'}
title="Share"
/* tslint:disable-next-line */
onPress={() => {
if (params.disableShare) {
if (unavailable || params.disableShare) {
return
}
if (params.withPhoto && params.withThreadName) {
Expand All @@ -99,7 +102,7 @@ class AddCaptionScreen extends React.Component<Props> {
this.props.updateComment(text)
}

componentWillMount() {
componentDidMount() {
// TODO: Investigate why share would ever be null? https://github.com/textileio/textile-mobile/issues/888
this.props.navigation.setParams({
disableShare:
Expand Down
16 changes: 8 additions & 8 deletions App/Containers/FeedList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,7 @@ class Notifications extends React.Component<Props, State> {
return
}

return (
<AlertRow
message={this.props.alert}
onClick={this.registerCafe}
/>
)
return <AlertRow message={this.props.alert} onClick={this.registerCafe} />
}
_renderItems() {
return (
Expand All @@ -211,7 +206,9 @@ class Notifications extends React.Component<Props, State> {
// the initial refresh has completed and returned 0 results. This is to avoid the art
// flickering for a second and then disappearing, which is ugly.
const showNotifications =
this.state.focusRefreshInProgress || this.props.notifications.length > 0 || this.props.alert
this.state.focusRefreshInProgress ||
this.props.notifications.length > 0 ||
this.props.alert
return (
<View style={styles.container}>
{!showNotifications && this._renderOnboarding()}
Expand All @@ -233,7 +230,10 @@ const mapStateToProps = (state: RootState): StateProps => {
const showOnboarding = state.preferences.tourScreens.feed === true
const refreshing = state.notifications.refreshing

const alert = Object.keys(state.cafes.cafes).length > 0 ? undefined : 'Improve app performance by choosing an account cafe now.'
const alert =
Object.keys(state.cafes.cafes).length > 0
? undefined
: 'Improve app performance by choosing an account cafe now.'

return {
alert,
Expand Down
5 changes: 3 additions & 2 deletions App/Containers/PhotoScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { threadDataByThreadId } from '../Redux/GroupsSelectors'
import { color } from '../styles'
import { CommentData } from '../Components/comments'
import { accountSelectors } from '../features/account'
import { groupPhoto } from '../features/group/selectors';
import { groupPhoto } from '../features/group/selectors'

const screenWidth = Dimensions.get('screen').width

Expand Down Expand Up @@ -149,7 +149,8 @@ const mapStateToProps = (state: RootState): StateProps => {
threadName = threadData ? threadData.name : undefined
}
const photoId = state.photoViewing.viewingPhoto
const photo = threadId && photoId ? groupPhoto(state.group, threadId, photoId) : undefined
const photo =
threadId && photoId ? groupPhoto(state.group, threadId, photoId) : undefined
const selfAddress = accountSelectors.getAddress(state.account) || ''
const removing = photo
? Object.keys(state.group.ignore)
Expand Down
30 changes: 28 additions & 2 deletions App/Containers/WalletPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ class TextileWalletPicker extends React.PureComponent<Props> {
const showImagePicker = navigation.getParam('showImagePicker')

const cameraRoll = () => {
if (!showImagePicker) {
return
}
showImagePicker('camera-roll')
}
const camera = () => {
if (!showImagePicker) {
return
}
showImagePicker('camera')
}
const onPress = () => {
Expand All @@ -46,12 +52,32 @@ class TextileWalletPicker extends React.PureComponent<Props> {
</TextileHeaderButtons>
)
const headerTitle = 'Recent Photos'

/**
* Android note.
* I can't explain why yet, but the two callbacks remain null for 500ms after page loads.
* So now if you click them early nothing will happen (also grey'd out)
* This is related to changing the launchMode="singleInstance" to
* launchMode="singleTop"
*/
const imagePickerProps = !showImagePicker ? { color: '#a9a9a9' } : {}
const headerRight = (
<TextileHeaderButtons>
<Item title="camera" iconName="camera-create" onPress={camera} />
<Item title="camera roll" iconName="image" onPress={cameraRoll} />
<Item
title="camera"
iconName="camera-create"
onPress={camera}
{...imagePickerProps}
/>
<Item
title="camera roll"
iconName="image"
onPress={cameraRoll}
{...imagePickerProps}
/>
</TextileHeaderButtons>
)

return {
headerTitle,
headerLeft,
Expand Down
4 changes: 2 additions & 2 deletions App/Redux/ThreadsRedux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ const actions = {
acceptInviteRequest: createAction(
'ACCEPT_THREAD_NOTIFICATION_INVITE',
resolve => {
return (notificationId: string, threadName?: string) =>
resolve({ notificationId, threadName })
return (notificationId: string, threadName?: string, goBack?: boolean) =>
resolve({ notificationId, threadName, goBack })
}
),
addInternalInvitesRequest: createAction(
Expand Down
10 changes: 8 additions & 2 deletions App/Redux/UIRedux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,17 @@ export function reducer(
switch (action.type) {
case getType(actions.updateSharingPhotoImage): {
const { image } = action.payload
return { ...state, sharingPhoto: { ...state.sharingPhoto, image } }
return {
...state,
sharingPhoto: { ...state.sharingPhoto, image, files: undefined }
}
}
case getType(actions.updateSharingPhotoFiles): {
const { files } = action.payload
return { ...state, sharingPhoto: { ...state.sharingPhoto, files } }
return {
...state,
sharingPhoto: { ...state.sharingPhoto, files, image: undefined }
}
}
case getType(actions.updateSharingPhotoThread): {
const { threadId } = action.payload
Expand Down
24 changes: 10 additions & 14 deletions App/SB/components/AlertRow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ class AlertRow extends React.PureComponent<AlertRowProps> {
const dateText = 'now'

const readStyle: ViewStyle = {
width: 29,
height: 29,
borderRadius: 16,
borderWidth: 0,
borderColor: 'rgba(255, 28, 63, 0.2)',
backgroundColor: 'rgba(255, 28, 63, 0.2)'
}
width: 29,
height: 29,
borderRadius: 16,
borderWidth: 0,
borderColor: 'rgba(255, 28, 63, 0.2)',
backgroundColor: 'rgba(255, 28, 63, 0.2)'
}

return (
<TouchableOpacity
Expand All @@ -42,18 +42,14 @@ class AlertRow extends React.PureComponent<AlertRowProps> {
alignItems: 'center',
alignContent: 'center'
}}
>
</View>
/>
</View>
</View>
<View style={styles.textContainer}>
<Text style={styles.text}>{message}</Text>
<Text style={[styles.timestamp, styles.unread]}>
{dateText}
</Text>
</View>
<View style={{ width: 40, height: 40, overflow: 'hidden' }}>
<Text style={[styles.timestamp, styles.unread]}>{dateText}</Text>
</View>
<View style={{ width: 40, height: 40, overflow: 'hidden' }} />
</TouchableOpacity>
)
}
Expand Down
2 changes: 1 addition & 1 deletion App/SB/components/FeedItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@ class FeedItem extends React.PureComponent<FeedItemProps> {
}
}

export default FeedItem
export default FeedItem
3 changes: 2 additions & 1 deletion App/Sagas/NotificationsSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ export function* reviewThreadInvite(
yield put(
ThreadsActions.acceptInviteRequest(
notification.id,
notification.threadName
notification.threadName,
false
)
)
} catch (error) {
Expand Down
8 changes: 3 additions & 5 deletions App/Sagas/PhotoViewingSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@ export function* monitorNewThreadActions() {
}

if (shouldNav) {
yield put(PhotoViewingActions.viewThread(id))
yield delay(700)
yield call(NavigationService.navigate, 'ViewThread', { threadId: id })
yield put(UIActions.navigateToThreadRequest(id, name))
} else if (shouldSelect) {
yield put(UIActions.updateSharingPhotoThread(id))
} else if (invite) {
yield put(PhotoViewingActions.viewThread(id))
yield call(NavigationService.navigate, 'ViewThread', { threadId: id })
yield call(NavigationService.navigate, 'Groups')
yield put(UIActions.navigateToThreadRequest(id, name))
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion App/Sagas/TextileSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*************************************************************/
import { Share, PermissionsAndroid, Platform } from 'react-native'
import { call, put, select } from 'redux-saga/effects'
import { delay } from 'redux-saga'
import Config from 'react-native-config'
import Textile, { ILogLevel, LogLevel } from '@textile/react-native-sdk'

Expand All @@ -21,14 +22,19 @@ import PreferencesActions, {
PreferencesSelectors
} from '../Redux/PreferencesRedux'
import UIActions from '../Redux/UIRedux'
import { ActionType } from 'typesafe-actions'
import GroupsActions from '../Redux/GroupsRedux'
import { ActionType } from 'typesafe-actions'
import PhotoViewingActions from '../Redux/PhotoViewingRedux'
import { logNewEvent } from './DeviceLogs'
import { threadDataByThreadId } from '../Redux/GroupsSelectors'

export function* navigateToThread(
action: ActionType<typeof UIActions.navigateToThreadRequest>
) {
const data = yield select(threadDataByThreadId, action.payload.threadId)
if (!data) {
return
}
yield put(PhotoViewingActions.viewThread(action.payload.threadId))
yield call(NavigationService.navigate, 'ViewThread', {
threadId: action.payload.threadId
Expand Down
6 changes: 4 additions & 2 deletions App/Sagas/ThreadsSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function* presentShareInterface(
export function* acceptInvite(
action: ActionType<typeof ThreadsActions.acceptInviteRequest>
) {
const { notificationId, threadName } = action.payload
const { notificationId, threadName, goBack } = action.payload
try {
// don't wait for the join event here...
yield call(waitUntilOnline, 5000)
Expand All @@ -99,7 +99,9 @@ export function* acceptInvite(
yield put(ThreadsActions.acceptInviteScanning(notificationId))
// Refresh in case the head is available
yield put(GroupsActions.refreshThreadsRequest())
yield call(NavigationService.navigate, 'Groups')
if (goBack) {
yield call(NavigationService.navigate, 'Groups')
}
} catch (error) {
yield put(ThreadsActions.acceptInviteError(notificationId, error))
}
Expand Down
4 changes: 2 additions & 2 deletions App/features/cafes/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ function* migrateUSW() {
const repl = '12D3KooWSdGmRz5JQidqrtmiPGVHkStXpbSAMnbCcW8abq6zuiDP'

const list: ICafeSessionList = yield call(Textile.cafes.sessions)
const peerIDs = list.items.map((session) => session.cafe.peer)
const peerIDs = list.items.map(session => session.cafe.peer)

if (peerIDs.indexOf(usw) > -1) {
// Use the existing route to deregister the usw cafe
yield put(actions.deregisterCafe.request({ peerId: usw }))
Expand Down
2 changes: 1 addition & 1 deletion App/features/group/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const groupPhoto = (
return undefined
}
})
.find(item => item && item.block === block || false)
.find(item => (item && item.block === block) || false)
}

export { feedSelectors, addPhotoSelectors, fileSyncSelectors }
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:launchMode="standard">
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down

0 comments on commit 7c92a17

Please sign in to comment.