Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
pleroma-fe
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Joseph Nuthalapati
pleroma-fe
Commits
5909baba
Commit
5909baba
authored
Jul 18, 2019
by
Wyatt Benno
Committed by
Shpuld Shpludson
Jul 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add user search at
parent
cc2e35f4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
5 deletions
+22
-5
src/components/emoji-input/suggestor.js
src/components/emoji-input/suggestor.js
+18
-3
src/components/post_status_form/post_status_form.js
src/components/post_status_form/post_status_form.js
+2
-1
src/components/user_settings/user_settings.js
src/components/user_settings/user_settings.js
+2
-1
No files found.
src/components/emoji-input/suggestor.js
View file @
5909baba
import
{
debounce
}
from
'
lodash
'
/**
* suggest - generates a suggestor function to be used by emoji-input
* data: object providing source information for specific types of suggestions:
* data.emoji - optional, an array of all emoji available i.e.
* (state.instance.emoji + state.instance.customEmoji)
* data.users - optional, an array of all known users
* updateUsersList - optional, a function to search and append to users
*
* Depending on data present one or both (or none) can be present, so if field
* doesn't support user linking you can just provide only emoji.
*/
const
debounceUserSearch
=
debounce
((
data
,
input
)
=>
{
data
.
updateUsersList
(
input
)
},
500
,
{
leading
:
true
,
trailing
:
false
})
export
default
data
=>
input
=>
{
const
firstChar
=
input
[
0
]
if
(
firstChar
===
'
:
'
&&
data
.
emoji
)
{
return
suggestEmoji
(
data
.
emoji
)(
input
)
}
if
(
firstChar
===
'
@
'
&&
data
.
users
)
{
return
suggestUsers
(
data
.
users
)(
input
)
return
suggestUsers
(
data
)(
input
)
}
return
[]
}
...
...
@@ -38,9 +45,11 @@ export const suggestEmoji = emojis => input => {
})
}
export
const
suggestUsers
=
users
=>
input
=>
{
export
const
suggestUsers
=
data
=>
input
=>
{
const
noPrefix
=
input
.
toLowerCase
().
substr
(
1
)
return
users
.
filter
(
const
users
=
data
.
users
const
newUsers
=
users
.
filter
(
user
=>
user
.
screen_name
.
toLowerCase
().
startsWith
(
noPrefix
)
||
user
.
name
.
toLowerCase
().
startsWith
(
noPrefix
)
...
...
@@ -75,5 +84,11 @@ export const suggestUsers = users => input => {
imageUrl
:
profile_image_url_original
,
replacement
:
'
@
'
+
screen_name
+
'
'
}))
// BE search users if there are no matches
if
(
newUsers
.
length
===
0
&&
data
.
updateUsersList
)
{
debounceUserSearch
(
data
,
noPrefix
)
}
return
newUsers
/* eslint-enable camelcase */
}
src/components/post_status_form/post_status_form.js
View file @
5909baba
...
...
@@ -104,7 +104,8 @@ const PostStatusForm = {
...
this
.
$store
.
state
.
instance
.
emoji
,
...
this
.
$store
.
state
.
instance
.
customEmoji
],
users
:
this
.
$store
.
state
.
users
.
users
users
:
this
.
$store
.
state
.
users
.
users
,
updateUsersList
:
(
input
)
=>
this
.
$store
.
dispatch
(
'
searchUsers
'
,
input
)
})
},
emojiSuggestor
()
{
...
...
src/components/user_settings/user_settings.js
View file @
5909baba
...
...
@@ -91,7 +91,8 @@ const UserSettings = {
...
this
.
$store
.
state
.
instance
.
emoji
,
...
this
.
$store
.
state
.
instance
.
customEmoji
],
users
:
this
.
$store
.
state
.
users
.
users
users
:
this
.
$store
.
state
.
users
.
users
,
updateUsersList
:
(
input
)
=>
this
.
$store
.
dispatch
(
'
searchUsers
'
,
input
)
})
},
emojiSuggestor
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment