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
54dc1958
Commit
54dc1958
authored
Aug 04, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IOS-163: fix the order of shorts after viewing them.
parent
d1ffc16e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
14 deletions
+19
-14
1Weather/Network/ShortsManager.swift
+16
-11
1Weather/ViewModels/ShortsViewModel.swift
+1
-1
OneWeatherCore/OneWeatherCore/ModelObjects/Shorts/ShortsItem.swift
+2
-2
No files found.
1Weather/Network/ShortsManager.swift
View file @
54dc1958
...
@@ -35,13 +35,13 @@ class ShortsManager {
...
@@ -35,13 +35,13 @@ class ShortsManager {
if
let
presentShortIndex
=
(
shorts
.
firstIndex
{
$0
.
id
==
newShort
.
id
})
{
if
let
presentShortIndex
=
(
shorts
.
firstIndex
{
$0
.
id
==
newShort
.
id
})
{
let
presentShort
=
shorts
[
presentShortIndex
]
let
presentShort
=
shorts
[
presentShortIndex
]
newShorts
[
index
]
.
isLiked
=
presentShort
.
isLiked
newShorts
[
index
]
.
isLiked
=
presentShort
.
isLiked
newShorts
[
index
]
.
isViewed
=
presentShort
.
isViewed
newShorts
[
index
]
.
viewDate
=
presentShort
.
viewDate
}
}
}
}
}
}
//MARK: Public
//MARK: Public
func
refreshShorts
()
{
public
func
refreshShorts
()
{
if
isUpdating
{
if
isUpdating
{
return
return
}
}
...
@@ -72,8 +72,17 @@ class ShortsManager {
...
@@ -72,8 +72,17 @@ class ShortsManager {
}
}
}
}
func
reordering
()
{
public
func
reordering
()
{
shorts
=
shorts
.
filter
{
!
$0
.
isViewed
}
+
shorts
.
filter
{
$0
.
isViewed
}
let
unviewedShorts
=
shorts
.
filter
{
$0
.
viewDate
==
nil
}
let
viewedShorts
=
shorts
.
filter
{
$0
.
viewDate
!=
nil
}
.
sorted
{
guard
let
viewDate0
=
$0
.
viewDate
,
let
viewDate1
=
$1
.
viewDate
else
{
return
false
}
return
viewDate0
<
viewDate1
}
shorts
=
unviewedShorts
+
viewedShorts
self
.
multicastDelegate
.
invoke
{
delegate
in
self
.
multicastDelegate
.
invoke
{
delegate
in
delegate
.
shortsDidChange
()
delegate
.
shortsDidChange
()
...
@@ -93,14 +102,10 @@ class ShortsManager {
...
@@ -93,14 +102,10 @@ class ShortsManager {
}
}
}
}
func
markAsViewed
(
item
:
ShortsItem
)
{
func
markAsViewed
(
index
:
Int
)
{
guard
guard
index
>=
0
,
index
<
shorts
.
count
else
{
!
item
.
isViewed
,
let
sourceIndex
=
(
self
.
shorts
.
firstIndex
{
$0
.
id
==
item
.
id
})
else
{
return
return
}
}
self
.
shorts
[
index
]
.
markAsViewed
()
self
.
shorts
[
sourceIndex
]
.
markAsViewed
()
}
}
}
}
1Weather/ViewModels/ShortsViewModel.swift
View file @
54dc1958
...
@@ -50,7 +50,7 @@ class ShortsViewModel: ViewModelProtocol {
...
@@ -50,7 +50,7 @@ class ShortsViewModel: ViewModelProtocol {
if
Settings
.
shared
.
shortsSwipeUpNudgeShowedCount
<=
ConfigManager
.
shared
.
config
.
shortsSwipeUpNudgeCount
{
if
Settings
.
shared
.
shortsSwipeUpNudgeShowedCount
<=
ConfigManager
.
shared
.
config
.
shortsSwipeUpNudgeCount
{
Settings
.
shared
.
shortsSwipeUpNudgeShowedCount
+=
1
Settings
.
shared
.
shortsSwipeUpNudgeShowedCount
+=
1
}
}
shortsManager
.
markAsViewed
(
i
tem
:
shorts
[
index
]
)
shortsManager
.
markAsViewed
(
i
ndex
:
index
)
}
}
}
}
...
...
OneWeatherCore/OneWeatherCore/ModelObjects/Shorts/ShortsItem.swift
View file @
54dc1958
...
@@ -37,7 +37,7 @@ public struct ShortsItem {
...
@@ -37,7 +37,7 @@ public struct ShortsItem {
public
let
likeCount
:
Int
public
let
likeCount
:
Int
public
let
shareCount
:
Int
public
let
shareCount
:
Int
public
var
isLiked
:
Bool
=
false
public
var
isLiked
:
Bool
=
false
public
var
isViewed
:
Bool
=
false
public
var
viewDate
:
Date
?
public
init
(
id
:
String
,
images
:
[
ShortsItemImage
],
overlayImages
:
[
ShortsItemImage
],
updatedAtInSecs
:
TimeInterval
,
startsAtInSecs
:
TimeInterval
,
endsAtInSecs
:
TimeInterval
,
shareURL
:
URL
?,
title
:
String
,
summaryText
:
String
,
sourceName
:
String
,
heartCount
:
Int
,
shortURL
:
URL
?,
ctaText
:
String
,
ctaURL
:
URL
?,
likeCount
:
Int
,
shareCount
:
Int
)
{
public
init
(
id
:
String
,
images
:
[
ShortsItemImage
],
overlayImages
:
[
ShortsItemImage
],
updatedAtInSecs
:
TimeInterval
,
startsAtInSecs
:
TimeInterval
,
endsAtInSecs
:
TimeInterval
,
shareURL
:
URL
?,
title
:
String
,
summaryText
:
String
,
sourceName
:
String
,
heartCount
:
Int
,
shortURL
:
URL
?,
ctaText
:
String
,
ctaURL
:
URL
?,
likeCount
:
Int
,
shareCount
:
Int
)
{
self
.
id
=
id
self
.
id
=
id
...
@@ -97,6 +97,6 @@ public struct ShortsItem {
...
@@ -97,6 +97,6 @@ public struct ShortsItem {
}
}
public
mutating
func
markAsViewed
()
{
public
mutating
func
markAsViewed
()
{
isViewed
=
true
viewDate
=
Date
()
}
}
}
}
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