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
40a375a0
Commit
40a375a0
authored
Aug 02, 2021
by
Dmitriy Stepanets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Fixed viewed shorts sorting
- Fixed SHORTS_CARD_VIEW event firing
parent
5eb4afef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletions
+21
-1
1Weather/Network/ShortsManager.swift
+14
-1
1Weather/UI/View controllers/Today/Shorts/ShortsView.swift
+7
-0
No files found.
1Weather/Network/ShortsManager.swift
View file @
40a375a0
...
...
@@ -29,7 +29,18 @@ class ShortsManager {
private
var
isUpdating
=
false
private
init
()
{}
//MARK: Private
private
func
sync
(
with
newShorts
:
inout
[
ShortsItem
])
{
for
(
index
,
newShort
)
in
newShorts
.
enumerated
()
{
if
let
presentShortIndex
=
(
shorts
.
firstIndex
{
$0
.
id
==
newShort
.
id
})
{
let
presentShort
=
shorts
[
presentShortIndex
]
newShorts
[
index
]
.
isLiked
=
presentShort
.
isLiked
newShorts
[
index
]
.
isViewed
=
presentShort
.
isViewed
}
}
}
//MARK: Public
func
refreshShorts
()
{
if
isUpdating
{
return
...
...
@@ -46,13 +57,15 @@ class ShortsManager {
return
}
guard
let
items
=
shortItems
else
{
guard
var
items
=
shortItems
else
{
self
?
.
log
.
debug
(
"Fetched shorts are empty"
)
return
}
self
?
.
sync
(
with
:
&
items
)
self
?
.
shorts
.
removeAll
()
self
?
.
shorts
.
append
(
contentsOf
:
items
)
self
?
.
reordering
()
self
?
.
multicastDelegate
.
invoke
(
invocation
:
{
delegate
in
delegate
.
shortsDidChange
()
})
...
...
1Weather/UI/View controllers/Today/Shorts/ShortsView.swift
View file @
40a375a0
...
...
@@ -98,6 +98,13 @@ extension ShortsView: UICollectionViewDelegate {
}
}
func
scrollViewDidEndDragging
(
_
scrollView
:
UIScrollView
,
willDecelerate
decelerate
:
Bool
)
{
let
visiblePath
=
(
collectionView
.
indexPathsForVisibleItems
.
sorted
{
$0
.
row
<
$1
.
row
})
guard
let
lastVisibleRow
=
visiblePath
.
last
?
.
row
else
{
return
}
AppAnalytics
.
shared
.
log
(
event
:
.
ANALYTICS_SHORTS_CARD_VIEW
,
params
:
[
.
ANALYTICS_KEY_SHORTS_CARD_POSITION
:
lastVisibleRow
])
}
func
scrollViewDidEndDecelerating
(
_
scrollView
:
UIScrollView
)
{
let
visiblePath
=
(
collectionView
.
indexPathsForVisibleItems
.
sorted
{
$0
.
row
<
$1
.
row
})
guard
let
lastVisibleRow
=
visiblePath
.
last
?
.
row
else
{
return
}
...
...
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