Skip to content

Commit 7fa9803

Browse files
committed
refactor(message-list): create message list effects
1 parent 24a27a6 commit 7fa9803

File tree

1 file changed

+76
-0
lines changed
  • feature/mail/message/list/api/src/main/kotlin/net/thunderbird/feature/mail/message/list/ui/effect

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package net.thunderbird.feature.mail.message.list.ui.effect
2+
3+
import net.thunderbird.feature.account.AccountId
4+
5+
/**
6+
* Represents one-time side effects that can be triggered from the message list screen.
7+
* These effects are intended to be consumed by the UI to perform actions like navigation
8+
* or showing transient messages.
9+
*/
10+
sealed interface MessageListEffect {
11+
/**
12+
* Effect to navigate back from the current screen.
13+
*/
14+
data object NavigateBack : MessageListEffect
15+
16+
/**
17+
* Effect to navigate to the "Move To" screen, allowing the user to select a destination
18+
* folder for the given messages.
19+
*
20+
* @param messagesIds The unique identifiers of the messages to be moved.
21+
* @param accountId The identifier of the account to which the messages belong.
22+
*/
23+
data class NavigateToMoveToScreen(val messagesIds: List<Long>, val accountId: AccountId) : MessageListEffect
24+
25+
/**
26+
* Represents the effect of messages being successfully archived.
27+
* This is typically used to show a notification or a snackbar to the user.
28+
*
29+
* @param messagesIdByAccountId A map where keys are account IDs and values are lists of message IDs
30+
* that have been archived for that account.
31+
*/
32+
data class ArchivedMessages(val messagesIdByAccountId: Map<AccountId, List<Long>>) : MessageListEffect
33+
34+
/**
35+
* Represents an effect for when pending (outbox) messages have been successfully sent.
36+
*
37+
* This effect is triggered after messages residing in the outbox are processed and sent,
38+
* typically resulting in them being moved to the Sent folder, if any configured.
39+
*
40+
* @param messagesIdByAccountId A map where each key is an [AccountId] and the value is a list of
41+
* message IDs that have been sent for that account.
42+
*/
43+
data class PendingMessagesSent(val messagesIdByAccountId: Map<AccountId, List<Long>>) : MessageListEffect
44+
45+
/**
46+
* Represents an effect for when messages have been permanently removed (expunged) from a folder.
47+
*
48+
* This typically happens after messages marked for deletion are purged from the server,
49+
* particularly with IMAP accounts. The UI should reflect this by removing these messages
50+
* or updating its state accordingly.
51+
*
52+
* @param messagesIdByAccountId A map where keys are account IDs and values are lists of message IDs
53+
* that have been expunged. This structure supports handling expunged messages from multiple accounts
54+
* in a single operation.
55+
*/
56+
data class ExpungedMessages(val messagesIdByAccountId: Map<AccountId, List<Long>>) : MessageListEffect
57+
58+
/**
59+
* Represents the side effect that messages have been marked for deletion.
60+
*
61+
* This effect is typically triggered after a user performs a delete action. The UI can use this
62+
* to show a confirmation, such as a snackbar, indicating the successful deletion.
63+
*
64+
* @param messagesIdByAccountId A map where each key is an [AccountId] and the corresponding value
65+
* is a list of message IDs that have been deleted for that account.
66+
*/
67+
data class DeletedMessages(val messagesIdByAccountId: Map<AccountId, List<Long>>) : MessageListEffect
68+
69+
/**
70+
* Represents the effect of one or more draft messages being discarded (deleted).
71+
*
72+
* @param messagesIdByAccountId A map where each key is an [AccountId] and the value is a list of message IDs
73+
* that have been discarded for that account.
74+
*/
75+
data class DraftsDiscarded(val messagesIdByAccountId: Map<AccountId, List<Long>>) : MessageListEffect
76+
}

0 commit comments

Comments
 (0)