@@ -3,7 +3,6 @@ import "./global";
3
3
4
4
import { provide } from "@lit/context" ;
5
5
import { localized , msg , str } from "@lit/localize" ;
6
- import { Task } from "@lit/task" ;
7
6
import type {
8
7
SlDialog ,
9
8
SlDrawer ,
@@ -15,7 +14,6 @@ import { ifDefined } from "lit/directives/if-defined.js";
15
14
import { until } from "lit/directives/until.js" ;
16
15
import { when } from "lit/directives/when.js" ;
17
16
import isEqual from "lodash/fp/isEqual" ;
18
- import queryString from "query-string" ;
19
17
20
18
import "./components" ;
21
19
import "./features" ;
@@ -35,9 +33,7 @@ import AuthService, {
35
33
import { BtrixElement } from "@/classes/BtrixElement" ;
36
34
import type { NavigateEventDetail } from "@/controllers/navigate" ;
37
35
import type { NotifyEventDetail } from "@/controllers/notify" ;
38
- import type { APIPaginatedList } from "@/types/api" ;
39
36
import { type Auth } from "@/types/auth" ;
40
- import type { Crawl } from "@/types/crawler" ;
41
37
import {
42
38
translatedLocales ,
43
39
type TranslatedLocaleEnum ,
@@ -70,8 +66,6 @@ export interface UserGuideEventMap {
70
66
"btrix-user-guide-show" : CustomEvent < { path ?: string } > ;
71
67
}
72
68
73
- const POLL_INTERVAL_SECONDS = 30 ;
74
-
75
69
@customElement ( "browsertrix-app" )
76
70
@localized ( )
77
71
export class App extends BtrixElement {
@@ -114,24 +108,6 @@ export class App extends BtrixElement {
114
108
@query ( "#userGuideDrawer" )
115
109
private readonly userGuideDrawer ! : SlDrawer ;
116
110
117
- private readonly activeCrawlsTotalTask = new Task ( this , {
118
- task : async ( ) => {
119
- return await this . getActiveCrawlsTotal ( ) ;
120
- } ,
121
- args : ( ) => [ ] as const ,
122
- } ) ;
123
-
124
- private readonly pollTask = new Task ( this , {
125
- task : async ( [ crawls ] ) => {
126
- if ( ! crawls ) return ;
127
-
128
- return window . setTimeout ( ( ) => {
129
- void this . activeCrawlsTotalTask . run ( ) ;
130
- } , POLL_INTERVAL_SECONDS * 1000 ) ;
131
- } ,
132
- args : ( ) => [ this . activeCrawlsTotalTask . value ] as const ,
133
- } ) ;
134
-
135
111
get orgSlugInPath ( ) {
136
112
return this . viewState . params . slug || "" ;
137
113
}
@@ -188,12 +164,6 @@ export class App extends BtrixElement {
188
164
this . startSyncBrowserTabs ( ) ;
189
165
}
190
166
191
- disconnectedCallback ( ) : void {
192
- super . disconnectedCallback ( ) ;
193
-
194
- window . clearTimeout ( this . pollTask . value ) ;
195
- }
196
-
197
167
private attachUserGuideListeners ( ) {
198
168
this . addEventListener (
199
169
"btrix-user-guide-show" ,
@@ -479,7 +449,7 @@ export class App extends BtrixElement {
479
449
}
480
450
481
451
private renderNavBar ( ) {
482
- const isSuperAdmin = this . userInfo ?. isSuperAdmin ;
452
+ const isSuperAdmin = this . authState && this . userInfo ?. isSuperAdmin ;
483
453
484
454
const showFullLogo =
485
455
this . viewState . route === "login" || ! this . authService . authState ;
@@ -629,14 +599,7 @@ export class App extends BtrixElement {
629
599
@click =${ this . navigate . link }
630
600
>
631
601
${ msg ( "Active Crawls" ) }
632
- ${ when (
633
- this . activeCrawlsTotalTask . value ,
634
- ( total ) => html `
635
- < btrix-badge variant =${ total > 0 ? "primary" : "blue" } >
636
- ${ this . localize . number ( total ) }
637
- </ btrix-badge >
638
- ` ,
639
- ) }
602
+ < btrix-active-crawls-badge > </ btrix-active-crawls-badge >
640
603
</ a >
641
604
</ div >
642
605
`
@@ -1183,16 +1146,4 @@ export class App extends BtrixElement {
1183
1146
private clearSelectedOrg ( ) {
1184
1147
AppStateService . updateOrgSlug ( null ) ;
1185
1148
}
1186
-
1187
- private async getActiveCrawlsTotal ( ) {
1188
- const query = queryString . stringify ( {
1189
- pageSize : 1 ,
1190
- } ) ;
1191
-
1192
- const data = await this . api . fetch < APIPaginatedList < Crawl > > (
1193
- `/orgs/all/crawls?${ query } ` ,
1194
- ) ;
1195
-
1196
- return data . total ;
1197
- }
1198
1149
}
0 commit comments