Skip to content

Commit

Permalink
fix error on triggering call style notif twice
Browse files Browse the repository at this point in the history
  • Loading branch information
dprevost-LMI committed Oct 31, 2024
1 parent 93f82cf commit 2f99ad6
Showing 1 changed file with 39 additions and 23 deletions.
62 changes: 39 additions & 23 deletions packages/react-native/src/validators/validateAndroidStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ import {
AndroidCallStyle,
AndroidStyle,
AndroidCallType,
AndroidAction,
} from '../types/NotificationAndroid';
import { objectHasProperty, isArray, isBoolean, isNumber, isObject, isString } from '../utils';
import validateAndroidPressAction from './validateAndroidPressAction';
import validateAndroidAction from './validateAndroidAction';

/**
Expand Down Expand Up @@ -343,28 +341,46 @@ export function validateAndroidCallStyle(style: AndroidCallStyle): AndroidCallSt
throw new Error("'callType' expected a number value.");
}

const out: AndroidCallStyle = {
type: AndroidStyle.CALL,
person,
callTypeActions: style.callTypeActions,
};

switch (out.callTypeActions.callType) {
case AndroidCallType.INCOMING:
out.callTypeActions.answerAction = validateAndroidAction(out.callTypeActions.answerAction)
out.callTypeActions.declineAction = validateAndroidAction(out.callTypeActions.declineAction)
break;
case AndroidCallType.ONGOING:

out.callTypeActions.hangUpAction = validateAndroidAction(out.callTypeActions.hangUpAction)
break;
case AndroidCallType.SCREENING:
out.callTypeActions.answerAction = validateAndroidAction(out.callTypeActions.answerAction)
out.callTypeActions.hangUpAction = validateAndroidAction(out.callTypeActions.hangUpAction)
break;
default:
throw new Error("'callType' expected a value of 0, 1 or 2.");
switch (style.callTypeActions.callType) {
case AndroidCallType.INCOMING: {
const answerAction = validateAndroidAction(style.callTypeActions.answerAction)
const declineAction = validateAndroidAction(style.callTypeActions.declineAction)
return {
type: AndroidStyle.CALL,
person,
callTypeActions: {
...style.callTypeActions,
answerAction,
declineAction
},
};
}
case AndroidCallType.ONGOING: {
const hangUpAction = validateAndroidAction(style.callTypeActions.hangUpAction)
return {
type: AndroidStyle.CALL,
person,
callTypeActions: {
...style.callTypeActions,
hangUpAction
},
};
}
case AndroidCallType.SCREENING: {
const answerAction = validateAndroidAction(style.callTypeActions.answerAction)
const hangUpAction = validateAndroidAction(style.callTypeActions.hangUpAction)
return {
type: AndroidStyle.CALL,
person,
callTypeActions: {
...style.callTypeActions,
answerAction,
hangUpAction
},
};
}
default: throw new Error("'callType' expected a value of 0, 1 or 2.");
}

return out;
}

0 comments on commit 2f99ad6

Please sign in to comment.