chat: split and send mixed messages sequentially
Hot and cold in that order. This amends the behaviour of messages
with text and URLs to submit them in order of found URL,
instead of batching the URLs at the end.
@@ -150,33 +150,43 @@ export class ChatInput extends Component {
return;
}
- let URLs = [];
- let letter = state.message.split(" ").map((each) => {
+ let message = [];
+ state.message.split(" ").map((each) => {
if (this.isUrl(each)) {
- let URL = this.getLetterType(each);
- URLs.push(URL);
- }
- else {
- return each;
+ if (message.length > 0) {
+ message = message.join(" ");
+ message = this.getLetterType(message);
+ props.api.chat.message(
+ props.station,
+ `~${window.ship}`,
+ Date.now(),
+ message
+ );
+ message = [];
}
- }).join(" ");
-
- letter = this.getLetterType(letter);
-
+ let URL = this.getLetterType(each);
props.api.chat.message(
props.station,
`~${window.ship}`,
Date.now(),
- letter
+ URL
);
+ }
+ else {
+ return message.push(each);
+ }
+ })
- for (let each of URLs) {
+ if (message.length > 0) {
+ message = message.join(" ");
+ message = this.getLetterType(message);
props.api.chat.message(
props.station,
`~${window.ship}`,
Date.now(),
- each
+ message
);
+ message = [];
}
// perf: setTimeout(this.closure, 2000);
