From fdd3ad24f8224b074ec419f88ba3b4b2c7cec2c2 Mon Sep 17 00:00:00 2001
From: Joe McGrath <33670767+josephmcg@users.noreply.github.com>
Date: Tue, 28 Dec 2021 05:20:19 +0900
Subject: [PATCH] feat(glyphs): recently used glyphs functionality AP-341
(#769)
---
.../EmbeddedLinkContent.vue | 32 +++-----
.../Chat/Embeds/VideoPlayer/VideoPlayer.vue | 2 +-
.../views/chat/chatbar/reply/Reply.less | 79 ++++++++++---------
.../views/chat/enhancers/glyphs/Glyphs.html | 1 -
.../views/chat/enhancers/glyphs/Glyphs.less | 3 +
.../chat/enhancers/glyphs/item/Item.html | 2 +-
.../views/chat/enhancers/glyphs/item/Item.vue | 8 +-
.../views/chat/enhancers/glyphs/nav/Nav.html | 11 +--
.../views/chat/enhancers/glyphs/nav/Nav.less | 1 +
.../views/chat/enhancers/glyphs/nav/Nav.vue | 19 +++--
components/views/chat/message/Message.vue | 3 +-
config.ts | 8 ++
locales | 2 +-
nuxt.config.js | 1 +
store/ui/getters.ts | 6 +-
store/ui/mutations.ts | 13 +++
store/ui/state.ts | 3 +-
store/ui/types.ts | 28 ++++---
18 files changed, 133 insertions(+), 89 deletions(-)
diff --git a/components/ui/Chat/Embeds/EmbeddedLinkContent/EmbeddedLinkContent.vue b/components/ui/Chat/Embeds/EmbeddedLinkContent/EmbeddedLinkContent.vue
index 2670c2190c..e629764696 100644
--- a/components/ui/Chat/Embeds/EmbeddedLinkContent/EmbeddedLinkContent.vue
+++ b/components/ui/Chat/Embeds/EmbeddedLinkContent/EmbeddedLinkContent.vue
@@ -7,8 +7,8 @@ import { IFrameVideoData } from './types'
export default Vue.extend({
props: {
data: {
- type: String,
- default: () => {},
+ type: String,
+ default: () => {},
},
},
data() {
@@ -33,9 +33,7 @@ export default Vue.extend({
*/
parseEmbeddableVideoContentFromText(messagetext: string) {
// parse incoming text for links
- const arrayOfLinks = messagetext.match(
- /(\b(https?):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|])/gi
- )
+ const arrayOfLinks = messagetext.match(this.$Config.regex.link)
// this.settings.embeddedLinks is the global set in the networks panel. Without this, it just shows up as a normal link
if (arrayOfLinks && this.settings.embeddedLinks === true) {
@@ -44,8 +42,8 @@ export default Vue.extend({
Parsing Youtube links, if we need to modify the regex do it in here.
*/
if (
- link.match(/^https?:\/\/([a-z0-9-]+[.])*youtube.com?/g) ||
- link.match(/^https?:\/\/([a-z0-9-]+[.])*youtu.be?/g)
+ link.match(this.$Config.regex.youtube) ||
+ link.match(this.$Config.regex.youtubeShort)
) {
let youtubeOutSource: string = ''
if (link.includes('youtube')) {
@@ -68,7 +66,7 @@ export default Vue.extend({
/*
Parsing Vimeo links, if we need to modify the regex do it in here. Right now it parses regular links and links to videos that are in collections
*/
- if (link.match(/^https?:\/\/([a-z0-9-]+[.])*vimeo.com?/g)) {
+ if (link.match(this.$Config.regex.vimeo)) {
// vimeo makes their video id potentially available in several different places in the url
const videoID: string = link
.split('/')
@@ -83,7 +81,7 @@ export default Vue.extend({
}
if (
- link.match(/^https?:\/\/([a-z0-9-]+[.])*facebook.com?/g) &&
+ link.match(this.$Config.regex.facebook) &&
link.includes('videos')
) {
// hacky workaround to make facebook embed more mobile responsive.
@@ -92,7 +90,7 @@ export default Vue.extend({
requestWidth = '300'
}
const facebookOutSource = `https://www.facebook.com/plugins/video.php?href=${encodeURIComponent(
- link.split('?')[0]
+ link.split('?')[0],
)}&show_text=0&width=${requestWidth}`
return {
src: facebookOutSource,
@@ -102,7 +100,7 @@ export default Vue.extend({
}
}
- if (link.match(/^https?:\/\/([a-z0-9-]+[.])twitch[.]tv\/?/g)) {
+ if (link.match(this.$Config.regex.twitch)) {
let videoId: string = ''
// check to see if it's an individual video
if (link.includes('/videos/')) {
@@ -120,17 +118,13 @@ export default Vue.extend({
src: `https://player.twitch.tv/?${videoId}&parent=${window.location.hostname}&autoplay=false`,
type: 'iframe',
ref: this.setRefId(
- `https://player.twitch.tv/?${videoId}&parent=${window.location.hostname}&autoplay=false`
+ `https://player.twitch.tv/?${videoId}&parent=${window.location.hostname}&autoplay=false`,
),
aspectRatioClass: 'iframe-container-16-9',
}
}
- if (
- link.match(
- /^https?:\/\/([a-z0-9-]+[.])spotify[.]com\/(playlist|embed)?/g
- )
- ) {
+ if (link.match(this.$Config.regex.spotify)) {
// get type and id
// https://open.spotify.com/playlist/46ffmNKBTEakwz0t625bbC?si=e878040ce04c460f => playlist/46ffmNKBTEakwz0t625bbC
// https://open.spotify.com/track/3s2RFp5hU6jEvAmfZrnrAi?si=a9bf555ede314a19 => track/3s2RFp5hU6jEvAmfZrnrAi
@@ -142,7 +136,7 @@ export default Vue.extend({
src: `https://open.spotify.com/embed/${spotifyEmbedType}?utm_source=generator`,
type: 'iframe',
ref: this.setRefId(
- `https://open.spotify.com/embed/${spotifyEmbedType}?utm_source=generator`
+ `https://open.spotify.com/embed/${spotifyEmbedType}?utm_source=generator`,
),
aspectRatioClass: 'iframe-container-16-9',
}
@@ -180,7 +174,7 @@ export default Vue.extend({
},
})
-
+
+