Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
1
1weather
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
1weather
Commits
a32a7dfc
Commit
a32a7dfc
authored
Apr 24, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Notifications list is properly updated.
parent
3e506463
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
6 deletions
+26
-6
1Weather/Model/LocationManager.swift
+6
-4
1Weather/Network/Notifications/NWSAlertsManager.swift
+3
-1
1Weather/ViewModels/NotificationsViewModel.swift
+17
-1
No files found.
1Weather/Model/LocationManager.swift
View file @
a32a7dfc
...
...
@@ -478,11 +478,13 @@ extension LocationManager: DeviceLocationMonitorDelegate {
// MARK: - NWSAlertsManagerDelegate
extension
LocationManager
:
NWSAlertsManagerDelegate
{
public
func
alertsListDidChange
(
in
alertsManager
:
NWSAlertsManager
)
{
// do nothing
}
public
func
extendedInfoAvailable
(
from
alertsManager
:
NWSAlertsManager
,
for
alert
:
NWSAlert
)
{
DispatchQueue
.
main
.
async
{
if
let
alertIndex
=
self
.
selectedLocation
?
.
notifications
?
.
nwsAlerts
.
firstIndex
(
of
:
alert
)
{
self
.
selectedLocation
?
.
notifications
?
.
nwsAlerts
[
alertIndex
]
=
alert
}
if
let
alertIndex
=
self
.
selectedLocation
?
.
notifications
?
.
nwsAlerts
.
firstIndex
(
of
:
alert
)
{
self
.
selectedLocation
?
.
notifications
?
.
nwsAlerts
[
alertIndex
]
=
alert
}
}
}
1Weather/Network/Notifications/NWSAlertsManager.swift
View file @
a32a7dfc
...
...
@@ -16,7 +16,8 @@ public enum NWSError: Error {
}
public
protocol
NWSAlertsManagerDelegate
:
class
{
func
extendedInfoAvailable
(
from
alertsManager
:
NWSAlertsManager
,
for
alert
:
NWSAlert
)
func
alertsListDidChange
(
in
alertsManager
:
NWSAlertsManager
)
func
extendedInfoAvailable
(
from
alertsManager
:
NWSAlertsManager
,
for
alert
:
NWSAlert
)
}
public
class
NWSAlertsManager
{
...
...
@@ -202,6 +203,7 @@ public class NWSAlertsManager {
// A deadlock shouldn't happen unless main thread waits on internalQueue, which it doesn't.
DispatchQueue
.
main
.
sync
{
self
.
alerts
=
resultingAlerts
self
.
delegate
?
.
alertsListDidChange
(
in
:
self
)
}
fetchAllExtendedInfo
(
for
:
resultingAlerts
)
}
...
...
1Weather/ViewModels/NotificationsViewModel.swift
View file @
a32a7dfc
...
...
@@ -9,9 +9,25 @@ import Foundation
class
NotificationsViewModel
:
ViewModelProtocol
{
public
weak
var
delegate
:
ViewModelDelegate
?
private
let
alertsManager
:
NWSAlertsManager
=
LocationManager
.
shared
.
nwsAlertsManager
private
let
alertsManager
:
NWSAlertsManager
public
init
(
alertsManager
:
NWSAlertsManager
=
LocationManager
.
shared
.
nwsAlertsManager
)
{
self
.
alertsManager
=
alertsManager
alertsManager
.
delegate
=
self
}
public
var
alerts
:
[
NWSAlert
]
{
alertsManager
.
alerts
}
}
extension
NotificationsViewModel
:
NWSAlertsManagerDelegate
{
func
extendedInfoAvailable
(
from
alertsManager
:
NWSAlertsManager
,
for
alert
:
NWSAlert
)
{
self
.
delegate
?
.
viewModelDidChange
(
model
:
self
)
}
func
alertsListDidChange
(
in
alertsManager
:
NWSAlertsManager
)
{
self
.
delegate
?
.
viewModelDidChange
(
model
:
self
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment