Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
enzevalos_iphone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
enzevalos
enzevalos_iphone
Commits
f4857a6a
Commit
f4857a6a
authored
5 years ago
by
cpilaszewicz
Browse files
Options
Downloads
Patches
Plain Diff
Create an enum for authentication results
parent
449d0370
No related branches found
No related tags found
4 merge requests
!58
Onboarding screens swift ui merge dev
,
!55
WIP: Resolve "UI for gamifcation & stats"
,
!47
Provisional fix for OpenSSL 1.1+, needs testing
,
!39
Resolve "Restructure Authentication"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
enzevalos_iphone/AuthenticationModel.swift
+10
-3
10 additions, 3 deletions
enzevalos_iphone/AuthenticationModel.swift
enzevalos_iphone/AuthenticationViewModel.swift
+6
-7
6 additions, 7 deletions
enzevalos_iphone/AuthenticationViewModel.swift
with
16 additions
and
10 deletions
enzevalos_iphone/AuthenticationModel.swift
+
10
−
3
View file @
f4857a6a
...
...
@@ -11,7 +11,7 @@ import Combine
class
AuthenticationModel
:
NSObject
{
enum
AuthenticationResult
{
case
Success
,
Timeout
,
Error
}
enum
AuthenticationResult
{
case
Success
,
Timeout
,
Error
(
value
:
MailServerConnectionError
)
}
static
let
instance
:
AuthenticationModel
=
AuthenticationModel
()
...
...
@@ -50,7 +50,6 @@ class AuthenticationModel: NSObject {
let
result
=
self
.
dispatchGroup
.
wait
(
timeout
:
DispatchTime
.
now
()
+
timeoutDelay
)
DispatchQueue
.
main
.
async
{
promise
(
.
success
(
self
.
onTimeout
(
timeoutResult
:
result
)))
print
(
"promise sent"
)
}
}
}
...
...
@@ -120,7 +119,15 @@ class AuthenticationModel: NSObject {
if
imapConfigurationSuccessful
&&
smtpConfigurationSuccessful
{
return
AuthenticationResult
.
Success
}
else
{
return
AuthenticationResult
.
Error
var
error
=
MailServerConnectionError
.
AuthenticationError
if
let
smtp
=
currentIMAP
,
let
e
=
MailServerConnectionError
.
findPrioError
(
errors
:
smtp
.
errors
)
{
error
=
e
}
if
let
imap
=
currentIMAP
,
let
e
=
MailServerConnectionError
.
findPrioError
(
errors
:
imap
.
errors
)
{
error
=
e
}
return
AuthenticationResult
.
Error
(
value
:
error
)
}
}
else
{
return
AuthenticationResult
.
Timeout
...
...
This diff is collapsed.
Click to expand it.
enzevalos_iphone/AuthenticationViewModel.swift
+
6
−
7
View file @
f4857a6a
...
...
@@ -31,7 +31,7 @@ class AuthenticationViewModel : ObservableObject {
case
AuthenticationModel
.
AuthenticationResult
.
Error
:
self
.
authenticationFailed
(
error
:
MailServerConnectionError
.
AuthenticationError
)
case
AuthenticationModel
.
AuthenticationResult
.
Timeout
:
self
.
timeoutNotification
(
result
:
promise
)
self
.
timeoutNotification
()
}
}
}
...
...
@@ -43,10 +43,10 @@ class AuthenticationViewModel : ObservableObject {
switch
promise
{
case
AuthenticationModel
.
AuthenticationResult
.
Success
:
self
.
authenticationSucceed
()
case
AuthenticationModel
.
AuthenticationResult
.
Error
:
self
.
authenticationFailed
(
error
:
MailServerConnectionError
.
AuthenticationError
)
case
AuthenticationModel
.
AuthenticationResult
.
Error
(
let
value
)
:
self
.
authenticationFailed
(
error
:
value
)
case
AuthenticationModel
.
AuthenticationResult
.
Timeout
:
self
.
timeoutNotification
(
result
:
promise
)
self
.
timeoutNotification
()
}
}
}
...
...
@@ -72,7 +72,7 @@ class AuthenticationViewModel : ObservableObject {
case
AuthenticationModel
.
AuthenticationResult
.
Error
:
self
.
authenticationFailed
(
error
:
MailServerConnectionError
.
AuthenticationError
)
case
AuthenticationModel
.
AuthenticationResult
.
Timeout
:
self
.
timeoutNotification
(
result
:
promise
)
self
.
timeoutNotification
()
}
}
})
...
...
@@ -86,8 +86,7 @@ class AuthenticationViewModel : ObservableObject {
errorMessage
=
NSLocalizedString
(
error
.
localizedUIBodyString
,
comment
:
""
)
}
func
timeoutNotification
(
result
:
AuthenticationModel
.
AuthenticationResult
)
{
print
(
"promise arrived"
)
func
timeoutNotification
()
{
errorMessage
=
NSLocalizedString
(
MailServerConnectionError
.
TimeoutError
.
localizedUIBodyString
,
comment
:
""
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment