mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2024-11-09 19:50:26 -06:00
[API] Fix for syncing new profiles after archiving.
This commit is contained in:
parent
e40871c0d0
commit
281b6a95ef
@ -409,9 +409,10 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
|
||||
}
|
||||
|
||||
app.db.profileDao().all.observe(this, Observer { profiles ->
|
||||
drawer.setProfileList(profiles.filter { it.id >= 0 && !it.archived }.toMutableList())
|
||||
val allArchived = profiles.all { it.archived }
|
||||
drawer.setProfileList(profiles.filter { it.id >= 0 && (!it.archived || allArchived) }.toMutableList())
|
||||
//prepend the archived profile if loaded
|
||||
if (app.profile.archived) {
|
||||
if (app.profile.archived && !allArchived) {
|
||||
drawer.prependProfile(Profile(
|
||||
id = app.profile.id,
|
||||
loginStoreId = app.profile.loginStoreId,
|
||||
|
@ -65,6 +65,11 @@ class ProfileArchiver(val app: App, val profile: Profile) {
|
||||
LOGIN_TYPE_VULCAN -> {
|
||||
// DataVulcan.isApiLoginValid() returns false so it will update the semester
|
||||
profile.removeStudentData("currentSemesterEndDate")
|
||||
profile.removeStudentData("studentSemesterId")
|
||||
profile.removeStudentData("studentSemesterNumber")
|
||||
profile.removeStudentData("semester1Id")
|
||||
profile.removeStudentData("semester2Id")
|
||||
profile.removeStudentData("studentClassId")
|
||||
}
|
||||
LOGIN_TYPE_IDZIENNIK -> {
|
||||
profile.removeStudentData("schoolYearId")
|
||||
|
@ -70,6 +70,14 @@ class IdziennikLoginWeb(val data: DataIdziennik, val onSuccess: () -> Unit) {
|
||||
data.webSelectedRegister = registerId
|
||||
}
|
||||
|
||||
// for profiles created after archiving
|
||||
data.schoolYearId = Regexes.IDZIENNIK_LOGIN_FIRST_SCHOOL_YEAR.find(text)?.let {
|
||||
it[1].toIntOrNull()
|
||||
} ?: data.schoolYearId
|
||||
data.profile?.studentClassName = Regexes.IDZIENNIK_LOGIN_FIRST_STUDENT.findAll(text)
|
||||
.firstOrNull { it[1].toIntOrNull() == data.registerId }
|
||||
?.let { "${it[5]} ${it[6]}" } ?: data.profile?.studentClassName
|
||||
|
||||
data.profile?.let { profile ->
|
||||
Regexes.IDZIENNIK_WEB_LUCKY_NUMBER.find(text)?.also {
|
||||
val number = it[1].toIntOrNull() ?: return@also
|
||||
|
Loading…
Reference in New Issue
Block a user