diff --git a/app/components/user_list/__snapshots__/index.test.tsx.snap b/app/components/user_list/__snapshots__/index.test.tsx.snap
index 80e960a70..e6c36f589 100644
--- a/app/components/user_list/__snapshots__/index.test.tsx.snap
+++ b/app/components/user_list/__snapshots__/index.test.tsx.snap
@@ -548,15 +548,6 @@ exports[`components/channel_list_row should show results and tutorial 1`] = `
-
(null);
const style = getStyleFromTheme(theme);
const {formatMessage} = useIntl();
+ const tutorialShown = useRef(false);
const startTutorial = () => {
viewRef.current?.measureInWindow((x, y, w, h) => {
@@ -113,18 +114,6 @@ function UserListRow({
storeProfileLongPressTutorial();
}, []);
- useEffect(() => {
- if (highlight && !tutorialWatched) {
- if (isTablet) {
- setShowTutorial(true);
- return;
- }
- InteractionManager.runAfterInteractions(() => {
- setShowTutorial(true);
- });
- }
- }, [highlight, tutorialWatched, isTablet]);
-
const handlePress = useCallback((u: UserModel | UserProfile) => {
onPress?.(u);
}, [onPress]);
@@ -155,11 +144,24 @@ function UserListRow({
}, [isChannelAdmin, showManageMode, theme]);
const onLayout = useCallback(() => {
- if (showTutorial) {
- startTutorial();
+ if (highlight && !tutorialWatched) {
+ if (isTablet) {
+ setShowTutorial(true);
+ return;
+ }
+ InteractionManager.runAfterInteractions(() => {
+ setShowTutorial(true);
+ });
}
}, [showTutorial]);
+ useLayoutEffect(() => {
+ if (showTutorial && !tutorialShown.current) {
+ tutorialShown.current = true;
+ startTutorial();
+ }
+ });
+
const icon = useMemo(() => {
if (!selectable && !selected) {
return null;
diff --git a/app/screens/home/channel_list/servers/servers_list/server_item/server_item.tsx b/app/screens/home/channel_list/servers/servers_list/server_item/server_item.tsx
index c078856e4..6d88b222c 100644
--- a/app/screens/home/channel_list/servers/servers_list/server_item/server_item.tsx
+++ b/app/screens/home/channel_list/servers/servers_list/server_item/server_item.tsx
@@ -1,7 +1,7 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
-import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
+import React, {useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState} from 'react';
import {useIntl} from 'react-intl';
import {Animated, DeviceEventEmitter, InteractionManager, Platform, type StyleProp, Text, View, type ViewStyle} from 'react-native';
import {RectButton} from 'react-native-gesture-handler';
@@ -159,6 +159,7 @@ const ServerItem = ({
const viewRef = useRef(null);
const [showTutorial, setShowTutorial] = useState(false);
const [itemBounds, setItemBounds] = useState({startX: 0, startY: 0, endX: 0, endY: 0});
+ const tutorialShown = useRef(false);
let displayName = server.displayName;
@@ -213,12 +214,25 @@ const ServerItem = ({
};
const onLayout = useCallback(() => {
- if (showTutorial) {
- swipeable.current?.close();
- startTutorial();
+ if (highlight && !tutorialWatched) {
+ if (isTablet) {
+ setShowTutorial(true);
+ return;
+ }
+ InteractionManager.runAfterInteractions(() => {
+ setShowTutorial(true);
+ });
}
}, [showTutorial]);
+ useLayoutEffect(() => {
+ if (showTutorial && !tutorialShown.current) {
+ swipeable.current?.close();
+ tutorialShown.current = true;
+ startTutorial();
+ }
+ });
+
const containerStyle = useMemo(() => {
const style: StyleProp = [styles.container];
if (isActive) {
@@ -349,18 +363,6 @@ const ServerItem = ({
};
}, [server.lastActiveAt, isActive]);
- useEffect(() => {
- if (highlight && !tutorialWatched) {
- if (isTablet) {
- setShowTutorial(true);
- return;
- }
- InteractionManager.runAfterInteractions(() => {
- setShowTutorial(true);
- });
- }
- }, [highlight, tutorialWatched, isTablet]);
-
const serverItem = `server_list.server_item.${server.displayName.replace(/ /g, '_').toLocaleLowerCase()}`;
const serverItemTestId = isActive ? `${serverItem}.active` : `${serverItem}.inactive`;