Commit Graph

99 Commits (3c4c986aca536fb128e4aa523fe5b35c05b0620d)

Author SHA1 Message Date
Luke Barnard d3f9a3aeb5 Run eslint --fix
Fixing 1000s of lint issues. Some rules cannot be `--fix`ed but this goes some way to linting the entire codebase.
2017-10-11 17:56:17 +01:00
Stefan Parviainen a96169e80e Fix merge conflict 2017-10-02 17:57:22 +02:00
Luke Barnard 6b9a2909df Add rule to enforce spacing in curly brackets in JSX children
This required an updated in version of eslint-plugin-react to 7.4.0.
2017-09-28 11:21:06 +01:00
Stefan Parviainen d4929b558e Add dummy translation function to mark translatable strings
Signed-off-by: Stefan Parviainen <pafcu@iki.fi>
2017-09-22 21:43:27 +02:00
David Baker 11f6c8cf53 Fix null pointer
Check if users is null, not the room
2017-09-22 16:56:26 +01:00
David Baker 02894ee906 Experimental: Lazy load user autocomplete entries
Loading the users into the autocomplete provider is quite a large
chunk of work for a large room. Try lazy loading it the first time
a completion is done rather than up front when the room is loaded,
given that a lot of the time you switch to a room you won't say
anything.
2017-09-22 14:31:29 +01:00
Matthew Hodgson 6a53b7b149 Merge pull request #1389 from turt2live/travis/ignored_users
Add ignore user API support
2017-09-17 22:05:02 +01:00
turt2live b2de016b35 Add option to disable Emoji suggestions
Signed-off-by: Travis Ralston <travpc@gmail.com>
2017-09-14 21:28:12 -06:00
turt2live 0363f73e28 Fix the MessagePanel test
Signed-off-by: Travis Ralston <travpc@gmail.com>
2017-09-14 20:57:28 -06:00
turt2live 3c71898237 Add /(un)ignore to autocomplete
Signed-off-by: Travis Ralston <travpc@gmail.com>
2017-09-14 20:30:40 -06:00
Luke Barnard 5b1467a4c9 Allow autocompletion when typing user IDs
Because we need to support tab completing `"@some_user"` if `@some_user` has a display name that is totally different and will therefore not match what the user typed in.

This does have the disadvantage of a display name appearing (the pill) that isn't at all what the user typed in, but the autocomplete box and the tooltip should give enough information to let the user know what's going on. (e.g. typing `@kyr*tab*` and getting `Remmy`).

This _does_ run contrary to vector-im/riot-web#4495

related to vector-im/riot-web#4794

cc @lampholder
2017-08-15 14:08:26 +01:00
Luke Barnard 610b2a3a42 For mentions, always use rawDisplayName and remove (IRC) 2017-08-09 10:40:06 +01:00
Luke Barnard a72f38799f Disable autocompletions for users and rooms when entering a command
This only affects commands that take a room alias or user ID as an argument. (Leaving commands such as `/me` unaffected)
2017-08-08 15:58:15 +01:00
Luke Barnard 1743c047bd Use the rawDisplayName for the user provider completion
to make sure that the length of text in the decoration (See <Pill>) is equal to the length of text in the completion (underlying text range that the Entity covers).
2017-08-08 10:28:11 +01:00
Luke Barnard 72c1cf9288 When sorting completions, use matched string, not entire query
Otherwise the results vary depending on where you start autocompleting in your message. We only care about the matched string.
2017-08-02 10:09:00 +01:00
Luke Barnard dbade448c1 Don't try to match query against roomId
We only care about aliases.
2017-08-02 09:40:00 +01:00
Luke Barnard 8053d2933a Order room completions more intuitively
by index of the query in displayedAlias and then length of displayedAlias. (So that aliases where the query appears earlier in the string appear first and if the query is in the same index for two aliases, the shorter one appears first).
2017-08-02 09:35:07 +01:00
Luke Barnard ff95542549 Adjust emoji sorting such that exact matches/prefixes appear first
fixes https://github.com/vector-im/riot-web/issues/4704
2017-08-01 17:36:41 +01:00
Luke Barnard 6d7bff83ca Update type Completion 2017-07-20 16:49:23 +01:00
Luke Barnard 84fe51a162 Insert MD links when autocompleting in MD mode
These will appear decorated because they are inserted as entities. It was necessary to modify pills to have an explicit linkText that is derived from the `href` being pillified (and is thus no longer the inserted completion but rather the display name (or user ID) or room alias.
2017-07-20 15:09:59 +01:00
David Baker 199b771051 Merge pull request #1237 from matrix-org/luke/fix-rte-colon-parity
Implement old composer feature that inserts ': ' or ' '
2017-07-20 13:05:40 +01:00
Luke Barnard 0185119146 Merge pull request #1236 from matrix-org/luke/fix-rte-emoji-match-by-name
Match emojis by long name
2017-07-20 11:53:41 +01:00
Luke Barnard 352f70f9ce Implement old composer feature that inserts ': ' or ' '
after a user completion
2017-07-20 11:52:18 +01:00
Luke Barnard b3df546cb9 Fix comment 2017-07-20 10:51:15 +01:00
Luke Barnard a7feb58b63 Match emojis by long name
For example, searching for `:tong` will now match `:stuck_out_tongue` because the query `:tong` has all non-word characters removed, becoming `tong` and is then matched against the (long) names of emojis such as `smiling face with open mouth and tightly-closed eyes`.
2017-07-20 10:01:58 +01:00
Luke Barnard 3a53fabb87 Merge pull request #1228 from matrix-org/luke/feature-auto-complete-matrixto-pills
Implement composer completion user/room pill insertion
2017-07-19 17:19:47 +01:00
Richard van der Hoff 8d7ff127f1 Merge pull request #1231 from matrix-org/luke/fix-rte-duplicate-autocompletions
Use _uniq instead of _sortedUniq for return unique matched results
2017-07-19 17:05:12 +01:00
Luke Barnard c8722292e3 Don't truncate EmojiProvider completion pills 2017-07-19 16:20:57 +01:00
Luke Barnard b185f43d3d Use _uniq instead of _sortedUniq for return unique matched results
_sortedUniq claims to be like _uniq but optimised for sorted arrays - https://lodash.com/docs/4.17.4#sortedUniqBy. But in practice this isn't quite true, so stick with the unoptimised version.
2017-07-18 16:23:54 +01:00
Luke Barnard 897ff05d87 Implement composer completion user/room pill insertion
This modifies the composer completion such that completing a room or user will insert an IMMUTABLE matrix.to LINK Entity for the range that was replaced. Display names will not have a colon after their name anymore as it seemed strange that we would insert one after a pill.
2017-07-17 15:53:29 +01:00
Luke Barnard dcc4db53f9 Async functions now return `bluebird` promises, remove redundant Promise.resolve 2017-07-13 17:51:14 +01:00
Luke Barnard f78a49b3a9 Do `reflect` in the same `map` 2017-07-13 17:20:17 +01:00
Luke Barnard c9f3a12693 Fix Autocompleter promises
Use bluebird instead of the now removed "q" library.

Also, make sure we timeout and then `reflect` to effectively do an `allSettled` that waits for all promises to either be resolved or rejected. Then we filter for those that are fulfilled and return the completions.
2017-07-13 16:51:14 +01:00
Richard van der Hoff 0254d2b3a2 q(...) -> Promise.resolve
```
find src test -name '*.js' | xargs perl -i -pe 's/\b[qQ]\(/Promise.resolve(/'
```
2017-07-12 18:05:08 +01:00
Richard van der Hoff a06bd84213 replace imports of `q` with bluebird
update `package.json`

```
find src test -name '*.js' |
   xargs perl -i -pe 'if (/require\(.[qQ].\)/) { $_ = "import Promise from '\''bluebird'\'';\n"; }'

find src test -name '*.js' |
   xargs perl -i -pe 'if (/import [qQ]/) { $_ = "import Promise from '\''bluebird'\'';\n"; }'
```
2017-07-12 18:05:08 +01:00
David Baker e242e5e714 Merge pull request #1205 from matrix-org/luke/feature-new-emojis
Bump the dep on emojione to 2.2.7 to add 🦈 and others
2017-07-11 14:13:13 +01:00
Luke Barnard d146246805 Move "regional" category to after "flags"
Otherwise by default it appears first, pushing "people" further down the list

Also, remove "unicode9" category ordering, as this category does not exist as part of emojione
2017-07-11 14:06:15 +01:00
Luke Barnard e18924c8fc Fix bug where a received message would remove completions for users
`Array.prototype.splice` will return the array of removed items, not a new array. The array operated on is actually modified in-place.

This was causing a few weird things to happen: https://github.com/vector-im/riot-web/issues/4511 and https://github.com/vector-im/riot-web/issues/4533. This should fix both of them but it is concerning that doing the tab completion is required to reproduce. Let's just see how this goes before closing the issues.

Thanks @turt2live for reproducing both bugs, giving enough information for a fix :)
2017-07-11 10:42:02 +01:00
David Baker 0112afad3c Merge pull request #1199 from matrix-org/luke/fix-rte-emoji-prefixes
Only allow completion of emoji in certain circumstances
2017-07-10 14:02:01 +01:00
Luke Barnard 62ee0f4e02 Fix accepting invites
Accepting an invite would cause a room to arrive via /sync only for it to throw an error in the auto complete code and cause the client to go wibbly (infinite spinner or preview bar).

The logs that lead to the debugging of this are https://github.com/matrix-org/riot-web-rageshakes/issues/239

Hopefully the error being throw isn't totally unrelated but looking at the sync handling for inviteRooms in sync.js, new rooms are stored and _then_ the Room event is emitted. The Room event could trigger setUserListFromRoom, which is where the bug was. So the room should have been stored regardless of this bug and the client should have been recoverable by swapping away and viewing the room again.
2017-07-07 19:43:30 +01:00
Luke Barnard 9a272d4965 Only allow completion of emoji in certain circumstances
Which are:
 - the emoji to complete is at the start of the query
 - there is a whitespace character before the emoji
 - there is an emoji before the emoji (so that several emoji can be input in-a-row)

Fixes https://github.com/vector-im/riot-web/issues/4498 (although it seems to be fixed through some other fix)
2017-07-07 19:02:51 +01:00
Luke Barnard 0a4f8ffead 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.
2017-07-06 18:11:46 +01:00
Luke Barnard 710ee69418 Don't try to match with an empty query string
This was causing UserProvider to give results because every string happens to start with empty string and its regex also acepts the empty string.
2017-07-04 17:32:07 +01:00
Luke Barnard 0af77e8913 Merge pull request #1177 from matrix-org/luke/fix-rte-prefix-matching
Only match users by matchgin displayname or user ID prefixes
2017-07-04 17:09:39 +01:00
Luke Barnard 2861adc830 Only truncate autocomplete pulls of Emoji, Room and UserProvider
Leaving Commands and DuckDuckGo not truncated
2017-07-04 16:50:50 +01:00
Luke Barnard 6a80875c01 Only match users by matchgin displayname or user ID prefixes
Because tab completing "k" probably shouldn't give you "luke"

Fixes https://github.com/vector-im/riot-web/issues/4495
2017-07-04 16:29:06 +01:00
Luke Barnard e688eca823 Improve the sorting applied to the sorting of autocomplete results
QueryMatcher: sort results based on the position of the query within the matching value. The closer to the beginning of the word, the higher the result apears.

UserProvider: perf improvement (slice early) and refactor onUserSpoke
2017-07-04 13:53:06 +01:00
Michael Telatynski fc379e2a15
fix typos post-luke-review
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2017-07-03 19:24:18 +01:00
Michael Telatynski fb61a5d68b
post-merge fix
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2017-07-01 13:08:23 +01:00
Michael Telatynski 09f017fdd2
Merge branches 'develop' and 't3chguy/add-missing-autocomplete-commands' of github.com:matrix-org/matrix-react-sdk into t3chguy/add-missing-autocomplete-commands
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

# Conflicts:
#	src/autocomplete/CommandProvider.js
#	src/i18n/strings/en_EN.json
2017-07-01 13:07:18 +01:00