mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-24 18:36:21 +03:00
Open-at-unread: add option to not mark as read until fully read
Change-Id: Ie700cee773bce08248212ddd3fcc7793b4a919cc
This commit is contained in:
parent
22b5cb2d31
commit
7723b45993
6 changed files with 30 additions and 4 deletions
|
@ -51,6 +51,11 @@ interface ReadService {
|
||||||
*/
|
*/
|
||||||
suspend fun setMarkedUnread(markedUnread: Boolean)
|
suspend fun setMarkedUnread(markedUnread: Boolean)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the explicitly set unread marker flag
|
||||||
|
*/
|
||||||
|
suspend fun setMarkedUnreadFlag(markedUnread: Boolean)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if an event is already read, ie. your read receipt is set on a more recent event.
|
* Check if an event is already read, ie. your read receipt is set on a more recent event.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -80,7 +80,7 @@ internal class DefaultReadService @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun setMarkedUnreadFlag(markedUnread: Boolean) {
|
override suspend fun setMarkedUnreadFlag(markedUnread: Boolean) {
|
||||||
val params = SetMarkedUnreadTask.Params(roomId, markedUnread = markedUnread)
|
val params = SetMarkedUnreadTask.Params(roomId, markedUnread = markedUnread)
|
||||||
setMarkedUnreadTask.execute(params)
|
setMarkedUnreadTask.execute(params)
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,11 +195,15 @@ class TimelineViewModel @AssistedInject constructor(
|
||||||
setupPreviewUrlObservers()
|
setupPreviewUrlObservers()
|
||||||
room.getRoomSummaryLive()
|
room.getRoomSummaryLive()
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
if (!loadRoomAtFirstUnread()) {
|
if (loadRoomAtFirstUnread()) {
|
||||||
tryOrNull { room.markAsRead(ReadService.MarkAsReadParams.READ_RECEIPT) }
|
if (vectorPreferences.readReceiptFollowsReadMarker()) {
|
||||||
|
tryOrNull { room.setMarkedUnreadFlag(false) }
|
||||||
} else {
|
} else {
|
||||||
tryOrNull { room.setMarkedUnread(false) }
|
tryOrNull { room.setMarkedUnread(false) }
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
tryOrNull { room.markAsRead(ReadService.MarkAsReadParams.READ_RECEIPT) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Inform the SDK that the room is displayed
|
// Inform the SDK that the room is displayed
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
|
|
|
@ -217,6 +217,7 @@ class VectorPreferences @Inject constructor(private val context: Context, privat
|
||||||
private const val SETTINGS_ENABLE_SPACE_PAGER = "SETTINGS_ENABLE_SPACE_PAGER"
|
private const val SETTINGS_ENABLE_SPACE_PAGER = "SETTINGS_ENABLE_SPACE_PAGER"
|
||||||
private const val SETTINGS_NOTIF_ONLY_ALERT_ONCE = "SETTINGS_NOTIF_ONLY_ALERT_ONCE"
|
private const val SETTINGS_NOTIF_ONLY_ALERT_ONCE = "SETTINGS_NOTIF_ONLY_ALERT_ONCE"
|
||||||
private const val SETTINGS_HIDE_CALL_BUTTONS = "SETTINGS_HIDE_CALL_BUTTONS"
|
private const val SETTINGS_HIDE_CALL_BUTTONS = "SETTINGS_HIDE_CALL_BUTTONS"
|
||||||
|
private const val SETTINGS_READ_RECEIPT_FOLLOWS_READ_MARKER = "SETTINGS_READ_RECEIPT_FOLLOWS_READ_MARKER"
|
||||||
|
|
||||||
private const val DID_ASK_TO_ENABLE_SESSION_PUSH = "DID_ASK_TO_ENABLE_SESSION_PUSH"
|
private const val DID_ASK_TO_ENABLE_SESSION_PUSH = "DID_ASK_TO_ENABLE_SESSION_PUSH"
|
||||||
|
|
||||||
|
@ -1089,6 +1090,11 @@ class VectorPreferences @Inject constructor(private val context: Context, privat
|
||||||
return defaultPrefs.getBoolean(SETTINGS_HIDE_CALL_BUTTONS, false)
|
return defaultPrefs.getBoolean(SETTINGS_HIDE_CALL_BUTTONS, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SC addition
|
||||||
|
fun readReceiptFollowsReadMarker(): Boolean {
|
||||||
|
return defaultPrefs.getBoolean(SETTINGS_READ_RECEIPT_FOLLOWS_READ_MARKER, false)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I likely do more fresh installs of the app than anyone else, so a shortcut to change some of the default settings to
|
* I likely do more fresh installs of the app than anyone else, so a shortcut to change some of the default settings to
|
||||||
* my preferred values can safe me some time
|
* my preferred values can safe me some time
|
||||||
|
@ -1112,6 +1118,7 @@ class VectorPreferences @Inject constructor(private val context: Context, privat
|
||||||
.putBoolean(SETTINGS_UNIFIED_PUSH_FORCE_CUSTOM_GATEWAY, true)
|
.putBoolean(SETTINGS_UNIFIED_PUSH_FORCE_CUSTOM_GATEWAY, true)
|
||||||
.putBoolean(SETTINGS_AGGREGATE_UNREAD_COUNTS, false)
|
.putBoolean(SETTINGS_AGGREGATE_UNREAD_COUNTS, false)
|
||||||
.putBoolean(SETTINGS_ENABLE_SPACE_PAGER, true)
|
.putBoolean(SETTINGS_ENABLE_SPACE_PAGER, true)
|
||||||
|
.putBoolean(SETTINGS_READ_RECEIPT_FOLLOWS_READ_MARKER, true)
|
||||||
.apply()
|
.apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -183,4 +183,7 @@
|
||||||
<string name="settings_upstream_labs">Element features</string>
|
<string name="settings_upstream_labs">Element features</string>
|
||||||
<string name="settings_labs_room_list">Room list</string>
|
<string name="settings_labs_room_list">Room list</string>
|
||||||
<string name="settings_labs_timeline">Timeline</string>
|
<string name="settings_labs_timeline">Timeline</string>
|
||||||
|
|
||||||
|
<string name="settings_read_receipt_follows_read_marker">Only mark chats as read if fully read</string>
|
||||||
|
<string name="settings_read_receipt_follows_read_marker_summary">Do not update your read receipt when opening the room, but only gradually while reading</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -29,6 +29,13 @@
|
||||||
android:title="@string/settings_open_chats_at_first_unread"
|
android:title="@string/settings_open_chats_at_first_unread"
|
||||||
android:summary="@string/settings_open_chats_at_first_unread_summary" />
|
android:summary="@string/settings_open_chats_at_first_unread_summary" />
|
||||||
|
|
||||||
|
<im.vector.app.core.preference.VectorSwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="SETTINGS_READ_RECEIPT_FOLLOWS_READ_MARKER"
|
||||||
|
android:dependency="SETTINGS_OPEN_CHATS_AT_FIRST_UNREAD"
|
||||||
|
android:title="@string/settings_read_receipt_follows_read_marker"
|
||||||
|
android:summary="@string/settings_read_receipt_follows_read_marker_summary" />
|
||||||
|
|
||||||
<im.vector.app.core.preference.VectorSwitchPreference
|
<im.vector.app.core.preference.VectorSwitchPreference
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="SETTINGS_ALLOW_URL_PREVIEW_IN_ENCRYPTED_ROOM_KEY"
|
android:key="SETTINGS_ALLOW_URL_PREVIEW_IN_ENCRYPTED_ROOM_KEY"
|
||||||
|
|
Loading…
Reference in a new issue