Commit 63cb2bb6 authored by Mikolai Gütschow's avatar Mikolai Gütschow Committed by Sebastian
Browse files

check for actual feature support in ConversationVisitor

parent cb2e796b
Pipeline #9351 passed with stage
in 3 minutes and 20 seconds
......@@ -56,6 +56,7 @@ import org.briarproject.briar.api.messaging.MessagingManager
import org.briarproject.briar.api.messaging.PrivateMessage
import org.briarproject.briar.api.messaging.PrivateMessageFactory
import org.briarproject.briar.api.messaging.PrivateMessageHeader
import org.briarproject.briar.desktop.DesktopFeatureFlags
import org.briarproject.briar.desktop.attachment.media.ImageCompressor
import org.briarproject.briar.desktop.contact.ContactItem
import org.briarproject.briar.desktop.conversation.ConversationRequestItem.RequestType.INTRODUCTION
......@@ -88,6 +89,7 @@ constructor(
db: TransactionManager,
private val attachmentReader: AttachmentReader,
private val imageCompressor: ImageCompressor,
private val desktopFeatureFlags: DesktopFeatureFlags,
private val eventBus: EventBus,
) : EventListenerDbViewModel(briarExecutors, lifecycleManager, db, eventBus) {
......@@ -185,7 +187,13 @@ constructor(
m.autoDeleteTimer
)
val visitor =
ConversationVisitor(contactItem.value!!.name, messagingManager, attachmentReader, txn)
ConversationVisitor(
contactItem.value!!.name,
messagingManager,
attachmentReader,
desktopFeatureFlags,
txn
)
val msg = h.accept(visitor)!!
txn.attach { addMessage(msg) }
} catch (e: UnexpectedTimerException) {
......@@ -290,7 +298,8 @@ constructor(
// Sort headers by timestamp in *ascending* order
val sorted = headers.sortedBy { it.timestamp }
start = LogUtils.now()
val visitor = ConversationVisitor(contact.name, messagingManager, attachmentReader, txn)
val visitor =
ConversationVisitor(contact.name, messagingManager, attachmentReader, desktopFeatureFlags, txn)
val messages = sorted.map { h -> h.accept(visitor)!! }
LOG.logDuration("Loading messages", start)
txn.attach {
......@@ -314,7 +323,13 @@ constructor(
// insert at start of list according to descending sort order
runOnDbThreadWithTransaction(true) { txn ->
val visitor =
ConversationVisitor(contactItem.value!!.name, messagingManager, attachmentReader, txn)
ConversationVisitor(
contactItem.value!!.name,
messagingManager,
attachmentReader,
desktopFeatureFlags,
txn
)
val msg = h.accept(visitor)!!
txn.attach { addMessage(msg) }
}
......
......@@ -35,6 +35,7 @@ import org.briarproject.briar.api.messaging.MessagingManager
import org.briarproject.briar.api.messaging.PrivateMessageHeader
import org.briarproject.briar.api.privategroup.invitation.GroupInvitationRequest
import org.briarproject.briar.api.privategroup.invitation.GroupInvitationResponse
import org.briarproject.briar.desktop.DesktopFeatureFlags
import org.briarproject.briar.desktop.utils.ImageUtils
import org.briarproject.briar.desktop.utils.InternationalizationUtils.i18n
import org.briarproject.briar.desktop.utils.InternationalizationUtils.i18nF
......@@ -44,6 +45,7 @@ internal class ConversationVisitor(
private val contactName: String,
private val messagingManager: MessagingManager,
private val attachmentReader: AttachmentReader,
private val desktopFeatureFlags: DesktopFeatureFlags,
private val txn: Transaction,
) : ConversationMessageVisitor<ConversationItem?> {
......@@ -87,8 +89,7 @@ internal class ConversationVisitor(
)
else {
val notice = i18nF("blog.invitation.received", contactName, r.name)
// todo: add proper check for feature support
if (false)
if (desktopFeatureFlags.shouldEnableBlogs())
ConversationRequestItem(
notice,
ConversationRequestItem.RequestType.BLOG, r
......@@ -131,8 +132,7 @@ internal class ConversationVisitor(
)
else {
val notice = i18nF("forum.invitation.received", contactName, r.name)
// todo: add proper check for feature support
if (false)
if (desktopFeatureFlags.shouldEnableForums())
ConversationRequestItem(
notice,
ConversationRequestItem.RequestType.FORUM, r
......@@ -175,8 +175,7 @@ internal class ConversationVisitor(
)
else {
val notice = i18nF("group.invitation.received", contactName, r.name)
// todo: add proper check for feature support
if (false)
if (desktopFeatureFlags.shouldEnablePrivateGroups())
ConversationRequestItem(
notice,
ConversationRequestItem.RequestType.GROUP, r
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment