fix restore selected proxy after update profile

This commit is contained in:
Kr328 committed 2019-12-08 23:55:40 +08:00
1 parent a1d623c42b
commit 8ec689a893
4 files changed
+9 -2

No files matched your search

@@ -180,8 +180,7 @@ class ProfilesActivity : BaseActivity() {
}
runClash { clash ->
clash.profileService.addProfile(profile
.copy(lastUpdate = System.currentTimeMillis()))
clash.profileService.touchProfile(profile.id)
}
}
catch (e: Exception) {
@@ -7,5 +7,6 @@ interface IClashProfileService {
void setActiveProfile(int id);
void addProfile(in ClashProfileEntity profile);
void removeProfile(int id);
void touchProfile(int id);
ClashProfileEntity queryActiveProfile();
}
@@ -42,6 +42,10 @@ class ClashProfileService(context: Context, private val master: Master) :
master.preformProfileChanged()
}
override fun touchProfile(id: Int) {
profileDao.touchProfile(id)
}
override fun queryProfiles(): Array<ClashProfileEntity> {
return profileDao.queryProfiles()
}
@@ -21,4 +21,7 @@ interface ClashProfileDao {
@Query("DELETE FROM profiles WHERE id = :id")
fun removeProfile(id: Int)
@Query("UPDATE profiles SET last_update = :lastUpdate WHERE id = :id")
fun touchProfile(id: Int, lastUpdate: Long = System.currentTimeMillis())
}