Skip to content

Commit

Permalink
fix: event registration for ProgressProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jul 31, 2021
1 parent d8fba28 commit 0c5828d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/core/CurrentFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ export class CurrentFile {
static _vue_sfc_loader: VueSfcLoader | null = null
static _composed_loader = new ComposedLoader()
static _onInvalidate = new EventEmitter<boolean>()
static _onInitialized = new EventEmitter<void>()
static _onHardStringDetected = new EventEmitter<DetectionResult[] | undefined>()

static onInvalidate = CurrentFile._onInvalidate.event
static onHardStringDetected = CurrentFile._onHardStringDetected.event
static onInitialized = CurrentFile._onInitialized.event

static get VueSfc() {
return Global.hasFeatureEnabled('VueSfc')
Expand Down Expand Up @@ -54,6 +56,7 @@ export class CurrentFile {
}

this.updateLoaders()
this._onInitialized.fire()
}

static updateLoaders() {
Expand Down
2 changes: 1 addition & 1 deletion src/core/loaders/ComposedLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Disposable } from 'vscode'
import _ from 'lodash'
import { PendingWrite } from '../types'
import { Translator } from '../Translator'
import { Log } from '~/utils'
import { Config } from '../Config'
import { FulfillAllMissingKeys } from '../../commands/manipulations'
import { LocaleTree, LocaleNode, FlattenLocaleTree } from '../Nodes'
import { Loader } from './Loader'
import { Log } from '~/utils'

export class ComposedLoader extends Loader {
constructor() {
Expand Down
4 changes: 2 additions & 2 deletions src/views/providers/ProgressProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export class ProgressProvider implements TreeDataProvider<BaseTreeItem> {

constructor(private ctx: ExtensionContext) {
const throttledRefresh = throttle(() => this.refresh(), THROTTLE_DELAY)
CurrentFile.loader.onDidChange(throttledRefresh)
EditorPanel.onDidChange(throttledRefresh)
Global.loader.onDidChange(throttledRefresh)
CurrentFile.onInitialized(() => CurrentFile.loader.onDidChange(throttledRefresh))
Global.onDidChangeLoader(() => Global.loader.onDidChange(throttledRefresh))
}

refresh(): void {
Expand Down

0 comments on commit 0c5828d

Please sign in to comment.