From a9210594328c69682ea6bc589d6ac7b1727ac507 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 6 Jul 2017 17:40:27 +0100 Subject: [PATCH 1/2] Fix vector-im/riot-web#4526 by pretending to join I thought about adding separate dispatches to prevent confusion but if anyone adds anything that listens to existing dispatches, they really ought to be grep-ing the world for said dispatch actions. --- src/createRoom.js | 12 ++++++++++++ src/stores/RoomViewStore.js | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/src/createRoom.js b/src/createRoom.js index 830ac50ef5..916405776d 100644 --- a/src/createRoom.js +++ b/src/createRoom.js @@ -79,6 +79,12 @@ function createRoom(opts) { const modal = Modal.createDialog(Loader, null, 'mx_Dialog_spinner'); let roomId; + if (opts.andView) { + // We will possibly have a successful join, indicate as such + dis.dispatch({ + action: 'will_join', + }); + } return client.createRoom(createOpts).finally(function() { modal.close(); }).then(function(res) { @@ -98,10 +104,16 @@ function createRoom(opts) { action: 'view_room', room_id: roomId, should_peek: false, + // Creating a room will have joined us to the room + joined: true, }); } return roomId; }, function(err) { + // We also failed to join the room (this sets joining to false in RoomViewStore) + dis.dispatch({ + action: 'join_room_error', + }); console.error("Failed to create room " + roomId + " " + err); Modal.createDialog(ErrorDialog, { title: _t("Failure to create room"), diff --git a/src/stores/RoomViewStore.js b/src/stores/RoomViewStore.js index 2f7d55b71f..865caa8997 100644 --- a/src/stores/RoomViewStore.js +++ b/src/stores/RoomViewStore.js @@ -141,6 +141,10 @@ class RoomViewStore extends Store { shouldPeek: payload.should_peek === undefined ? true : payload.should_peek, }; + if (payload.joined) { + newState.joining = false; + } + // If an event ID wasn't specified, default to the one saved for this room // via update_scroll_state. Assume initialEventPixelOffset should be set. if (!newState.initialEventId) { From 0a4f8ffead5937680a28cc81e120bcf6f3c57403 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 6 Jul 2017 18:11:46 +0100 Subject: [PATCH 2/2] Alter EMOJI_REGEX to include end of string ($) Fixes https://github.com/vector-im/riot-web/issues/4529 because the match must include the remainder of the query. --- src/autocomplete/EmojiProvider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/autocomplete/EmojiProvider.js b/src/autocomplete/EmojiProvider.js index 5cb3c4af2f..35e9cc7b68 100644 --- a/src/autocomplete/EmojiProvider.js +++ b/src/autocomplete/EmojiProvider.js @@ -41,7 +41,7 @@ const CATEGORY_ORDER = [ ]; // Match for ":wink:" or ascii-style ";-)" provided by emojione -const EMOJI_REGEX = new RegExp('(' + asciiRegexp + '|:\\w*:?)', 'g'); +const EMOJI_REGEX = new RegExp('(' + asciiRegexp + '|:\\w*:?)$', 'g'); const EMOJI_SHORTNAMES = Object.keys(EmojiData).map((key) => EmojiData[key]).sort( (a, b) => { if (a.category === b.category) {