Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Commit

Permalink
Fix broken favorites sync
Browse files Browse the repository at this point in the history
Release v6.8.2
  • Loading branch information
NerdNumber9 committed Feb 15, 2018
1 parent 5447bd0 commit c54d26d
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ android {
minSdkVersion 16
targetSdkVersion 26
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
versionCode 6801
versionName "v6.8.1-EH"
versionCode 6802
versionName "v6.8.2-EH"

buildConfigField "String", "COMMIT_COUNT", "\"${getCommitCount()}\""
buildConfigField "String", "COMMIT_SHA", "\"${getGitSha()}\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ object PreferenceKeys {

const val eh_settingsKey = "eh_settingsKey"

const val eh_sessionCookie = "eh_sessionCookie"

const val eh_enableExHentai = "enable_exhentai"

const val eh_showSettingsUploadWarning = "eh_showSettingsUploadWarning"
const val eh_showSettingsUploadWarning = "eh_showSettingsUploadWarning1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ class PreferencesHelper(val context: Context) {
fun eh_ehSettingsProfile() = rxPrefs.getInteger(Keys.eh_ehSettingsProfile, -1)
fun eh_exhSettingsProfile() = rxPrefs.getInteger(Keys.eh_exhSettingsProfile, -1)
fun eh_settingsKey() = rxPrefs.getString(Keys.eh_settingsKey, "")
fun eh_sessionCookie() = rxPrefs.getString(Keys.eh_sessionCookie, "")

//Lock
fun lockHash() = rxPrefs.getString("lock_hash", null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class EHentai(override val id: Long,
//Get title
it.select(".itd .it5 a").first()?.apply {
title = text()
setUrlWithoutDomain(ExGalleryMetadata.normalizeUrl(attr("href")))
url = ExGalleryMetadata.normalizeUrl(attr("href"))
}
//Get image
it.select(".itd .it2").first()?.apply {
Expand Down Expand Up @@ -345,6 +345,10 @@ class EHentai(override val id: Long,
val sessionKey = prefs.eh_settingsKey().getOrDefault()
if(sessionKey != null)
cookies["sk"] = sessionKey

val sessionCookie = prefs.eh_sessionCookie().getOrDefault()
if(sessionCookie != null)
cookies["s"] = sessionCookie
}

//Session-less list display mode (for users without ExHentai)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ class LibraryController(
cleanupSyncState()
favoritesSyncSubscription =
presenter.favoritesSync.status
.sample(100, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
updateSyncStatus(it)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/exh/metadata/models/ExGalleryMetadata.kt
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ open class ExGalleryMetadata : RealmObject(), SearchableGalleryMetadata {
pathSegments.filterNot(String::isNullOrBlank)
}

fun galleryId(url: String) = splitGalleryUrl(url).let { it[it.size - 2] }
fun galleryId(url: String) = splitGalleryUrl(url)[1]

fun galleryToken(url: String) =
splitGalleryUrl(url).last()
splitGalleryUrl(url)[2]

fun normalizeUrl(id: String, token: String)
= "/g/$id/$token/?nw=always"
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/exh/uconfig/EHConfigurator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,14 @@ class EHConfigurator {
val keyCookie = response.headers().toMultimap()["Set-Cookie"]?.find {
it.startsWith("sk=")
}?.removePrefix("sk=")?.substringBefore(';')
val sessionCookie = response.headers().toMultimap()["Set-Cookie"]?.find {
it.startsWith("s=")
}?.removePrefix("s=")?.substringBefore(';')

if(keyCookie != null)
prefs.eh_settingsKey().set(keyCookie)
if(sessionCookie != null)
prefs.eh_sessionCookie().set(sessionCookie)
}

companion object {
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/raw/changelog_release.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog bulletedList="true">
<changelogversion versionName="v6.8.2-EH" changeDate="">
<changelogtext>Fix broken favorites sync in previous release</changelogtext>
</changelogversion>
<changelogversion versionName="v6.8.1-EH" changeDate="">
<changelogtext>Various performance improvements</changelogtext>
<changelogtext>Fix app not working at all for some users</changelogtext>
Expand Down

0 comments on commit c54d26d

Please sign in to comment.