chore: rename highlightTroubleshooting

This commit is contained in:
GleidsonDaniel 2024-02-20 14:19:57 -03:00
parent 15cab12479
commit f9f350a92a
5 changed files with 35 additions and 40 deletions

View File

@ -17,7 +17,7 @@ describe('test troubleshootingNotification reducer', () => {
it('should return correctly value after call troubleshootingNotification action', () => {
const payload: ITroubleshootingNotification = {
deviceNotificationEnabled: true,
highlightTroubleshooting: false,
issuesWithNotifications: false,
defaultPushGateway: true,
pushGatewayEnabled: true,
consumptionPercentage: 0,

View File

@ -5,7 +5,7 @@ export interface ITroubleshootingNotification {
deviceNotificationEnabled: boolean;
pushGatewayEnabled: boolean;
defaultPushGateway: boolean;
highlightTroubleshooting: boolean;
issuesWithNotifications: boolean;
consumptionPercentage: number;
isCommunityEdition: boolean;
}
@ -14,7 +14,7 @@ export const initialState: ITroubleshootingNotification = {
deviceNotificationEnabled: false,
pushGatewayEnabled: false,
defaultPushGateway: false,
highlightTroubleshooting: false,
issuesWithNotifications: false,
consumptionPercentage: 0,
isCommunityEdition: false
};

View File

@ -1,7 +1,6 @@
import { Action } from 'redux';
import { put, takeEvery } from 'redux-saga/effects';
import { call } from 'typed-redux-saga';
import notifee from '@notifee/react-native';
import { call, takeLatest, put } from 'typed-redux-saga';
import notifee, { AuthorizationStatus } from '@notifee/react-native';
import { TROUBLESHOOTING_NOTIFICATION } from '../actions/actionsTypes';
import { setTroubleshootingNotification } from '../actions/troubleshootingNotification';
@ -20,32 +19,28 @@ function* request() {
let defaultPushGateway = false;
let pushGatewayEnabled = false;
try {
const { authorizationStatus } = yield * call(notifee.getNotificationSettings);
deviceNotificationEnabled = authorizationStatus > 0;
const pushInfoResult = yield * call(pushInfo);
const { authorizationStatus } = yield* call(notifee.getNotificationSettings);
deviceNotificationEnabled = authorizationStatus > AuthorizationStatus.DENIED;
const pushInfoResult = yield* call(pushInfo);
if (pushInfoResult.success) {
pushGatewayEnabled = pushInfoResult.pushGatewayEnabled;
defaultPushGateway = pushInfoResult.defaultPushGateway;
}
// TODO: Need to request the information of push quota and if the server is a community edition
} catch (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 {
yield takeEvery<IGenericAction>(TROUBLESHOOTING_NOTIFICATION.REQUEST, request);
yield takeLatest<IGenericAction>(TROUBLESHOOTING_NOTIFICATION.REQUEST, request);
}

View File

@ -46,7 +46,7 @@ interface IRightButtonsProps extends Pick<ISubscription, 't'> {
rid?: string;
theme?: TSupportedThemes;
colors?: TColors;
highlightTroubleshooting: boolean;
issuesWithNotifications: boolean;
disableNotifications?: boolean;
}
@ -96,7 +96,7 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
shouldComponentUpdate(nextProps: IRightButtonsProps, nextState: IRigthButtonsState) {
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) {
return true;
}
@ -112,7 +112,7 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
if (nextState.isFollowingThread !== isFollowingThread) {
return true;
}
if (nextProps.highlightTroubleshooting !== highlightTroubleshooting) {
if (nextProps.issuesWithNotifications !== issuesWithNotifications) {
return true;
}
if (nextProps.disableNotifications !== disableNotifications) {
@ -305,12 +305,12 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
goToNotification = () => {
const { room } = this;
const { rid, navigation, isMasterDetail, highlightTroubleshooting } = this.props;
const { rid, navigation, isMasterDetail, issuesWithNotifications } = this.props;
if (!rid || !room) {
return;
}
if (!highlightTroubleshooting && room) {
if (!issuesWithNotifications && room) {
if (isMasterDetail) {
navigation.navigate('ModalStackNavigator', {
screen: 'NotificationPrefView',
@ -361,7 +361,7 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
render() {
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 (!this.isOmnichannelPreview()) {
@ -386,9 +386,9 @@ class RightButtonsContainer extends Component<IRightButtonsProps, IRigthButtonsS
}
return (
<HeaderButton.Container>
{highlightTroubleshooting || disableNotifications ? (
{issuesWithNotifications || disableNotifications ? (
<HeaderButton.Item
color={highlightTroubleshooting ? colors!.fontDanger : colors!.headerTintColor}
color={issuesWithNotifications ? colors!.fontDanger : colors!.headerTintColor}
iconName='notification-disabled'
onPress={this.goToNotification}
testID='room-view-push-troubleshoot'
@ -414,7 +414,7 @@ const mapStateToProps = (state: IApplicationState) => ({
threadsEnabled: state.settings.Threads_enabled as boolean,
isMasterDetail: state.app.isMasterDetail,
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));

View File

@ -92,7 +92,7 @@ interface IRoomsListViewProps {
createPrivateChannelPermission: [];
createDiscussionPermission: [];
serverVersion: string;
highlightTroubleshooting: boolean;
issuesWithNotifications: boolean;
}
interface IRoomsListViewState {
@ -147,7 +147,7 @@ const shouldUpdateProps = [
'createPublicChannelPermission',
'createPrivateChannelPermission',
'createDiscussionPermission',
'highlightTroubleshooting',
'issuesWithNotifications',
'supportedVersionsStatus'
];
@ -335,7 +335,7 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
createDiscussionPermission,
showAvatar,
displayMode,
highlightTroubleshooting,
issuesWithNotifications,
supportedVersionsStatus
} = this.props;
const { item } = this.state;
@ -360,7 +360,7 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
insets.left !== prevProps.insets.left ||
insets.right !== prevProps.insets.right ||
notificationPresenceCap !== prevProps.notificationPresenceCap ||
highlightTroubleshooting !== prevProps.highlightTroubleshooting ||
issuesWithNotifications !== prevProps.issuesWithNotifications ||
supportedVersionsStatus !== prevProps.supportedVersionsStatus
) {
this.setHeader();
@ -414,7 +414,7 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
getHeader = (): StackNavigationOptions => {
const { searching, canCreateRoom } = this.state;
const { navigation, isMasterDetail, notificationPresenceCap, highlightTroubleshooting, supportedVersionsStatus, theme } =
const { navigation, isMasterDetail, notificationPresenceCap, issuesWithNotifications, supportedVersionsStatus, theme } =
this.props;
if (searching) {
return {
@ -462,7 +462,7 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
headerTitle: () => <RoomsListHeaderView />,
headerRight: () => (
<HeaderButton.Container>
{highlightTroubleshooting ? (
{issuesWithNotifications ? (
<HeaderButton.Item
iconName='notification-disabled'
onPress={this.goPushTroubleshoot}
@ -1030,7 +1030,7 @@ const mapStateToProps = (state: IApplicationState) => ({
createPrivateChannelPermission: state.permissions['create-p'],
createDiscussionPermission: state.permissions['start-discussion'],
serverVersion: state.server.version,
highlightTroubleshooting: state.troubleshootingNotification.highlightTroubleshooting
issuesWithNotifications: state.troubleshootingNotification.issuesWithNotifications
});
export default connect(mapStateToProps)(withDimensions(withTheme(withSafeAreaInsets(RoomsListView))));