Skip to content

Commit 97281d1

Browse files
Fix recent activity rerender (#1370)
* Fix recent activity rerender * Remove recent activity indicator management --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 1659125 commit 97281d1

File tree

38 files changed

+490
-434
lines changed

38 files changed

+490
-434
lines changed

apps.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const appData: AppData = {
5454
// },
5555
["recent-activity"]: {
5656
entry: path.resolve(__dirname, "./src/containers/RecentActivity/index.tsx"),
57+
environmentVariables: ["recentActivityExpirationLimit"],
5758
platforms: ["jetbrains"]
5859
},
5960
troubleshooting: {

dependencies.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"jetBrainsPluginVersion": "2.0.414",
2+
"jetBrainsPluginVersion": "2.0.417",
33
"visualStudioExtensionVersion": "1.2.11",
44
"jaegerUIVersion": "1.29.1-digma.1.2.0",
55
"jaegerVersion": "1.45.0"

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "digma-ui",
3-
"version": "12.0.4",
3+
"version": "12.0.5-alpha.1",
44
"description": "Digma UI",
55
"scripts": {
66
"lint:eslint": "eslint --cache .",

src/components/Admin/Header/Greeting/index.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useState } from "react";
1+
import { useNow } from "../../../../hooks/useNow";
22
import { useGetUserProfileQuery } from "../../../../redux/services/digma";
33
import * as s from "./styles";
44

@@ -19,17 +19,9 @@ const getGreetingText = (dateTime: number) => {
1919
};
2020

2121
export const Greeting = () => {
22+
const now = useNow(REFRESH_INTERVAL);
2223
const { data: userProfile } = useGetUserProfileQuery();
23-
const [currentDateTime, setCurrentDateTime] = useState(Date.now());
24-
const greetingText = getGreetingText(currentDateTime);
25-
26-
useEffect(() => {
27-
const intervalId = setInterval(() => {
28-
setCurrentDateTime(Date.now());
29-
}, REFRESH_INTERVAL);
30-
31-
return () => clearInterval(intervalId);
32-
}, []);
24+
const greetingText = getGreetingText(now);
3325

3426
if (!userProfile) {
3527
return null;

src/components/Admin/Header/HeaderContent/FilterMenu/FilterButton/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ const FilterButtonComponent = (
2020
</Tooltip>
2121
</div>
2222
);
23+
2324
export const FilterButton = forwardRef(FilterButtonComponent);

src/components/Assets/AssetList/AssetEntry/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { getFeatureFlagValue } from "../../../../featureFlags";
2+
import { useNow } from "../../../../hooks/useNow";
23
import { AssetsSortingCriterion } from "../../../../redux/services/types";
34
import { useConfigSelector } from "../../../../store/config/useConfigSelector";
45
import { isNumber } from "../../../../typeGuards/isNumber";
@@ -25,6 +26,7 @@ export const AssetEntry = ({
2526
sortingCriterion
2627
}: AssetEntryProps) => {
2728
const { backendInfo } = useConfigSelector();
29+
const now = useNow();
2830
const isNewImpactScoreCalculationEnabled = getFeatureFlagValue(
2931
backendInfo,
3032
FeatureFlag.IsNewImpactScoreCalculationEnabled
@@ -62,14 +64,14 @@ export const AssetEntry = ({
6264

6365
const servicesTitle = entry.services.join(", ");
6466

65-
const timeDistanceString = formatTimeDistance(lastSeenDateTime, {
67+
const timeDistanceString = formatTimeDistance(lastSeenDateTime, now, {
6668
format: "short",
6769
withDescriptiveWords: false
6870
}).replace(" ", "");
6971
const timeDistanceTitle = new Date(lastSeenDateTime).toString();
7072

7173
const isNew = isString(entry.firstDetected)
72-
? Date.now() - new Date(entry.firstDetected).valueOf() < IS_NEW_TIME_LIMIT
74+
? now - new Date(entry.firstDetected).valueOf() < IS_NEW_TIME_LIMIT
7375
: false;
7476

7577
return (

src/components/Assets/AssetList/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ export const AssetList = ({
154154

155155
const { data } = useGetAssetsQuery(payload, {
156156
skip: !environmentId,
157-
pollingInterval: REFRESH_INTERVAL
157+
pollingInterval: REFRESH_INTERVAL,
158+
refetchOnReconnect: true
158159
});
159160

160161
const filteredCount = data?.filteredCount ?? 0;

src/components/Assets/AssetTypeList/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ export const AssetTypeList = ({
5656

5757
const { data } = useGetAssetsCategoriesQuery(payload, {
5858
skip: !environmentId,
59-
pollingInterval: REFRESH_INTERVAL
59+
pollingInterval: REFRESH_INTERVAL,
60+
refetchOnReconnect: true
6061
});
6162

6263
const previousData = usePrevious(data);

src/components/Errors/ErrorCard/TimestampKeyValue/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
import { useNow } from "../../../../hooks/useNow";
12
import { formatTimeDistance } from "../../../../utils/formatTimeDistance";
23
import { Tooltip } from "../../../common/v3/Tooltip";
34
import * as s from "./styles";
45
import type { TimestampProps } from "./types";
56

67
export const TimestampKeyValue = ({ label, timestamp }: TimestampProps) => {
78
const dateTimeString = new Date(timestamp).toString();
9+
const now = useNow();
810

911
return (
1012
<Tooltip title={dateTimeString} key={label}>
1113
<s.Container>
1214
<s.Label>{label}:</s.Label>
13-
<s.TimeDistance>{formatTimeDistance(timestamp)}</s.TimeDistance>
15+
<s.TimeDistance>{formatTimeDistance(timestamp, now)}</s.TimeDistance>
1416
</s.Container>
1517
</Tooltip>
1618
);

0 commit comments

Comments
 (0)