Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
d16914b7
Commit
d16914b7
authored
Mar 12, 2021
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved some re-used values into constants file
parent
1b94ec93
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
8 deletions
+17
-8
app/assets/javascripts/emoji/components/picker.vue
app/assets/javascripts/emoji/components/picker.vue
+2
-2
app/assets/javascripts/emoji/components/utils.js
app/assets/javascripts/emoji/components/utils.js
+11
-5
app/assets/javascripts/emoji/constants.js
app/assets/javascripts/emoji/constants.js
+4
-1
No files found.
app/assets/javascripts/emoji/components/picker.vue
View file @
d16914b7
...
...
@@ -3,7 +3,7 @@ import { GlIcon, GlDropdown, GlSearchBoxByType } from '@gitlab/ui';
import
{
findLastIndex
}
from
'
lodash
'
;
import
VirtualList
from
'
vue-virtual-scroll-list
'
;
import
{
CATEGORY_NAMES
}
from
'
~/emoji
'
;
import
{
CATEGORY_ICON_MAP
}
from
'
../constants
'
;
import
{
CATEGORY_ICON_MAP
,
FREQUENTLY_USED_KEY
}
from
'
../constants
'
;
import
Category
from
'
./category.vue
'
;
import
EmojiList
from
'
./emoji_list.vue
'
;
import
{
addToFrequentlyUsed
,
getEmojiCategories
,
hasFrequentlyUsedEmojis
}
from
'
./utils
'
;
...
...
@@ -33,7 +33,7 @@ export default {
computed
:
{
categoryNames
()
{
return
CATEGORY_NAMES
.
filter
((
c
)
=>
{
if
(
c
===
'
frequently_used
'
)
return
hasFrequentlyUsedEmojis
();
if
(
c
===
FREQUENTLY_USED_KEY
)
return
hasFrequentlyUsedEmojis
();
return
true
;
}).
map
((
category
)
=>
({
name
:
category
,
...
...
app/assets/javascripts/emoji/components/utils.js
View file @
d16914b7
import
Cookies
from
'
js-cookie
'
;
import
{
chunk
,
memoize
,
uniq
}
from
'
lodash
'
;
import
{
initEmojiMap
,
getEmojiCategoryMap
}
from
'
~/emoji
'
;
import
{
EMOJIS_PER_ROW
,
EMOJI_ROW_HEIGHT
,
CATEGORY_ROW_HEIGHT
}
from
'
../constants
'
;
import
{
EMOJIS_PER_ROW
,
EMOJI_ROW_HEIGHT
,
CATEGORY_ROW_HEIGHT
,
FREQUENTLY_USED_KEY
,
FREQUENTLY_USED_COOKIE_KEY
,
}
from
'
../constants
'
;
export
const
generateCategoryHeight
=
(
emojisLength
)
=>
emojisLength
*
EMOJI_ROW_HEIGHT
+
CATEGORY_ROW_HEIGHT
;
export
const
getFrequentlyUsedEmojis
=
()
=>
{
const
savedEmojis
=
Cookies
.
get
(
'
frequently_used_emojis
'
);
const
savedEmojis
=
Cookies
.
get
(
FREQUENTLY_USED_COOKIE_KEY
);
if
(
!
savedEmojis
)
return
null
;
...
...
@@ -24,13 +30,13 @@ export const getFrequentlyUsedEmojis = () => {
export
const
addToFrequentlyUsed
=
(
emoji
)
=>
{
const
frequentlyUsedEmojis
=
uniq
(
(
Cookies
.
get
(
'
frequently_used_emojis
'
)
||
''
)
(
Cookies
.
get
(
FREQUENTLY_USED_COOKIE_KEY
)
||
''
)
.
split
(
'
,
'
)
.
filter
((
e
)
=>
e
)
.
concat
(
emoji
),
);
Cookies
.
set
(
'
frequently_used_emojis
'
,
frequentlyUsedEmojis
.
join
(
'
,
'
),
{
expires
:
365
});
Cookies
.
set
(
FREQUENTLY_USED_COOKIE_KEY
,
frequentlyUsedEmojis
.
join
(
'
,
'
),
{
expires
:
365
});
};
export
const
hasFrequentlyUsedEmojis
=
()
=>
getFrequentlyUsedEmojis
()
!==
null
;
...
...
@@ -46,7 +52,7 @@ export const getEmojiCategories = memoize(async () => {
return
Object
.
freeze
(
Object
.
keys
(
categories
)
.
filter
((
c
)
=>
c
!==
'
frequently_used
'
)
.
filter
((
c
)
=>
c
!==
FREQUENTLY_USED_KEY
)
.
reduce
((
acc
,
category
)
=>
{
const
emojis
=
chunk
(
categories
[
category
],
EMOJIS_PER_ROW
);
const
height
=
generateCategoryHeight
(
emojis
.
length
);
...
...
app/assets/javascripts/emoji/constants.js
View file @
d16914b7
export
const
FREQUENTLY_USED_KEY
=
'
frequently_used
'
;
export
const
FREQUENTLY_USED_COOKIE_KEY
=
'
frequently_used_emojis
'
;
export
const
CATEGORY_ICON_MAP
=
{
frequently_used
:
'
history
'
,
[
FREQUENTLY_USED_KEY
]
:
'
history
'
,
activity
:
'
dumbbell
'
,
people
:
'
smiley
'
,
nature
:
'
nature
'
,
...
...
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