Commit graph

212 commits

Author SHA1 Message Date
Luke Barnard
dad797d4a2 Run linting --fix 2017-11-16 13:19:36 +00:00
Travis Ralston
289b0c2b6a
Merge branch 'develop' into travis/granular-settings 2017-11-07 14:55:12 -07:00
David Baker
41e7496ff1 unused var 2017-11-06 15:25:25 +00:00
Travis Ralston
893c39bfbe Merge branch 'develop' into travis/granular-settings 2017-11-03 22:00:07 -06:00
David Baker
112c74a255 Add NotifProvider to offer @room as a completion 2017-11-02 18:54:25 +00:00
David Baker
6ad4bb80dd == 2017-11-02 18:14:46 +00:00
David Baker
3b58f0ca2a Ignore removed events 2017-11-02 18:14:21 +00:00
David Baker
ee43c635d1 phrasing 2017-11-02 18:11:18 +00:00
David Baker
42589281d1 comment stub method 2017-11-02 18:10:13 +00:00
David Baker
f7201e8dee Revert unintentional changes 2017-11-02 18:08:24 +00:00
David Baker
498b117d5a copyrights 2017-11-02 18:01:28 +00:00
David Baker
4953d4de4d Give autocomplete providers the room they're in
Removes the gut-wrenching that RoomView does to jam the user list
into the user autocomplete provider.
2017-11-02 17:51:08 +00:00
Travis Ralston
ae10a11ac4 Convert synced settings to granular settings
Signed-off-by: Travis Ralston <travpc@gmail.com>
2017-10-29 01:43:52 -06:00
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
Michael Telatynski
9dba628f10
add missing commands to the Autocomplete CommandProvider
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2017-07-01 12:55:43 +01:00
Luke Barnard
b315ed630e Match by emoji ascii regex first before shorthand
Plaintext emojis that start with ":" will also match against the shorthand regex but the match won't include the important part of the plaintext emoji. This means some emoji like ":)" won't be matched.

To fix this, put the ascii emoji regex first so that the match will be plaintext or otherwise it will fall through to the shorthand match (if there is one).

Fixes https://github.com/vector-im/riot-web/issues/4467
2017-06-30 16:31:40 +01:00
Luke Barnard
982b009b90 Implement ascii emoji tab completion
When a fully plaintext, ascii emoji is typed like ";-)", pressing tab will suggest emojione to replace it with based off of the meta data provided by emojione.

e.g. the aliases_ascii for `😃` are [":D",":-D","=D"] so typing ":D *tab*" will insert a real 😃
2017-06-29 11:29:55 +01:00
Luke Barnard
2b8da85726 Strip the emoji meta-data for the data we need
This is done at build time by parsing emojione/emoji.json, stripping it and then writing to ./lib/stripped-emoji.json.
2017-06-28 11:36:19 +01:00
Luke Barnard
8ca3b382ed Use emojione/emoji.json because we don't want two sets of emoji meta 2017-06-28 11:19:16 +01:00
Luke Barnard
f4db765239 Fix indentation 2017-06-28 10:32:46 +01:00
Luke Barnard
9d339b96bd Order emojis by standard ordering, add alternate shortnames
Also, increase the maximum number of emoji shown to 20.
2017-06-27 20:13:48 +01:00
David Baker
3cdc7c9114 Add copyright headers 2017-06-23 18:30:16 +01:00
David Baker
c0e48c72fc Remove dep on liblevenstein
While we don't actually use it
2017-06-23 18:03:32 +01:00
Luke Barnard
89afcfd897 Linting 2017-06-23 17:35:07 +01:00
Luke Barnard
87609582c6 Merge branch 'develop' into rte-fixes2
Conflicts:
	package.json
	src/autocomplete/CommandProvider.js
	src/autocomplete/UserProvider.js
	src/components/structures/RoomView.js
	src/components/structures/UserSettings.js
	src/components/views/rooms/MessageComposerInput.js
2017-06-23 15:30:06 +01:00
Michael Telatynski
464863acd6 remove unused imports
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2017-06-02 21:35:55 +01:00
Kegan Dougal
66bce35918 copyright adjustments 2017-06-01 17:29:40 +01:00
Kegan Dougal
f75e714c3a More translations.. 2017-06-01 15:18:06 +01:00
Michael Telatynski
dc2d32670b clean up file
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2017-05-29 23:52:55 +01:00
Michael Telatynski
bfc7302fba fix i18n typo
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
2017-05-29 23:51:05 +01:00
David Baker
5c359e63ab Bulk change counterpart imports
to use languageHandler wrapper func
2017-05-25 11:39:08 +01:00
David Baker
d419c42a4f Squash merge https://github.com/matrix-org/matrix-react-sdk/pull/801 2017-05-23 15:16:31 +01:00
Luke Barnard
bc045698b9 Fix for fuse 2.7.2
As of v2.7.2, fuse.js introduces a regression where the second argument to the constructor `Fuse` is assumed to be an object. There was one instance where we were not passing any argument. This fixes that.
2017-04-25 18:01:56 +01:00
Aviral Dasgupta
b977b559de
autocomplete: add missing commands to CommandProvider 2017-03-07 04:46:55 +05:30
Aviral Dasgupta
9946cadc2d
autocomplete: fix RoomProvider regression 2017-03-07 04:09:27 +05:30
Aviral Dasgupta
32dd89774e
add support for autocomplete delay 2017-03-07 04:09:26 +05:30
Aviral Dasgupta
e65744abdc
fix EmojiProvider for new QueryMatcher 2017-03-07 04:09:26 +05:30
Aviral Dasgupta
0653343319
order User completions by last spoken 2017-03-07 04:09:26 +05:30
Aviral Dasgupta
c7d0652762
actually sort autocomplete results by distance 2017-03-07 04:09:26 +05:30
Aviral Dasgupta
78641a80dd
autocomplete: replace Fuse.js with liblevenshtein 2017-03-07 04:09:25 +05:30
Aviral Dasgupta
edd5903ed7
autocomplete: add space after completing room name 2017-03-07 04:09:25 +05:30
Aviral Dasgupta
f2ad4bee8b
Disable force completion for RoomProvider (RTE) 2017-03-07 04:09:24 +05:30
David Baker
18d4d3392a Fix a bunch of linting errors
eslint --fix and a few manual ones
2017-01-20 14:22:27 +00:00
Aviral Dasgupta
2913e4605f Fix unicode completions in autocomplete.
Fixes vector-im/vector-web#2208
2016-09-16 15:38:29 +05:30
Aviral Dasgupta
79e5e6f6fe Fix force completion and hide rooms with no alias 2016-09-13 18:02:33 +05:30
Aviral Dasgupta
9a991a4dfd Autocomplete fixes and improvements 2016-09-13 17:30:29 +05:30
Aviral Dasgupta
fbf2d5f96c Fix tests (wip) 2016-09-13 16:46:20 +05:30
Aviral Dasgupta
b62622a814 Improve autocomplete behaviour
Fixes vector-im/vector-web#1761
2016-09-13 15:46:02 +05:30
David Baker
df1cc8748f Change references to MatrixTools to Rooms
or remove where they were unused
2016-09-07 11:33:58 +01:00
Aviral Dasgupta
884abbd7e9 Cleanup autocomplete 2016-08-23 00:36:31 +05:30
Aviral Dasgupta
e173900808 Update autocomplete design and scroll it correctly 2016-08-17 17:27:19 +05:30
Aviral Dasgupta
1b414cad18 Add max-width to emoji completions. 2016-08-10 00:52:55 +05:30
Aviral Dasgupta
2cddf18461 strip (IRC) displayname suffix from autocomplete
Fixes vector-im/vector-web#574
2016-08-03 17:26:05 +05:30
Aviral Dasgupta
ed305bd547 fix: https for DDG, provide range for UserProvider 2016-07-05 01:37:01 +05:30
Aviral Dasgupta
b3d8292113 feat: use canonical room alias for room completion 2016-07-04 22:34:58 +05:30
Aviral Dasgupta
30b7efd585 fix: code cleanup, fix getCurrentCommand 2016-07-04 21:44:35 +05:30
Aviral Dasgupta
cccc58b47f feat: implement autocomplete replacement 2016-07-03 22:15:13 +05:30
Aviral Dasgupta
fb6eec0f7d Hide/show autocomplete based on selection state 2016-06-21 15:46:20 +05:30
Aviral Dasgupta
f6a76edfdf Fuzzy matching in User and Room providers 2016-06-21 05:05:23 +05:30
Aviral Dasgupta
4af983ed90 Style changes and improvements in autocomplete 2016-06-20 13:52:55 +05:30
Aviral Dasgupta
b9d7743e5a Emoji provider, DDG working, style improvements 2016-06-17 04:58:09 +05:30
Aviral Dasgupta
4bc8ec3e6d room, user, ddg autocomplete providers (wip) 2016-06-12 17:02:46 +05:30
Aviral Dasgupta
b979a16199 initial version of autocomplete 2016-06-01 16:54:21 +05:30