Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
android-components
Commits
67dc5b26
Commit
67dc5b26
authored
Jun 26, 2019
by
Sebastian Kaspari
Browse files
Issue #3432: SessionManager: Add restored tabs at the beginning of the list.
parent
2192b68c
Changes
2
Hide whitespace changes
Inline
Side-by-side
components/browser/session/src/main/java/mozilla/components/browser/session/LegacySessionManager.kt
View file @
67dc5b26
...
...
@@ -140,7 +140,7 @@ class LegacySessionManager(
addInternal
(
session
,
selected
,
engineSession
,
parent
=
parent
,
viaRestore
=
false
)
}
@Suppress
(
"LongParameterList"
)
@Suppress
(
"LongParameterList"
,
"ComplexMethod"
)
private
fun
addInternal
(
session
:
Session
,
selected
:
Boolean
=
false
,
...
...
@@ -160,7 +160,16 @@ class LegacySessionManager(
values
.
add
(
parentIndex
+
1
,
session
)
}
else
{
values
.
add
(
session
)
if
(
viaRestore
)
{
// We always restore Sessions at the beginning of the list to pretend those sessions existed before
// we added any other sessions (e.g. coming from an Intent)
values
.
add
(
0
,
session
)
if
(
selectedIndex
!=
NO_SELECTION
)
{
selectedIndex
++
}
}
else
{
values
.
add
(
session
)
}
}
if
(
engineSession
!=
null
)
{
...
...
@@ -201,7 +210,7 @@ class LegacySessionManager(
return
}
snapshot
.
sessions
.
forEach
{
snapshot
.
sessions
.
asReversed
().
forEach
{
addInternal
(
it
.
session
,
engineSession
=
it
.
engineSession
,
...
...
components/browser/session/src/test/java/mozilla/components/browser/session/SessionManagerTest.kt
View file @
67dc5b26
...
...
@@ -367,9 +367,9 @@ class SessionManagerTest {
assertEquals
(
3
,
manager
.
size
)
assertEquals
(
"https://www.mozilla.org"
,
manager
.
selectedSessionOrThrow
.
url
)
assertEquals
(
"https://
www.mozilla.org
"
,
manager
.
sessions
[
0
].
url
)
assertEquals
(
"https://www.
firefox.com
"
,
manager
.
sessions
[
1
].
url
)
assertEquals
(
"https://
getpocket
.com"
,
manager
.
sessions
[
2
].
url
)
assertEquals
(
"https://
getpocket.com
"
,
manager
.
sessions
[
0
].
url
)
assertEquals
(
"https://www.
mozilla.org
"
,
manager
.
sessions
[
1
].
url
)
assertEquals
(
"https://
www.firefox
.com"
,
manager
.
sessions
[
2
].
url
)
verify
(
observer
).
onSessionsRestored
()
}
...
...
Write
Preview
Supports
Markdown
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