Skip to content

more direct way of handling Future success/fail #412

@tomholub

Description

@tomholub

It's similarly weird to use map if we are talking about a single Future executing one time with a single failure or success. Map implies working with array of potentially many items, which seems a mismatch for what we're doing (even if this is otherwise common in iOS development).

I'll merge this but file a separate issue.

Originally posted by @tomholub in #410 (comment)

        return getPubKeys(for: recipients)
            .mapError { ComposeMessageError.validationError($0) }
            .map { allRecipientPubs in
                let replyToMimeMsg = input.replyToMime
                    .flatMap { String(data: $0, encoding: .utf8) }

                return SendableMsg(
                    text: text,
                    to: recipients.map(\.email),
                    cc: [],
                    bcc: [],
                    from: email,
                    subject: subject,
                    replyToMimeMsg: replyToMimeMsg,
                    atts: atts,
                    pubKeys: allRecipientPubs + [myPubKey]
                )
            }
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions