Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion client/components/Message/Attachments/components/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ const Image: FC<ImageProps> = ({ previewUrl, loadImage = true, setLoadImage, src
return (
<ImageBox
onError={setHasError}
box
{...(previewUrl && ({ style: { background, boxSizing: 'content-box' } } as any))}
{...dimensions}
is='picture'
Expand Down
21 changes: 13 additions & 8 deletions client/providers/createReactiveSubscriptionFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,30 @@ export const createReactiveSubscriptionFactory = <T>(

const callbacks = new Set<Unsubscribe>();

let currentValue: T;

const computation = Tracker.autorun(() => {
currentValue = computeCurrentValue();
callbacks.forEach((callback) => {
callback();
let currentValue = computeCurrentValue();

let computation: Tracker.Computation | undefined;
const timeout = setTimeout(() => {
computation = Tracker.autorun(() => {
currentValue = computeCurrentValue();
callbacks.forEach((callback) => {
callback();
});
});
});
}, 0);

return {
getCurrentValue: (): T => currentValue,
subscribe: (callback): Unsubscribe => {
callbacks.add(callback);

return (): void => {
clearTimeout(timeout);

callbacks.delete(callback);

if (callbacks.size === 0) {
computation.stop();
computation && computation.stop();
}
};
},
Expand Down
5 changes: 1 addition & 4 deletions client/views/room/contextualBar/Threads/ThreadList.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box, Icon, TextInput, Select, Margins, Callout } from '@rocket.chat/fuselage';
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 ThreadComponent from '../../../../../app/threads/client/components/ThreadComponent';
Expand Down Expand Up @@ -35,7 +35,6 @@ function ThreadList({
setText,
}) {
const showRealNames = useSetting('UI_Use_Real_Name');
const threadsRef = useRef();

const t = useTranslation();
const inputRef = useAutoFocus(true);
Expand All @@ -60,8 +59,6 @@ function ThreadList({
[t],
);

threadsRef.current = threads;

const { ref, contentBoxSize: { inlineSize = 378, blockSize = 1 } = {} } = useResizeObserver({
debounceDelay: 200,
});
Expand Down
10 changes: 2 additions & 8 deletions client/views/room/contextualBar/Threads/useThreadsList.ts
Original file line number Diff line number Diff line change
@@ -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 { IUser } from '../../../../../definition/IUser';
Expand All @@ -15,13 +15,7 @@ export const useThreadsList = (
initialItemCount: number;
loadMoreItems: (start: number, end: number) => void;
} => {
const [threadsList] = useState(() => new ThreadsList(options));

useEffect(() => {
if (threadsList.options !== options) {
threadsList.updateFilters(options);
}
}, [threadsList, options]);
const threadsList = useMemo(() => new ThreadsList(options), [options]);

const getThreadsList = useEndpoint('GET', 'chat.getThreadsList');

Expand Down