Regression: Unread Threads Header and List (#21816)

pull/21818/head
Guilherme Gazzo 4 years ago committed by GitHub
parent 8abc78e2e9
commit bee153ab3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      client/components/Message/Attachments/components/Image.tsx
  2. 21
      client/providers/createReactiveSubscriptionFactory.ts
  3. 5
      client/views/room/contextualBar/Threads/ThreadList.js
  4. 10
      client/views/room/contextualBar/Threads/useThreadsList.ts

@ -59,7 +59,6 @@ const Image: FC<ImageProps> = ({ previewUrl, loadImage = true, setLoadImage, src
return ( return (
<ImageBox <ImageBox
onError={setHasError} onError={setHasError}
box
{...(previewUrl && ({ style: { background, boxSizing: 'content-box' } } as any))} {...(previewUrl && ({ style: { background, boxSizing: 'content-box' } } as any))}
{...dimensions} {...dimensions}
is='picture' is='picture'

@ -12,14 +12,17 @@ export const createReactiveSubscriptionFactory = <T>(
const callbacks = new Set<Unsubscribe>(); const callbacks = new Set<Unsubscribe>();
let currentValue: T; let currentValue = computeCurrentValue();
const computation = Tracker.autorun(() => { let computation: Tracker.Computation | undefined;
currentValue = computeCurrentValue(); const timeout = setTimeout(() => {
callbacks.forEach((callback) => { computation = Tracker.autorun(() => {
callback(); currentValue = computeCurrentValue();
callbacks.forEach((callback) => {
callback();
});
}); });
}); }, 0);
return { return {
getCurrentValue: (): T => currentValue, getCurrentValue: (): T => currentValue,
@ -27,10 +30,12 @@ export const createReactiveSubscriptionFactory = <T>(
callbacks.add(callback); callbacks.add(callback);
return (): void => { return (): void => {
clearTimeout(timeout);
callbacks.delete(callback); callbacks.delete(callback);
if (callbacks.size === 0) { if (callbacks.size === 0) {
computation.stop(); computation && computation.stop();
} }
}; };
}, },

@ -1,6 +1,6 @@
import { Box, Icon, TextInput, Select, Margins, Callout } from '@rocket.chat/fuselage'; import { Box, Icon, TextInput, Select, Margins, Callout } from '@rocket.chat/fuselage';
import { useResizeObserver, useMutableCallback, useAutoFocus } from '@rocket.chat/fuselage-hooks'; import { useResizeObserver, useMutableCallback, useAutoFocus } from '@rocket.chat/fuselage-hooks';
import React, { useMemo, useRef } from 'react'; import React, { useMemo } from 'react';
import { Virtuoso } from 'react-virtuoso'; import { Virtuoso } from 'react-virtuoso';
import ThreadComponent from '../../../../../app/threads/client/components/ThreadComponent'; import ThreadComponent from '../../../../../app/threads/client/components/ThreadComponent';
@ -35,7 +35,6 @@ function ThreadList({
setText, setText,
}) { }) {
const showRealNames = useSetting('UI_Use_Real_Name'); const showRealNames = useSetting('UI_Use_Real_Name');
const threadsRef = useRef();
const t = useTranslation(); const t = useTranslation();
const inputRef = useAutoFocus(true); const inputRef = useAutoFocus(true);
@ -60,8 +59,6 @@ function ThreadList({
[t], [t],
); );
threadsRef.current = threads;
const { ref, contentBoxSize: { inlineSize = 378, blockSize = 1 } = {} } = useResizeObserver({ const { ref, contentBoxSize: { inlineSize = 378, blockSize = 1 } = {} } = useResizeObserver({
debounceDelay: 200, debounceDelay: 200,
}); });

@ -1,4 +1,4 @@
import { useCallback, useEffect, useMemo, useState } from 'react'; import { useCallback, useMemo } from 'react';
import { getConfig } from '../../../../../app/ui-utils/client/config'; import { getConfig } from '../../../../../app/ui-utils/client/config';
import { IUser } from '../../../../../definition/IUser'; import { IUser } from '../../../../../definition/IUser';
@ -15,13 +15,7 @@ export const useThreadsList = (
initialItemCount: number; initialItemCount: number;
loadMoreItems: (start: number, end: number) => void; loadMoreItems: (start: number, end: number) => void;
} => { } => {
const [threadsList] = useState(() => new ThreadsList(options)); const threadsList = useMemo(() => new ThreadsList(options), [options]);
useEffect(() => {
if (threadsList.options !== options) {
threadsList.updateFilters(options);
}
}, [threadsList, options]);
const getThreadsList = useEndpoint('GET', 'chat.getThreadsList'); const getThreadsList = useEndpoint('GET', 'chat.getThreadsList');

Loading…
Cancel
Save