Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

feat(gif) Support rating config + show display name over gif tile (#12461)

Mihaela Dumitrub4809fe08318
diff --git a/config.js b/config.js
index b57df6be1f..86a194bd0c 100644
--- a/config.js
+++ b/config.js
@@ -1503,6 +1503,8 @@ var config = {
// displayMode: 'all',
// // How long the GIF should be displayed on the tile (in milliseconds).
// tileTime: 5000,
+ // // Limit results by rating: g, pg, pg-13, r. Default value: g.
+ // rating: 'pg',
// },
// Logging
diff --git a/react/features/base/config/configType.ts b/react/features/base/config/configType.ts
index 04d546e14d..419d2354fa 100644
--- a/react/features/base/config/configType.ts
+++ b/react/features/base/config/configType.ts
@@ -312,6 +312,7 @@ export interface IConfig {
giphy?: {
displayMode?: 'all' | 'tile' | 'chat';
enabled?: boolean;
+ rating?: 'g' | 'pg' | 'pg-13' | 'r';
sdkKey?: string;
tileTime?: number;
};
diff --git a/react/features/filmstrip/components/web/Thumbnail.tsx b/react/features/filmstrip/components/web/Thumbnail.tsx
index a8aee9b55e..d0f04a539c 100644
--- a/react/features/filmstrip/components/web/Thumbnail.tsx
+++ b/react/features/filmstrip/components/web/Thumbnail.tsx
@@ -363,7 +363,6 @@ const defaultStyles = (theme: Theme) => {
position: 'absolute' as const,
width: '100%',
height: '100%',
- zIndex: 11,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
diff --git a/react/features/gifs/components/native/GifsMenu.js b/react/features/gifs/components/native/GifsMenu.js
index bd0e3744e0..a59a550f6c 100644
--- a/react/features/gifs/components/native/GifsMenu.js
+++ b/react/features/gifs/components/native/GifsMenu.js
@@ -1,14 +1,14 @@
import { GiphyContent, GiphyGridView, GiphyMediaType } from '@giphy/react-native-sdk';
import React, { useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { useDispatch } from 'react-redux';
+import { useDispatch, useSelector } from 'react-redux';
import { createGifSentEvent, sendAnalytics } from '../../../analytics';
import JitsiScreen from '../../../base/modal/components/JitsiScreen';
import { sendMessage } from '../../../chat/actions.any';
import { goBack } from '../../../mobile/navigation/components/conference/ConferenceNavigationContainerRef';
import ClearableInput from '../../../participants-pane/components/native/ClearableInput';
-import { formatGifUrlMessage, getGifUrl } from '../../functions';
+import { formatGifUrlMessage, getGifRating, getGifUrl } from '../../functions';
import GifsMenuFooter from './GifsMenuFooter';
import styles from './styles';
@@ -17,12 +17,19 @@ const GifsMenu = () => {
const [ searchQuery, setSearchQuery ] = useState('');
const dispatch = useDispatch();
const { t } = useTranslation();
+ const rating = useSelector(getGifRating);
+
+ const options = {
+ mediaType: GiphyMediaType.Gif,
+ limit: 20,
+ rating
+ };
const content = searchQuery === ''
- ? GiphyContent.trending({ mediaType: GiphyMediaType.Gif })
+ ? GiphyContent.trending(options)
: GiphyContent.search({
- searchQuery,
- mediaType: GiphyMediaType.Gif
+ ...options,
+ searchQuery
});
const sendGif = useCallback(e => {
diff --git a/react/features/gifs/components/web/GifsMenu.tsx b/react/features/gifs/components/web/GifsMenu.tsx
index 995fd1a47a..bace70a00a 100644
--- a/react/features/gifs/components/web/GifsMenu.tsx
+++ b/react/features/gifs/components/web/GifsMenu.tsx
@@ -20,7 +20,12 @@ import { setOverflowMenuVisible } from '../../../toolbox/actions.web';
import { Drawer, JitsiPortal } from '../../../toolbox/components/web';
import { showOverflowDrawer } from '../../../toolbox/functions.web';
import { setGifDrawerVisibility } from '../../actions';
-import { formatGifUrlMessage, getGifAPIKey, getGifUrl } from '../../functions';
+import {
+ formatGifUrlMessage,
+ getGifAPIKey,
+ getGifRating,
+ getGifUrl
+} from '../../function.any';
const OVERFLOW_DRAWER_PADDING = 16;
@@ -88,12 +93,13 @@ function GifsMenu() {
const { t } = useTranslation();
const overflowDrawer: boolean = useSelector(showOverflowDrawer);
const { clientWidth } = useSelector((state: IReduxState) => state['features/base/responsive-ui']);
+ const rating = useSelector(getGifRating);
const fetchGifs = useCallback(async (offset = 0) => {
const options: TrendingOptions = {
- rating: 'pg-13',
limit: 20,
- offset
+ offset,
+ rating
};
if (!searchKey) {
diff --git a/react/features/gifs/constants.ts b/react/features/gifs/constants.ts
index 03d8480910..38ae004864 100644
--- a/react/features/gifs/constants.ts
+++ b/react/features/gifs/constants.ts
@@ -7,3 +7,8 @@ export const GIF_DEFAULT_TIMEOUT = 5000;
* The prefix for formatted GIF messages.
*/
export const GIF_PREFIX = 'gif[';
+
+/**
+ * The Giphy default option for audience rating.
+ */
+export const GIF_DEFAULT_RATING = 'g';
diff --git a/react/features/gifs/function.any.ts b/react/features/gifs/function.any.ts
index 4d1d3f2217..a8754296e2 100644
--- a/react/features/gifs/function.any.ts
+++ b/react/features/gifs/function.any.ts
@@ -1,6 +1,6 @@
import { IReduxState } from '../app/types';
-import { GIF_PREFIX } from './constants';
+import { GIF_DEFAULT_RATING, GIF_PREFIX } from './constants';
import { IGif } from './reducer';
/**
@@ -87,3 +87,15 @@ export function getGifDisplayMode(state: IReduxState) {
return giphy?.displayMode || 'all';
}
+
+/**
+ * Get the GIF audience rating.
+ *
+ * @param {IReduxState} state - Redux state.
+ * @returns {string}
+ */
+export function getGifRating(state: IReduxState) {
+ const { giphy } = state['features/base/config'];
+
+ return giphy?.rating || GIF_DEFAULT_RATING;
+}