Browse Source

Renames isReady to ready

main
Eric Amodio 1 year ago
parent
commit
ee1e5214a8
7 changed files with 35 additions and 35 deletions
  1. +12
    -12
      src/plus/webviews/graph/graphWebview.ts
  2. +2
    -2
      src/plus/webviews/timeline/timelineWebview.ts
  3. +2
    -2
      src/webviews/commitDetails/commitDetailsWebview.ts
  4. +4
    -4
      src/webviews/home/homeWebview.ts
  5. +1
    -1
      src/webviews/settings/settingsWebview.ts
  6. +12
    -12
      src/webviews/webviewController.ts
  7. +2
    -2
      src/webviews/webviewsController.ts

+ 12
- 12
src/plus/webviews/graph/graphWebview.ts View File

@ -189,7 +189,7 @@ export class GraphWebviewProvider implements WebviewProvider {
this.resetRepositoryState(); this.resetRepositoryState();
this.ensureRepositorySubscriptions(true); this.ensureRepositorySubscriptions(true);
if (this.host.isReady) {
if (this.host.ready) {
this.updateState(); this.updateState();
} }
} }
@ -282,7 +282,7 @@ export class GraphWebviewProvider implements WebviewProvider {
this.repository = context.node.repo; this.repository = context.node.repo;
} }
if (this.repository != null && !loading && this.host.isReady) {
if (this.repository != null && !loading && this.host.ready) {
this.updateState(); this.updateState();
} }
} }
@ -414,7 +414,7 @@ export class GraphWebviewProvider implements WebviewProvider {
} }
if (visible) { if (visible) {
if (this.host.isReady) {
if (this.host.ready) {
this.sendPendingIpcNotifications(); this.sendPendingIpcNotifications();
} }
@ -1117,7 +1117,7 @@ export class GraphWebviewProvider implements WebviewProvider {
@debug() @debug()
private async notifyDidChangeWindowFocus(): Promise<boolean> { private async notifyDidChangeWindowFocus(): Promise<boolean> {
if (!this.host.isReady || !this.host.visible) {
if (!this.host.ready || !this.host.visible) {
this.addPendingIpcNotification(DidChangeWindowFocusNotificationType); this.addPendingIpcNotification(DidChangeWindowFocusNotificationType);
return false; return false;
} }
@ -1181,7 +1181,7 @@ export class GraphWebviewProvider implements WebviewProvider {
@debug() @debug()
private async notifyDidChangeColumns() { private async notifyDidChangeColumns() {
if (!this.host.isReady || !this.host.visible) {
if (!this.host.ready || !this.host.visible) {
this.addPendingIpcNotification(DidChangeColumnsNotificationType); this.addPendingIpcNotification(DidChangeColumnsNotificationType);
return false; return false;
} }
@ -1196,7 +1196,7 @@ export class GraphWebviewProvider implements WebviewProvider {
@debug() @debug()
private async notifyDidChangeRefsVisibility() { private async notifyDidChangeRefsVisibility() {
if (!this.host.isReady || !this.host.visible) {
if (!this.host.ready || !this.host.visible) {
this.addPendingIpcNotification(DidChangeRefsVisibilityNotificationType); this.addPendingIpcNotification(DidChangeRefsVisibilityNotificationType);
return false; return false;
} }
@ -1210,7 +1210,7 @@ export class GraphWebviewProvider implements WebviewProvider {
@debug() @debug()
private async notifyDidChangeConfiguration() { private async notifyDidChangeConfiguration() {
if (!this.host.isReady || !this.host.visible) {
if (!this.host.ready || !this.host.visible) {
this.addPendingIpcNotification(DidChangeGraphConfigurationNotificationType); this.addPendingIpcNotification(DidChangeGraphConfigurationNotificationType);
return false; return false;
} }
@ -1222,7 +1222,7 @@ export class GraphWebviewProvider implements WebviewProvider {
@debug() @debug()
private async notifyDidFetch() { private async notifyDidFetch() {
if (!this.host.isReady || !this.host.visible) {
if (!this.host.ready || !this.host.visible) {
this.addPendingIpcNotification(DidFetchNotificationType); this.addPendingIpcNotification(DidFetchNotificationType);
return false; return false;
} }
@ -1257,7 +1257,7 @@ export class GraphWebviewProvider implements WebviewProvider {
@debug() @debug()
private async notifyDidChangeWorkingTree() { private async notifyDidChangeWorkingTree() {
if (!this.host.isReady || !this.host.visible) {
if (!this.host.ready || !this.host.visible) {
this.addPendingIpcNotification(DidChangeWorkingTreeNotificationType); this.addPendingIpcNotification(DidChangeWorkingTreeNotificationType);
return false; return false;
} }
@ -1269,7 +1269,7 @@ export class GraphWebviewProvider implements WebviewProvider {
@debug() @debug()
private async notifyDidChangeSelection() { private async notifyDidChangeSelection() {
if (!this.host.isReady || !this.host.visible) {
if (!this.host.ready || !this.host.visible) {
this.addPendingIpcNotification(DidChangeSelectionNotificationType); this.addPendingIpcNotification(DidChangeSelectionNotificationType);
return false; return false;
} }
@ -1281,7 +1281,7 @@ export class GraphWebviewProvider implements WebviewProvider {
@debug() @debug()
private async notifyDidChangeSubscription() { private async notifyDidChangeSubscription() {
if (!this.host.isReady || !this.host.visible) {
if (!this.host.ready || !this.host.visible) {
this.addPendingIpcNotification(DidChangeSubscriptionNotificationType); this.addPendingIpcNotification(DidChangeSubscriptionNotificationType);
return false; return false;
} }
@ -1295,7 +1295,7 @@ export class GraphWebviewProvider implements WebviewProvider {
@debug() @debug()
private async notifyDidChangeState() { private async notifyDidChangeState() {
if (!this.host.isReady || !this.host.visible) {
if (!this.host.ready || !this.host.visible) {
this.addPendingIpcNotification(DidChangeNotificationType); this.addPendingIpcNotification(DidChangeNotificationType);
return false; return false;
} }

+ 2
- 2
src/plus/webviews/timeline/timelineWebview.ts View File

@ -396,7 +396,7 @@ export class TimelineWebviewProvider implements WebviewProvider {
@debug() @debug()
private updateState(immediate: boolean = false) { private updateState(immediate: boolean = false) {
if (!this.host.isReady || !this.host.visible) return;
if (!this.host.ready || !this.host.visible) return;
if (this._pendingContext == null && this.host.isView()) { if (this._pendingContext == null && this.host.isView()) {
this.updatePendingEditor(window.activeTextEditor); this.updatePendingEditor(window.activeTextEditor);
@ -416,7 +416,7 @@ export class TimelineWebviewProvider implements WebviewProvider {
@debug() @debug()
private async notifyDidChangeState() { private async notifyDidChangeState() {
if (!this.host.isReady || !this.host.visible) return false;
if (!this.host.ready || !this.host.visible) return false;
this._notifyDidChangeStateDebounced?.cancel(); this._notifyDidChangeStateDebounced?.cancel();
if (this._pendingContext == null) return false; if (this._pendingContext == null) return false;

+ 2
- 2
src/webviews/commitDetails/commitDetailsWebview.ts View File

@ -674,7 +674,7 @@ export class CommitDetailsWebviewProvider implements WebviewProvider
private _notifyDidChangeStateDebounced: Deferrable<() => void> | undefined = undefined; private _notifyDidChangeStateDebounced: Deferrable<() => void> | undefined = undefined;
private updateState(immediate: boolean = false) { private updateState(immediate: boolean = false) {
if (!this.host.isReady || !this.host.visible) return;
if (!this.host.ready || !this.host.visible) return;
if (immediate) { if (immediate) {
void this.notifyDidChangeState(); void this.notifyDidChangeState();
@ -689,7 +689,7 @@ export class CommitDetailsWebviewProvider implements WebviewProvider
} }
private async notifyDidChangeState() { private async notifyDidChangeState() {
if (!this.host.isReady || !this.host.visible) return false;
if (!this.host.ready || !this.host.visible) return false;
const scope = getLogScope(); const scope = getLogScope();

+ 4
- 4
src/webviews/home/homeWebview.ts View File

@ -239,7 +239,7 @@ export class HomeWebviewProvider implements WebviewProvider {
} }
private notifyDidChangeData(subscription?: Subscription) { private notifyDidChangeData(subscription?: Subscription) {
if (!this.host.isReady) return false;
if (!this.host.ready) return false;
return window.withProgress({ location: { viewId: this.host.id } }, async () => { return window.withProgress({ location: { viewId: this.host.id } }, async () => {
const sub = await this.getSubscription(subscription); const sub = await this.getSubscription(subscription);
@ -255,7 +255,7 @@ export class HomeWebviewProvider implements WebviewProvider {
} }
private notifyExtensionEnabled() { private notifyExtensionEnabled() {
if (!this.host.isReady) return;
if (!this.host.ready) return;
void this.host.notify(DidChangeExtensionEnabledType, { void this.host.notify(DidChangeExtensionEnabledType, {
extensionEnabled: this.getExtensionEnabled(), extensionEnabled: this.getExtensionEnabled(),
@ -267,7 +267,7 @@ export class HomeWebviewProvider implements WebviewProvider {
} }
private notifyDidChangeConfiguration() { private notifyDidChangeConfiguration() {
if (!this.host.isReady) return;
if (!this.host.ready) return;
void this.host.notify(DidChangeConfigurationType, { void this.host.notify(DidChangeConfigurationType, {
plusEnabled: this.getPlusEnabled(), plusEnabled: this.getPlusEnabled(),
@ -280,7 +280,7 @@ export class HomeWebviewProvider implements WebviewProvider {
} }
private notifyDidChangeLayout() { private notifyDidChangeLayout() {
if (!this.host.isReady) return;
if (!this.host.ready) return;
void this.host.notify(DidChangeLayoutType, { layout: this.getLayout() }); void this.host.notify(DidChangeLayoutType, { layout: this.getLayout() });
} }

+ 1
- 1
src/webviews/settings/settingsWebview.ts View File

@ -16,7 +16,7 @@ export class SettingsWebviewProvider extends WebviewProviderWithConfigBase
): boolean | Promise<boolean> { ): boolean | Promise<boolean> {
const anchor = args[0]; const anchor = args[0];
if (anchor && typeof anchor === 'string') { if (anchor && typeof anchor === 'string') {
if (!loading && this.host.isReady && this.host.visible) {
if (!loading && this.host.ready && this.host.visible) {
queueMicrotask( queueMicrotask(
() => () =>
void this.host.notify(DidOpenAnchorNotificationType, { void this.host.notify(DidOpenAnchorNotificationType, {

+ 12
- 12
src/webviews/webviewController.ts View File

@ -123,10 +123,10 @@ export class WebviewController<
public readonly id: Descriptor['id']; public readonly id: Descriptor['id'];
private _isReady: boolean = false;
private _ready: boolean = false;
private _suspended: boolean = false; private _suspended: boolean = false;
get isReady() {
return this._isReady;
get ready() {
return this._ready;
} }
private readonly disposables: Disposable[] = []; private readonly disposables: Disposable[] = [];
@ -171,7 +171,7 @@ export class WebviewController<
this.provider.onFocusChanged?.(false); this.provider.onFocusChanged?.(false);
this.provider.onVisibilityChanged?.(false); this.provider.onVisibilityChanged?.(false);
this._isReady = false;
this._ready = false;
this._suspended = false; this._suspended = false;
this._onDidDispose.fire(); this._onDidDispose.fire();
@ -271,7 +271,7 @@ export class WebviewController<
this.provider.onRefresh?.(force); this.provider.onRefresh?.(force);
// Mark the webview as not ready, until we know if we are changing the html // Mark the webview as not ready, until we know if we are changing the html
this._isReady = false;
this._ready = false;
this._suspended = false; this._suspended = false;
const html = await this.getHtml(this.webview); const html = await this.getHtml(this.webview);
@ -282,7 +282,7 @@ export class WebviewController<
// If we aren't changing the html, mark the webview as ready again // If we aren't changing the html, mark the webview as ready again
if (this.webview.html === html) { if (this.webview.html === html) {
this._isReady = true;
this._ready = true;
return; return;
} }
@ -302,7 +302,7 @@ export class WebviewController<
switch (e.method) { switch (e.method) {
case WebviewReadyCommandType.method: case WebviewReadyCommandType.method:
onIpc(WebviewReadyCommandType, e, () => { onIpc(WebviewReadyCommandType, e, () => {
this._isReady = true;
this._ready = true;
this._suspended = false; this._suspended = false;
this.provider.onReady?.(); this.provider.onReady?.();
}); });
@ -349,12 +349,12 @@ export class WebviewController<
if (this.descriptor.webviewHostOptions?.retainContextWhenHidden !== true) { if (this.descriptor.webviewHostOptions?.retainContextWhenHidden !== true) {
if (visible) { if (visible) {
if (this._suspended) { if (this._suspended) {
this._isReady = true;
this._ready = true;
this._suspended = false; this._suspended = false;
this.provider.onReady?.(); this.provider.onReady?.();
} }
} else { } else {
this._isReady = false;
this._ready = false;
this._suspended = true; this._suspended = true;
} }
} }
@ -380,12 +380,12 @@ export class WebviewController<
if (this.descriptor.webviewHostOptions?.retainContextWhenHidden !== true) { if (this.descriptor.webviewHostOptions?.retainContextWhenHidden !== true) {
if (visible) { if (visible) {
if (this._suspended) { if (this._suspended) {
this._isReady = true;
this._ready = true;
this._suspended = false; this._suspended = false;
this.provider.onReady?.(); this.provider.onReady?.();
} }
} else { } else {
this._isReady = false;
this._ready = false;
this._suspended = true; this._suspended = true;
} }
} }
@ -476,7 +476,7 @@ export class WebviewController<
}, },
}) })
async postMessage(message: IpcMessage): Promise<boolean> { async postMessage(message: IpcMessage): Promise<boolean> {
if (!this._isReady) return Promise.resolve(false);
if (!this._ready) return Promise.resolve(false);
// It looks like there is a bug where `postMessage` can sometimes just hang infinitely. Not sure why, but ensure we don't hang // It looks like there is a bug where `postMessage` can sometimes just hang infinitely. Not sure why, but ensure we don't hang
const success = await Promise.race<boolean>([ const success = await Promise.race<boolean>([

+ 2
- 2
src/webviews/webviewsController.ts View File

@ -151,7 +151,7 @@ export class WebviewsController implements Disposable {
return { return {
id: descriptor.id, id: descriptor.id,
get ready() { get ready() {
return registration.controller?.isReady ?? false;
return registration.controller?.ready ?? false;
}, },
get visible() { get visible() {
return registration.controller?.visible ?? false; return registration.controller?.visible ?? false;
@ -246,7 +246,7 @@ export class WebviewsController implements Disposable {
return { return {
id: descriptor.id, id: descriptor.id,
get ready() { get ready() {
return registration.controller?.isReady ?? false;
return registration.controller?.ready ?? false;
}, },
get visible() { get visible() {
return registration.controller?.visible ?? false; return registration.controller?.visible ?? false;

Loading…
Cancel
Save