Skip to content

Commit 500f196

Browse files
authored
Merge pull request dbeaver#1126 from dbeaver/hotfix/CB-2558-log-viewer
CB-2558 fix(plugin-log-viewer): Start logs polling on mount
2 parents 96a5735 + 05008ce commit 500f196

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

webapp/packages/plugin-log-viewer/src/LogViewer/LogViewerService.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ export class LogViewerService {
6363

6464
toggle(): void {
6565
if (this.isActive) {
66-
this.stopLog();
66+
this.settings.active = false;
6767
} else {
68-
this.startLog();
68+
this.settings.active = true;
6969
}
7070
}
7171

@@ -74,14 +74,14 @@ export class LogViewerService {
7474
}
7575

7676
async startLog(): Promise<void> {
77-
if (this.isActive) {
77+
if (this.timeoutTaskId !== null) {
7878
return;
7979
}
80+
8081
if (!this.isLogViewerAvailable()) {
8182
throw new Error('Access denied');
8283
}
8384
this.failedRequestsCount = 0;
84-
this.settings.active = true;
8585

8686
const refreshInterval = this.logViewerSettingsService.settings.isValueDefault('refreshTimeout')
8787
? this.coreSettingsService.settings.getValue('app.logViewer.refreshTimeout')
@@ -100,7 +100,6 @@ export class LogViewerService {
100100
clearTimeout(this.timeoutTaskId);
101101
this.timeoutTaskId = null;
102102
}
103-
this.settings.active = false;
104103
}
105104

106105
clearLog(): void {

webapp/packages/plugin-log-viewer/src/LogViewer/useLogViewer.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
import { observable } from 'mobx';
10+
import { useEffect } from 'react';
1011

1112
import { useObjectRef, useObservableRef } from '@cloudbeaver/core-blocks';
1213
import { useService } from '@cloudbeaver/core-di';
@@ -22,6 +23,13 @@ interface Props {
2223
export function useLogViewer() {
2324
const logViewerService = useService(LogViewerService);
2425

26+
useEffect(() => {
27+
logViewerService.startLog();
28+
return () => {
29+
logViewerService.stopLog();
30+
};
31+
}, []);
32+
2533
const props: Props = useObservableRef(
2634
() => ({ selectedItem: null }),
2735
{ selectedItem: observable.ref },

0 commit comments

Comments
 (0)