From c1cc1cdcafa004550c415b92a56734a1632e138d Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Thu, 9 Jul 2015 16:06:12 +0300 Subject: [PATCH] more code improvements --- ui/dialogs/dialogs.ios.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ui/dialogs/dialogs.ios.ts b/ui/dialogs/dialogs.ios.ts index 9ce793d45..aaf07f81c 100644 --- a/ui/dialogs/dialogs.ios.ts +++ b/ui/dialogs/dialogs.ios.ts @@ -85,17 +85,21 @@ function addButtonsToAlertDialog(alert: UIAlertView, options: dialogs.ConfirmOpt } function getDialogResult(buttons: allertButtons, index: number) { - if (buttons & allertButtons.cancel && buttons & allertButtons.neutral && buttons & allertButtons.ok) { + var hasCancel = buttons & allertButtons.cancel; + var hasNeutral = buttons & allertButtons.neutral; + var hasOk = buttons & allertButtons.ok; + + if (hasCancel && hasNeutral && hasOk) { return index === 0 ? false : index === 2 ? true : undefined; - } else if (buttons & allertButtons.neutral && buttons & allertButtons.ok) { + } else if (buttons & hasNeutral && hasOk) { return index === 0 ? undefined : true; - } else if (buttons & allertButtons.cancel && buttons & allertButtons.ok) { + } else if (hasCancel && hasOk) { return index !== 0; - } else if (buttons & allertButtons.cancel && buttons & allertButtons.neutral) { + } else if (hasCancel && hasNeutral) { return index === 0 ? false : undefined; - } else if (buttons & allertButtons.cancel) { + } else if (hasCancel) { return false; - } else if (buttons & allertButtons.ok) { + } else if (hasOk) { return true; }