Skip to main content

Module compose

Module compose 

Source
Expand description

Composer message handlers for Avestruz.

A note, a reply or a quote is written in a view of its own. What is written belongs to what it is written to: leaving the composer keeps the text as that target’s draft, and coming back finds it. The draft of a new note is also written to a file whenever the composer or the popup is left, so it is there after a restart.

Cancel, beside the way to publish, leaves and keeps nothing, without asking: it is what rubbing out all that was written and then leaving comes to, so there is no draft after it, and the files on their way to be attached are called off.

Backspace leaves the composer as well, and may keep nothing too (see Leaving). With nothing written there is nothing to keep, and it leaves. With something written it asks first: keep it as a draft, discard it, or go on writing.

flowchart TD
    key["Backspace, with nothing in the text for it to rub out, or with the keyboard out of the text"] --> held{"Was it held down, rubbing the text out until a moment ago?"}
    held -->|"yes"| nothing["Nothing: rubbing out what was written is not leaving"]
    held -->|"no"| written{"Is anything written, or a file on its way to be attached?"}
    written -->|"no"| leave["The composer is left, and there is no draft"]
    written -->|"yes"| ask["It asks: keep it as a draft?"]
    ask -->|"Enter"| keep["Left, and what was written is kept as the draft"]
    ask -->|"Backspace"| discard["Left, and nothing is kept: the draft is gone, and the files are called off"]
    ask -->|"Escape"| stay["Not left: the keyboard is back in the text"]

A quote is written as a note is, with the note it quotes on show under the text. That note’s address is put under what was written when it goes out, and may be all that goes out: a quote needs nothing said.

What is written can be looked at as it would show once it is out, in place of the text: the control above the text chooses, and Ctrl+P is the other of the two. It is what publishing would send, read as a row reads a note and shown whole: Markdown, pictures, videos, the page it links to, the people it names and the notes it quotes, which are looked for as a list would look for them. The text is not written to meanwhile, so what shows is what would go out; a file that gets where it was going meanwhile shows too. Pressing somebody it names, or a note it quotes, leaves the composer as the way back does: what was written is kept.

flowchart LR
    text["The text"] -->|"Preview, Ctrl+P"| note["As a note that is not one yet"]
    note --> shown["Shown as a row would show it, whole"]
    note -->|"it quotes notes"| sought["Looked for: the store, then the relays"]
    sought -->|"it says the same still"| shown
    shown -->|"Write, Ctrl+P"| text
    shown -->|"Publish, Ctrl+Enter"| out["Signed and sent"]

A file is attached by sending it to the account’s media servers and putting its address in the text (see crate::handlers::media). What the note says of that file goes out with it, as long as the address is still in the text.

Publishing has the account’s signer sign (its key from the keyring, or its remote signer) and sends to the connected relays. Until a relay has taken it the text stays where it is; once one has, the note or the quote shows at the top of the feed, or the reply in its place in the thread.

Enums§

Leaving 🔒
What Backspace does to the composer, pressed to leave it.

Constants§

PREVIEW_TAB 🔒
RUBBING_OUT 🔒
How long after the text was last rubbed out a Backspace is still taken for the one that did it, held down: longer than the gap between the repeats of a held key, which come some thirty to a second, and shorter than the gap between two presses made on purpose.
WRITE_TAB 🔒
Where writing is in the control that chooses between it and the look at how what is written would show, and where the look is.

Functions§

held_from_rubbing_out 🔒
Whether a Backspace pressed at now is one held down that has been rubbing the text out, which was last changed at rubbed.
is_the_same_with_more 🔒
Whether found is shown, which is being written and looked at, with no fewer of the notes it quotes: what was looked for when it said something else is not what it says now.
outgoing 🔒
What is in composer as it would go out: the text, without the space around it, and under the text of a quote the address of the note it quotes.
publish 🔒
Have signer sign text as author’s note, or reply to what target names, which answered wrote, and send it to the relays, with said for what it says of the files it links to. The text of a quote names what it quotes already. Returns it as a row shows it.
publish_error_text 🔒
Why an event did not go out, in the user’s language.
publish_failure_text 🔒
Why what was written did not go out, in the user’s language.