Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,6 @@ PODS:
- RNSentry (2.6.2):
- React-Core
- Sentry (= 7.1.4)
- RNSound (0.11.0):
- React
- RNSound/Core (= 0.11.0)
- RNSound/Core (0.11.0):
- React
- RNVectorIcons (7.0.0):
- React
- Sentry (7.1.4):
Expand Down Expand Up @@ -498,7 +493,6 @@ DEPENDENCIES:
- RNGestureHandler (from `../node_modules/react-native-gesture-handler`)
- RNReanimated (from `../node_modules/react-native-reanimated`)
- "RNSentry (from `../node_modules/@sentry/react-native`)"
- RNSound (from `../node_modules/react-native-sound`)
- RNVectorIcons (from `../node_modules/react-native-vector-icons`)
- UMAppLoader (from `../node_modules/unimodules-app-loader/ios`)
- "UMCore (from `../node_modules/@unimodules/core/ios`)"
Expand Down Expand Up @@ -624,8 +618,6 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-reanimated"
RNSentry:
:path: "../node_modules/@sentry/react-native"
RNSound:
:path: "../node_modules/react-native-sound"
RNVectorIcons:
:path: "../node_modules/react-native-vector-icons"
UMAppLoader:
Expand Down Expand Up @@ -701,7 +693,6 @@ SPEC CHECKSUMS:
RNGestureHandler: a479ebd5ed4221a810967000735517df0d2db211
RNReanimated: 9c13c86454bfd54dab7505c1a054470bfecd2563
RNSentry: 68644ef607b780551cc555f084869764f2566652
RNSound: da030221e6ac7e8290c6b43f2b5f2133a8e225b0
RNVectorIcons: da6fe858f5a65d7bbc3379540a889b0b12aa5976
Sentry: 1d3eb1a25f8c5333c88dd5603904a6d461cd9fcf
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
Expand Down
8 changes: 7 additions & 1 deletion ios/ZulipMobile/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,13 @@ -(void)userNotificationCenter:(UNUserNotificationCenter *)center
// Update the badge count. Do not play sound or show an alert. For
// these options see
// https://developer.apple.com/documentation/usernotifications/unnotificationpresentationoptions?language=objc
completionHandler(UNNotificationPresentationOptionBadge);
completionHandler(
UNNotificationPresentationOptionBadge
| UNNotificationPresentationOptionSound
| UNNotificationPresentationOptionBanner
// Deprecated; we use this to get banners on iOS <14.
| UNNotificationPresentationOptionAlert
);
}

@end
4 changes: 0 additions & 4 deletions jest/jestSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ jest.mock('@react-native-community/push-notification-ios', () => ({
// etc. (incomplete)
}));

jest.mock('react-native-sound', () => () => ({
play: jest.fn(),
}));

jest.mock('rn-fetch-blob', () => ({
DocumentDir: () => {},
}));
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
"react-native-safe-area-context": "^3.1.7",
"react-native-screens": "^2.10.1",
"react-native-simple-toast": "^1.0.0",
"react-native-sound": "^0.11.0",
"react-native-tab-view": "^2.15.2",
"react-native-text-input-reset": "^1.0.2",
"react-native-unimodules": "^0.14.6",
Expand Down
46 changes: 2 additions & 44 deletions src/events/doEventActionSideEffects.js
Original file line number Diff line number Diff line change
@@ -1,60 +1,18 @@
/* @flow strict-local */
// import { Vibration } from 'react-native';

import { AppState } from 'react-native';
import type { GlobalState, Message, ThunkAction } from '../types';
import type { ThunkAction } from '../types';
import type { EventAction } from '../actionTypes';
import { EVENT_NEW_MESSAGE, EVENT_TYPING_START } from '../actionConstants';
import { isHomeNarrow, isMessageInNarrow } from '../utils/narrow';
import { getActiveAccount, getChatScreenParams } from '../selectors';
import { playMessageSound } from '../utils/sound';
import { NULL_ARRAY } from '../nullObjects';
import { EVENT_TYPING_START } from '../actionConstants';
import { ensureTypingStatusExpiryLoop } from '../typing/typingActions';
import { getOwnUserId } from '../users/userSelectors';

/**
* React to incoming `MessageEvent`s.
*/
const messageEvent = (state: GlobalState, message: Message): void => {
const flags = message.flags ?? NULL_ARRAY;

if (AppState.currentState !== 'active') {
return;
}

const isMentioned = flags.includes('mentioned') || flags.includes('wildcard_mentioned');
if (!(message.type === 'private' || isMentioned)) {
return;
}

const activeAccount = getActiveAccount(state);
// Assume (unchecked) that `narrow` is `Narrow` if present
// $FlowFixMe[cannot-resolve-name]
const narrow: Narrow | void = getChatScreenParams().narrow;
const isUserInSameNarrow =
activeAccount
&& narrow !== undefined // chat screen is not at top
&& !isHomeNarrow(narrow)
&& isMessageInNarrow(message, flags, narrow, getOwnUserId(state));
const isSenderSelf = getOwnUserId(state) === message.sender_id;
if (!isUserInSameNarrow && !isSenderSelf) {
playMessageSound();
// Vibration.vibrate();
}
};

/**
* React to actions dispatched for Zulip server events.
*
* To be dispatched before the event actions are dispatched.
*/
export default (action: EventAction): ThunkAction<Promise<void>> => async (dispatch, getState) => {
const state = getState();
switch (action.type) {
case EVENT_NEW_MESSAGE: {
messageEvent(state, action.message);
break;
}
case EVENT_TYPING_START:
dispatch(ensureTypingStatusExpiryLoop());
break;
Expand Down
52 changes: 52 additions & 0 deletions src/nav/__tests__/navActions-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* @flow strict-local */
import deepFreeze from 'deep-freeze';

import { navigateBack } from '../navActions';
import * as NavigationService from '../NavigationService';

describe('navigateBack', () => {
test('if no routes the count of same routes is 0', () => {
// $FlowFixMe[cannot-write] Make Flow understand about mocking.
NavigationService.getState = jest.fn().mockReturnValue(
deepFreeze({
routes: [],
}),
);

const action = navigateBack();

expect(action.payload.count).toEqual(0);
});

test('if last route differs from routes the count of same routes is 0', () => {
// $FlowFixMe[cannot-write] Make Flow understand about mocking.
NavigationService.getState = jest.fn().mockReturnValue(
deepFreeze({
routes: [{ name: 'main-tabs' }, { name: 'chat' }],
}),
);

const action = navigateBack();

expect(action.payload.count).toEqual(1);
});

test('if several of the routes are the same ignore the params and return their count', () => {
// $FlowFixMe[cannot-write] Make Flow understand about mocking.
NavigationService.getState = jest.fn().mockReturnValue(
deepFreeze({
routes: [
{ name: 'login' },
{ name: 'main-tabs' },
{ name: 'chat', params: { key: 'value' } },
{ name: 'chat', params: { key: 'another value' } },
{ name: 'chat', params: { anotherKey: 'some value' } },
],
}),
);

const action = navigateBack();

expect(action.payload.count).toEqual(3);
});
});
107 changes: 0 additions & 107 deletions src/nav/__tests__/navSelectors-test.js

This file was deleted.

17 changes: 15 additions & 2 deletions src/nav/navActions.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
/* @flow strict-local */
import {
type PopAction,
StackActions,
CommonActions,
type GenericNavigationAction,
} from '@react-navigation/native';

import * as NavigationService from './NavigationService';
import type { Message, Narrow, UserId } from '../types';
import type { SharedData } from '../sharing/types';
import type { ApiResponseServerSettings } from '../api/settings/getServerSettings';
import { getSameRoutesCount } from '../selectors';

export const navigateBack = (): GenericNavigationAction => StackActions.pop(getSameRoutesCount());
// TODO: Probably just do a StackActions.pop()?
export const navigateBack = (): PopAction => {
const routes = NavigationService.getState().routes;
let i = routes.length - 1;
while (i >= 0) {
if (routes[i].name !== routes[routes.length - 1].name) {
break;
}
i--;
}
const sameRoutesCount = routes.length - i - 1;
return StackActions.pop(sameRoutesCount);
};

/*
* "Reset" actions, to explicitly prohibit back navigation.
Expand Down
31 changes: 0 additions & 31 deletions src/nav/navSelectors.js

This file was deleted.

1 change: 0 additions & 1 deletion src/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export * from './chat/fetchingSelectors';
export * from './directSelectors';
export * from './emoji/emojiSelectors';
export * from './message/messageSelectors';
export * from './nav/navSelectors';
export * from './subscriptions/subscriptionSelectors';
export * from './topics/topicSelectors';
export * from './typing/typingSelectors';
Expand Down
16 changes: 0 additions & 16 deletions src/utils/sound.js

This file was deleted.

5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9222,11 +9222,6 @@ react-native-simple-toast@^1.0.0:
resolved "https://registry.yarnpkg.com/react-native-simple-toast/-/react-native-simple-toast-1.1.3.tgz#4d0835891fe5c9342341fc4a88ed01ebb1a34bd5"
integrity sha512-bkZy25axqlU4L6IoTysSl5KOQA7qdxzivbXz/L/yAw9g9fENxjzYvUUtv5wWtgq7mzOe5HiJ7GCQrOl3MhIevQ==

react-native-sound@^0.11.0:
version "0.11.0"
resolved "https://registry.yarnpkg.com/react-native-sound/-/react-native-sound-0.11.0.tgz#ad60b55ba8c6dc89917f381ad3713f2738de530f"
integrity sha512-4bGAZfni6E2L695NQjOZwNLBQGXgBGYC4Sy+h99K5h0HqNZjCqR0+aLel+ezASxEJDpaH83gylNObXpiqJgdwg==

react-native-tab-view@^2.15.2:
version "2.16.0"
resolved "https://registry.yarnpkg.com/react-native-tab-view/-/react-native-tab-view-2.16.0.tgz#cae72c7084394bd328fac5fefb86cd966df37a86"
Expand Down