chore: rename highlightTroubleshooting
This commit is contained in:
parent
15cab12479
commit
f9f350a92a
|
@ -17,7 +17,7 @@ describe('test troubleshootingNotification reducer', () => {
|
||||||
it('should return correctly value after call troubleshootingNotification action', () => {
|
it('should return correctly value after call troubleshootingNotification action', () => {
|
||||||
const payload: ITroubleshootingNotification = {
|
const payload: ITroubleshootingNotification = {
|
||||||
deviceNotificationEnabled: true,
|
deviceNotificationEnabled: true,
|
||||||
highlightTroubleshooting: false,
|
issuesWithNotifications: false,
|
||||||
defaultPushGateway: true,
|
defaultPushGateway: true,
|
||||||
pushGatewayEnabled: true,
|
pushGatewayEnabled: true,
|
||||||
consumptionPercentage: 0,
|
consumptionPercentage: 0,
|
||||||
|
|
|
@ -5,7 +5,7 @@ export interface ITroubleshootingNotification {
|
||||||
deviceNotificationEnabled: boolean;
|
deviceNotificationEnabled: boolean;
|
||||||
pushGatewayEnabled: boolean;
|
pushGatewayEnabled: boolean;
|
||||||
defaultPushGateway: boolean;
|
defaultPushGateway: boolean;
|
||||||
highlightTroubleshooting: boolean;
|
issuesWithNotifications: boolean;
|
||||||
consumptionPercentage: number;
|
consumptionPercentage: number;
|
||||||
isCommunityEdition: boolean;
|
isCommunityEdition: boolean;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ export const initialState: ITroubleshootingNotification = {
|
||||||
deviceNotificationEnabled: false,
|
deviceNotificationEnabled: false,
|
||||||
pushGatewayEnabled: false,
|
pushGatewayEnabled: false,
|
||||||
defaultPushGateway: false,
|
defaultPushGateway: false,
|
||||||
highlightTroubleshooting: false,
|
issuesWithNotifications: false,
|
||||||
consumptionPercentage: 0,
|
consumptionPercentage: 0,
|
||||||
isCommunityEdition: false
|
isCommunityEdition: false
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { Action } from 'redux';
|
import { Action } from 'redux';
|
||||||
import { put, takeEvery } from 'redux-saga/effects';
|
import { call, takeLatest, put } from 'typed-redux-saga';
|
||||||
import { call } from 'typed-redux-saga';
|
import notifee, { AuthorizationStatus } from '@notifee/react-native';
|
||||||
import notifee from '@notifee/react-native';
|
|
||||||
|
|
||||||
import { TROUBLESHOOTING_NOTIFICATION } from '../actions/actionsTypes';
|
import { TROUBLESHOOTING_NOTIFICATION } from '../actions/actionsTypes';
|
||||||
import { setTroubleshootingNotification } from '../actions/troubleshootingNotification';
|
import { setTroubleshootingNotification } from '../actions/troubleshootingNotification';
|
||||||
|
@ -20,32 +19,28 @@ function* request() {
|
||||||
let defaultPushGateway = false;
|
let defaultPushGateway = false;
|
||||||
let pushGatewayEnabled = false;
|
let pushGatewayEnabled = false;
|
||||||
try {
|
try {
|
||||||
const { authorizationStatus } = yield * call(notifee.getNotificationSettings);
|
const { authorizationStatus } = yield* call(notifee.getNotificationSettings);
|
||||||
deviceNotificationEnabled = authorizationStatus > 0;
|
deviceNotificationEnabled = authorizationStatus > AuthorizationStatus.DENIED;
|
||||||
const pushInfoResult = yield * call(pushInfo);
|
const pushInfoResult = yield* call(pushInfo);
|
||||||
if (pushInfoResult.success) {
|
if (pushInfoResult.success) {
|
||||||
pushGatewayEnabled = pushInfoResult.pushGatewayEnabled;
|
pushGatewayEnabled = pushInfoResult.pushGatewayEnabled;
|
||||||
defaultPushGateway = pushInfoResult.defaultPushGateway;
|
defaultPushGateway = pushInfoResult.defaultPushGateway;
|
||||||
}
|
}
|
||||||
// TODO: Need to request the information of push quota and if the server is a community edition
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e);
|
log(e);
|
||||||
} finally {
|
|
||||||
// If Any of the items that can have red values: notification settings, CE quota, or gateway connection; the red icon should show.
|
|
||||||
// Then highlightTroubleshooting has to be true
|
|
||||||
const highlightTroubleshooting =
|
|
||||||
!deviceNotificationEnabled || (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '6.6.0') && !pushGatewayEnabled);
|
|
||||||
yield put(
|
|
||||||
setTroubleshootingNotification({
|
|
||||||
deviceNotificationEnabled,
|
|
||||||
defaultPushGateway,
|
|
||||||
pushGatewayEnabled,
|
|
||||||
highlightTroubleshooting
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
const issuesWithNotifications =
|
||||||
|
!deviceNotificationEnabled || (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '6.6.0') && !pushGatewayEnabled);
|
||||||
|
yield put(
|
||||||
|
setTroubleshootingNotification({
|
||||||
|
deviceNotificationEnabled,
|
||||||
|
defaultPushGateway,
|
||||||
|
pushGatewayEnabled,
|
||||||
|
issuesWithNotifications
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function* root(): Generator {
|
export default function* root(): Generator {
|
||||||
yield takeEvery<IGenericAction>(TROUBLESHOOTING_NOTIFICATION.REQUEST, request);
|
yield takeLatest<IGenericAction>(TROUBLESHOOTING_NOTIFICATION.REQUEST, request);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ interface IRightButtonsProps extends Pick<ISubscription, 't'> {
|
||||||
rid?: string;
|
rid?: string;
|
||||||
theme?: TSupportedThemes;
|
theme?: TSupportedThemes;
|
||||||
colors?: TColors;
|
colors?: TColors;
|
||||||
highlightTroubleshooting: boolean;
|
issuesWithNotifications: boolean;
|
||||||
disableNotifications?: boolean;
|
disableNotifications?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps: IRightButtonsProps, nextState: IRigthButtonsState) {
|
shouldComponentUpdate(nextProps: IRightButtonsProps, nextState: IRigthButtonsState) {
|
||||||
const { isFollowingThread, tunread, tunreadUser, tunreadGroup } = this.state;
|
const { isFollowingThread, tunread, tunreadUser, tunreadGroup } = this.state;
|
||||||
const { teamId, status, joined, omnichannelPermissions, theme, highlightTroubleshooting, disableNotifications } = this.props;
|
const { teamId, status, joined, omnichannelPermissions, theme, issuesWithNotifications, disableNotifications } = this.props;
|
||||||
if (nextProps.teamId !== teamId) {
|
if (nextProps.teamId !== teamId) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
|
||||||
if (nextState.isFollowingThread !== isFollowingThread) {
|
if (nextState.isFollowingThread !== isFollowingThread) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (nextProps.highlightTroubleshooting !== highlightTroubleshooting) {
|
if (nextProps.issuesWithNotifications !== issuesWithNotifications) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (nextProps.disableNotifications !== disableNotifications) {
|
if (nextProps.disableNotifications !== disableNotifications) {
|
||||||
|
@ -305,12 +305,12 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
|
||||||
|
|
||||||
goToNotification = () => {
|
goToNotification = () => {
|
||||||
const { room } = this;
|
const { room } = this;
|
||||||
const { rid, navigation, isMasterDetail, highlightTroubleshooting } = this.props;
|
const { rid, navigation, isMasterDetail, issuesWithNotifications } = this.props;
|
||||||
|
|
||||||
if (!rid || !room) {
|
if (!rid || !room) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!highlightTroubleshooting && room) {
|
if (!issuesWithNotifications && room) {
|
||||||
if (isMasterDetail) {
|
if (isMasterDetail) {
|
||||||
navigation.navigate('ModalStackNavigator', {
|
navigation.navigate('ModalStackNavigator', {
|
||||||
screen: 'NotificationPrefView',
|
screen: 'NotificationPrefView',
|
||||||
|
@ -361,7 +361,7 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { isFollowingThread, tunread, tunreadUser, tunreadGroup } = this.state;
|
const { isFollowingThread, tunread, tunreadUser, tunreadGroup } = this.state;
|
||||||
const { t, tmid, threadsEnabled, rid, colors, highlightTroubleshooting, disableNotifications } = this.props;
|
const { t, tmid, threadsEnabled, rid, colors, issuesWithNotifications, disableNotifications } = this.props;
|
||||||
|
|
||||||
if (t === 'l') {
|
if (t === 'l') {
|
||||||
if (!this.isOmnichannelPreview()) {
|
if (!this.isOmnichannelPreview()) {
|
||||||
|
@ -386,9 +386,9 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<HeaderButton.Container>
|
<HeaderButton.Container>
|
||||||
{highlightTroubleshooting || disableNotifications ? (
|
{issuesWithNotifications || disableNotifications ? (
|
||||||
<HeaderButton.Item
|
<HeaderButton.Item
|
||||||
color={highlightTroubleshooting ? colors!.fontDanger : colors!.headerTintColor}
|
color={issuesWithNotifications ? colors!.fontDanger : colors!.headerTintColor}
|
||||||
iconName='notification-disabled'
|
iconName='notification-disabled'
|
||||||
onPress={this.goToNotification}
|
onPress={this.goToNotification}
|
||||||
testID='room-view-push-troubleshoot'
|
testID='room-view-push-troubleshoot'
|
||||||
|
@ -414,7 +414,7 @@ const mapStateToProps = (state: IApplicationState) => ({
|
||||||
threadsEnabled: state.settings.Threads_enabled as boolean,
|
threadsEnabled: state.settings.Threads_enabled as boolean,
|
||||||
isMasterDetail: state.app.isMasterDetail,
|
isMasterDetail: state.app.isMasterDetail,
|
||||||
livechatRequestComment: state.settings.Livechat_request_comment_when_closing_conversation as boolean,
|
livechatRequestComment: state.settings.Livechat_request_comment_when_closing_conversation as boolean,
|
||||||
highlightTroubleshooting: state.troubleshootingNotification.highlightTroubleshooting
|
issuesWithNotifications: state.troubleshootingNotification.issuesWithNotifications
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(mapStateToProps)(withTheme(RightButtonsContainer));
|
export default connect(mapStateToProps)(withTheme(RightButtonsContainer));
|
||||||
|
|
|
@ -92,7 +92,7 @@ interface IRoomsListViewProps {
|
||||||
createPrivateChannelPermission: [];
|
createPrivateChannelPermission: [];
|
||||||
createDiscussionPermission: [];
|
createDiscussionPermission: [];
|
||||||
serverVersion: string;
|
serverVersion: string;
|
||||||
highlightTroubleshooting: boolean;
|
issuesWithNotifications: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IRoomsListViewState {
|
interface IRoomsListViewState {
|
||||||
|
@ -147,7 +147,7 @@ const shouldUpdateProps = [
|
||||||
'createPublicChannelPermission',
|
'createPublicChannelPermission',
|
||||||
'createPrivateChannelPermission',
|
'createPrivateChannelPermission',
|
||||||
'createDiscussionPermission',
|
'createDiscussionPermission',
|
||||||
'highlightTroubleshooting',
|
'issuesWithNotifications',
|
||||||
'supportedVersionsStatus'
|
'supportedVersionsStatus'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -335,7 +335,7 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
|
||||||
createDiscussionPermission,
|
createDiscussionPermission,
|
||||||
showAvatar,
|
showAvatar,
|
||||||
displayMode,
|
displayMode,
|
||||||
highlightTroubleshooting,
|
issuesWithNotifications,
|
||||||
supportedVersionsStatus
|
supportedVersionsStatus
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { item } = this.state;
|
const { item } = this.state;
|
||||||
|
@ -360,7 +360,7 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
|
||||||
insets.left !== prevProps.insets.left ||
|
insets.left !== prevProps.insets.left ||
|
||||||
insets.right !== prevProps.insets.right ||
|
insets.right !== prevProps.insets.right ||
|
||||||
notificationPresenceCap !== prevProps.notificationPresenceCap ||
|
notificationPresenceCap !== prevProps.notificationPresenceCap ||
|
||||||
highlightTroubleshooting !== prevProps.highlightTroubleshooting ||
|
issuesWithNotifications !== prevProps.issuesWithNotifications ||
|
||||||
supportedVersionsStatus !== prevProps.supportedVersionsStatus
|
supportedVersionsStatus !== prevProps.supportedVersionsStatus
|
||||||
) {
|
) {
|
||||||
this.setHeader();
|
this.setHeader();
|
||||||
|
@ -414,7 +414,7 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
|
||||||
|
|
||||||
getHeader = (): StackNavigationOptions => {
|
getHeader = (): StackNavigationOptions => {
|
||||||
const { searching, canCreateRoom } = this.state;
|
const { searching, canCreateRoom } = this.state;
|
||||||
const { navigation, isMasterDetail, notificationPresenceCap, highlightTroubleshooting, supportedVersionsStatus, theme } =
|
const { navigation, isMasterDetail, notificationPresenceCap, issuesWithNotifications, supportedVersionsStatus, theme } =
|
||||||
this.props;
|
this.props;
|
||||||
if (searching) {
|
if (searching) {
|
||||||
return {
|
return {
|
||||||
|
@ -462,7 +462,7 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
|
||||||
headerTitle: () => <RoomsListHeaderView />,
|
headerTitle: () => <RoomsListHeaderView />,
|
||||||
headerRight: () => (
|
headerRight: () => (
|
||||||
<HeaderButton.Container>
|
<HeaderButton.Container>
|
||||||
{highlightTroubleshooting ? (
|
{issuesWithNotifications ? (
|
||||||
<HeaderButton.Item
|
<HeaderButton.Item
|
||||||
iconName='notification-disabled'
|
iconName='notification-disabled'
|
||||||
onPress={this.goPushTroubleshoot}
|
onPress={this.goPushTroubleshoot}
|
||||||
|
@ -1030,7 +1030,7 @@ const mapStateToProps = (state: IApplicationState) => ({
|
||||||
createPrivateChannelPermission: state.permissions['create-p'],
|
createPrivateChannelPermission: state.permissions['create-p'],
|
||||||
createDiscussionPermission: state.permissions['start-discussion'],
|
createDiscussionPermission: state.permissions['start-discussion'],
|
||||||
serverVersion: state.server.version,
|
serverVersion: state.server.version,
|
||||||
highlightTroubleshooting: state.troubleshootingNotification.highlightTroubleshooting
|
issuesWithNotifications: state.troubleshootingNotification.issuesWithNotifications
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(mapStateToProps)(withDimensions(withTheme(withSafeAreaInsets(RoomsListView))));
|
export default connect(mapStateToProps)(withDimensions(withTheme(withSafeAreaInsets(RoomsListView))));
|
||||||
|
|
Loading…
Reference in New Issue