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
6609f62d
Commit
6609f62d
authored
Sep 03, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IOS-259: fix potential duplicate WIDGET_UPDATE.
parent
c2fa601a
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
22 deletions
+19
-22
OneWeatherCore/OneWeatherCore/Managers/WidgetManager.swift
+3
-12
OneWeatherWidget/Data/WeatherProvider.swift
+12
-6
OneWeatherWidget/Widgets/PrecipitationWidget.swift
+1
-1
OneWeatherWidget/Widgets/RadarWidget.swift
+1
-1
OneWeatherWidget/Widgets/TemperatureWidget.swift
+1
-1
OneWeatherWidget/Widgets/WindWidget.swift
+1
-1
No files found.
OneWeatherCore/OneWeatherCore/Managers/WidgetManager.swift
View file @
6609f62d
...
@@ -133,12 +133,8 @@ public class WidgetManager {
...
@@ -133,12 +133,8 @@ public class WidgetManager {
params
:
[
.
ANALYTICS_KEY_WIDGET_NAME
:
name
])
params
:
[
.
ANALYTICS_KEY_WIDGET_NAME
:
name
])
}
}
public
func
logUpdate
(
forLocation
location
:
Location
?)
{
public
func
logUpdate
(
forLocation
location
:
Location
?,
kind
:
String
,
family
:
WidgetFamily
)
{
WidgetCenter
.
shared
.
getCurrentConfigurations
{[
weak
self
]
result
in
if
let
option
=
WidgetOptions
.
option
(
forKind
:
kind
,
family
:
family
)
{
switch
result
{
case
.
success
(
let
widgetInfo
):
for
info
in
widgetInfo
{
if
let
option
=
WidgetOptions
.
option
(
forKind
:
info
.
kind
,
family
:
info
.
family
)
{
let
name
=
WidgetOptions
.
name
(
for
:
option
)
let
name
=
WidgetOptions
.
name
(
for
:
option
)
var
params
:
[
AnalyticsParameter
:
String
]
=
[
.
ANALYTICS_KEY_WIDGET_NAME
:
name
]
var
params
:
[
AnalyticsParameter
:
String
]
=
[
.
ANALYTICS_KEY_WIDGET_NAME
:
name
]
...
@@ -146,7 +142,7 @@ public class WidgetManager {
...
@@ -146,7 +142,7 @@ public class WidgetManager {
// TODO: this needs to be unified. Any widget not using smart text shouldn't have that parameter.
// TODO: this needs to be unified. Any widget not using smart text shouldn't have that parameter.
if
option
!=
.
radarLarge
{
if
option
!=
.
radarLarge
{
if
let
updatedLocation
=
location
{
if
let
updatedLocation
=
location
{
let
smartText
=
self
?
.
smartTextProvider
.
smartText
(
for
:
updatedLocation
)
??
""
let
smartText
=
smartTextProvider
.
smartText
(
for
:
updatedLocation
)
params
[
.
ANALYTICS_KEY_WIDGET_SMART_TEXT
]
=
#
"
\
#(smartText)"
#
params
[
.
ANALYTICS_KEY_WIDGET_SMART_TEXT
]
=
#
"
\
#(smartText)"
#
}
}
}
}
...
@@ -155,11 +151,6 @@ public class WidgetManager {
...
@@ -155,11 +151,6 @@ public class WidgetManager {
params
:
params
)
params
:
params
)
}
}
}
}
case
.
failure
(
let
error
):
self
?
.
log
.
error
(
error
.
localizedDescription
)
}
}
}
private
func
sync
(
with
widgetInfo
:
[
WidgetInfo
])
{
private
func
sync
(
with
widgetInfo
:
[
WidgetInfo
])
{
var
currentOptions
:
WidgetOptions
=
[]
var
currentOptions
:
WidgetOptions
=
[]
...
...
OneWeatherWidget/Data/WeatherProvider.swift
View file @
6609f62d
...
@@ -21,10 +21,10 @@ class WeatherProvider: TimelineProvider {
...
@@ -21,10 +21,10 @@ class WeatherProvider: TimelineProvider {
private
let
needsRadar
:
Bool
private
let
needsRadar
:
Bool
private
var
weatherSource
:
WeatherSource
private
var
weatherSource
:
WeatherSource
private
let
locationSource
:
WidgetLocationSource
private
let
locationSource
:
WidgetLocationSource
private
let
widget
Type
:
String
private
let
widget
Kind
:
String
public
init
(
widget
Type
:
String
,
locationSource
:
WidgetLocationSource
=
WidgetLocationSource
.
shared
,
weatherSource
:
WeatherSource
=
WdtWeatherSource
(),
needsRadar
:
Bool
)
{
public
init
(
widget
Kind
:
String
,
locationSource
:
WidgetLocationSource
=
WidgetLocationSource
.
shared
,
weatherSource
:
WeatherSource
=
WdtWeatherSource
(),
needsRadar
:
Bool
)
{
self
.
widget
Type
=
widgetType
self
.
widget
Kind
=
widgetKind
self
.
locationSource
=
locationSource
self
.
locationSource
=
locationSource
self
.
weatherSource
=
weatherSource
self
.
weatherSource
=
weatherSource
self
.
needsRadar
=
needsRadar
self
.
needsRadar
=
needsRadar
...
@@ -42,6 +42,7 @@ class WeatherProvider: TimelineProvider {
...
@@ -42,6 +42,7 @@ class WeatherProvider: TimelineProvider {
func
getTimeline
(
in
context
:
Context
,
completion
:
@escaping
(
Timeline
<
WeatherEntry
>
)
->
Void
)
{
func
getTimeline
(
in
context
:
Context
,
completion
:
@escaping
(
Timeline
<
WeatherEntry
>
)
->
Void
)
{
locationSource
.
getUpToDateLocation
{
[
weak
self
]
location
in
locationSource
.
getUpToDateLocation
{
[
weak
self
]
location
in
guard
let
self
=
self
else
{
return
}
guard
let
self
=
self
else
{
return
}
var
needToLogUpdate
=
false
if
if
let
fetchedLocation
=
location
,
let
fetchedLocation
=
location
,
let
coordinates
=
fetchedLocation
.
coordinates
let
coordinates
=
fetchedLocation
.
coordinates
...
@@ -54,7 +55,7 @@ class WeatherProvider: TimelineProvider {
...
@@ -54,7 +55,7 @@ class WeatherProvider: TimelineProvider {
let
nextRefresh
=
Calendar
.
current
.
date
(
byAdding
:
.
minute
,
value
:
30
,
to
:
Date
())
!
let
nextRefresh
=
Calendar
.
current
.
date
(
byAdding
:
.
minute
,
value
:
30
,
to
:
Date
())
!
let
entry
=
WeatherEntry
(
location
:
fetchedLocation
,
date
:
nextRefresh
,
radarMapImage
:
mapImage
)
let
entry
=
WeatherEntry
(
location
:
fetchedLocation
,
date
:
nextRefresh
,
radarMapImage
:
mapImage
)
let
timeline
=
Timeline
(
entries
:
[
entry
],
policy
:
.
atEnd
)
let
timeline
=
Timeline
(
entries
:
[
entry
],
policy
:
.
atEnd
)
WidgetManager
.
shared
.
logUpdate
(
forLocation
:
fetchedLocation
)
needToLogUpdate
=
true
completion
(
timeline
)
completion
(
timeline
)
}
}
}
}
...
@@ -62,7 +63,7 @@ class WeatherProvider: TimelineProvider {
...
@@ -62,7 +63,7 @@ class WeatherProvider: TimelineProvider {
let
nextRefresh
=
Calendar
.
current
.
date
(
byAdding
:
.
minute
,
value
:
30
,
to
:
Date
())
!
let
nextRefresh
=
Calendar
.
current
.
date
(
byAdding
:
.
minute
,
value
:
30
,
to
:
Date
())
!
let
entry
=
WeatherEntry
(
location
:
fetchedLocation
,
date
:
nextRefresh
,
radarMapImage
:
nil
)
let
entry
=
WeatherEntry
(
location
:
fetchedLocation
,
date
:
nextRefresh
,
radarMapImage
:
nil
)
let
timeline
=
Timeline
(
entries
:
[
entry
],
policy
:
.
atEnd
)
let
timeline
=
Timeline
(
entries
:
[
entry
],
policy
:
.
atEnd
)
WidgetManager
.
shared
.
logUpdate
(
forLocation
:
fetchedLocation
)
needToLogUpdate
=
true
completion
(
timeline
)
completion
(
timeline
)
}
}
}
}
...
@@ -70,11 +71,16 @@ class WeatherProvider: TimelineProvider {
...
@@ -70,11 +71,16 @@ class WeatherProvider: TimelineProvider {
let
nextRefresh
=
Calendar
.
current
.
date
(
byAdding
:
.
minute
,
value
:
30
,
to
:
Date
())
!
let
nextRefresh
=
Calendar
.
current
.
date
(
byAdding
:
.
minute
,
value
:
30
,
to
:
Date
())
!
let
entry
=
WeatherEntry
(
location
:
location
,
date
:
nextRefresh
)
let
entry
=
WeatherEntry
(
location
:
location
,
date
:
nextRefresh
)
let
timeline
=
Timeline
(
entries
:
[
entry
],
policy
:
.
atEnd
)
let
timeline
=
Timeline
(
entries
:
[
entry
],
policy
:
.
atEnd
)
WidgetManager
.
shared
.
logUpdate
(
forLocation
:
location
)
needToLogUpdate
=
true
completion
(
timeline
)
completion
(
timeline
)
}
}
if
!
context
.
isPreview
{
WidgetManager
.
shared
.
refreshAnalytics
()
WidgetManager
.
shared
.
refreshAnalytics
()
if
needToLogUpdate
{
WidgetManager
.
shared
.
logUpdate
(
forLocation
:
location
,
kind
:
self
.
widgetKind
,
family
:
context
.
family
)
}
}
}
}
}
}
}
}
OneWeatherWidget/Widgets/PrecipitationWidget.swift
View file @
6609f62d
...
@@ -17,7 +17,7 @@ struct PrecipitationWidget: Widget {
...
@@ -17,7 +17,7 @@ struct PrecipitationWidget: Widget {
// We currently display selectedLocation, so it's not really configurable,
// We currently display selectedLocation, so it's not really configurable,
// but we'll probably need to switch to an IntentConfiguration at some point.
// but we'll probably need to switch to an IntentConfiguration at some point.
StaticConfiguration
(
kind
:
kind
,
StaticConfiguration
(
kind
:
kind
,
provider
:
WeatherProvider
(
widget
Type
:
kind
.
components
(
separatedBy
:
"."
)
.
last
??
"-"
,
needsRadar
:
false
)
provider
:
WeatherProvider
(
widget
Kind
:
kind
,
needsRadar
:
false
)
)
{
weatherEntry
in
)
{
weatherEntry
in
MediumPrecipitationWidgetView
(
widgetViewModel
:
ForecastWidgetViewModel
(
location
:
weatherEntry
.
location
))
MediumPrecipitationWidgetView
(
widgetViewModel
:
ForecastWidgetViewModel
(
location
:
weatherEntry
.
location
))
.
widgetURL
(
URL
(
string
:
"ow-widget://precipitation-medium"
))
.
widgetURL
(
URL
(
string
:
"ow-widget://precipitation-medium"
))
...
...
OneWeatherWidget/Widgets/RadarWidget.swift
View file @
6609f62d
...
@@ -17,7 +17,7 @@ struct RadarWidget: Widget {
...
@@ -17,7 +17,7 @@ struct RadarWidget: Widget {
// We currently display selectedLocation, so it's not really configurable,
// We currently display selectedLocation, so it's not really configurable,
// but we'll probably need to switch to an IntentConfiguration at some point.
// but we'll probably need to switch to an IntentConfiguration at some point.
StaticConfiguration
(
kind
:
kind
,
StaticConfiguration
(
kind
:
kind
,
provider
:
WeatherProvider
(
widget
Type
:
kind
.
components
(
separatedBy
:
"."
)
.
last
??
"-"
,
needsRadar
:
true
)
provider
:
WeatherProvider
(
widget
Kind
:
kind
,
needsRadar
:
true
)
)
{
weatherEntry
in
)
{
weatherEntry
in
LargeRadarWidgetView
(
widgetViewModel
:
ForecastWidgetViewModel
(
location
:
weatherEntry
.
location
,
LargeRadarWidgetView
(
widgetViewModel
:
ForecastWidgetViewModel
(
location
:
weatherEntry
.
location
,
radarImage
:
weatherEntry
.
radarMapImage
))
radarImage
:
weatherEntry
.
radarMapImage
))
...
...
OneWeatherWidget/Widgets/TemperatureWidget.swift
View file @
6609f62d
...
@@ -17,7 +17,7 @@ struct TemperatureWidget: Widget {
...
@@ -17,7 +17,7 @@ struct TemperatureWidget: Widget {
// We currently display selectedLocation, so it's not really configurable,
// We currently display selectedLocation, so it's not really configurable,
// but we'll probably need to switch to an IntentConfiguration at some point.
// but we'll probably need to switch to an IntentConfiguration at some point.
StaticConfiguration
(
kind
:
kind
,
StaticConfiguration
(
kind
:
kind
,
provider
:
WeatherProvider
(
widget
Type
:
kind
.
components
(
separatedBy
:
"."
)
.
last
??
"-"
,
needsRadar
:
false
)
provider
:
WeatherProvider
(
widget
Kind
:
kind
,
needsRadar
:
false
)
)
{
weatherEntry
in
)
{
weatherEntry
in
WidgetView
(
entry
:
weatherEntry
)
WidgetView
(
entry
:
weatherEntry
)
}
}
...
...
OneWeatherWidget/Widgets/WindWidget.swift
View file @
6609f62d
...
@@ -17,7 +17,7 @@ struct WindWidget: Widget {
...
@@ -17,7 +17,7 @@ struct WindWidget: Widget {
// We currently display selectedLocation, so it's not really configurable,
// We currently display selectedLocation, so it's not really configurable,
// but we'll probably need to switch to an IntentConfiguration at some point.
// but we'll probably need to switch to an IntentConfiguration at some point.
StaticConfiguration
(
kind
:
kind
,
StaticConfiguration
(
kind
:
kind
,
provider
:
WeatherProvider
(
widget
Type
:
kind
.
components
(
separatedBy
:
"."
)
.
last
??
"-"
,
needsRadar
:
false
)
provider
:
WeatherProvider
(
widget
Kind
:
kind
,
needsRadar
:
false
)
)
{
weatherEntry
in
)
{
weatherEntry
in
WidgetView
(
entry
:
weatherEntry
)
WidgetView
(
entry
:
weatherEntry
)
}
}
...
...
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