implementation of polling limit on open groups

This commit is contained in:
Brice-W
2021-05-24 12:00:17 +10:00
parent 910787a960
commit dbaa51bd9a
4 changed files with 40 additions and 0 deletions

View File

@@ -22,6 +22,7 @@ class OpenGroupPollerV2(private val server: String, private val executorService:
companion object {
private val pollInterval: Long = 4 * 1000
const val maxInactivityPeriod = 14 * 24 * 60 * 60 * 1000
}
fun startIfNeeded() {

View File

@@ -99,6 +99,11 @@ object TextSecurePreferences {
private const val GIF_GRID_LAYOUT = "pref_gif_grid_layout"
// region Limit open group polling
private const val LAST_TIME_SESSION_OPENED = "pref_last_time_session_open"
private const val OPEN_GROUP_POLLING_LIMIT = "pref_Open_group_polling_limit"
// region FCM
const val IS_USING_FCM = "pref_is_using_fcm"
private const val FCM_TOKEN = "pref_fcm_token"
@@ -771,5 +776,22 @@ object TextSecurePreferences {
fun setHasSeenFileServerInstabilityNotification(context: Context) {
setBooleanPreference(context, "has_seen_file_server_instability_notification", true)
}
fun getLastTimeSessionOpened(context: Context): Long {
return getLongPreference(context!!, LAST_TIME_SESSION_OPENED, 0)
}
fun setLastTimeSessionOpened(context: Context) {
setLongPreference(context, LAST_TIME_SESSION_OPENED, System.currentTimeMillis())
}
fun isOpenGroupPollingLimit(context: Context): Boolean {
return getBooleanPreference(context, OPEN_GROUP_POLLING_LIMIT, false)
}
fun setOpenGroupPollingLimit(context: Context, limit: Boolean) {
setBooleanPreference(context, OPEN_GROUP_POLLING_LIMIT, limit)
}
// endregion
}