Ver código fonte

Fixes state not being restored on Home webview

main
Eric Amodio 1 ano atrás
pai
commit
ec5beb905c
4 arquivos alterados com 26 adições e 12 exclusões
  1. +4
    -1
      src/webviews/apps/commitDetails/commitDetails.ts
  2. +5
    -0
      src/webviews/apps/home/home.ts
  3. +2
    -0
      src/webviews/apps/plus/timeline/timeline.ts
  4. +15
    -11
      src/webviews/home/homeWebview.ts

+ 4
- 1
src/webviews/apps/commitDetails/commitDetails.ts Ver arquivo

@ -53,7 +53,7 @@ export class CommitDetailsApp extends App> {
}
override onInitialize() {
this.log(`onInitialize()`);
this.state = this.getState() ?? this.state;
this.renderContent();
}
@ -117,6 +117,8 @@ export class CommitDetailsApp extends App> {
// // }
// this.state = newState;
// this.setState(this.state);
// this.renderRichContent();
// });
// break;
@ -125,6 +127,7 @@ export class CommitDetailsApp extends App> {
assertsSerialized<typeof params.state>(params.state);
this.state = params.state;
this.setState(this.state);
this.renderContent();
});
break;

+ 5
- 0
src/webviews/apps/home/home.ts Ver arquivo

@ -44,6 +44,7 @@ export class HomeApp extends App {
this.$steps = [...document.querySelectorAll<SteppedSection>('stepped-section[id]')];
this.$cards = [...document.querySelectorAll<CardSection>('card-section[id]')];
this.state = this.getState() ?? this.state;
this.updateState();
}
@ -92,6 +93,7 @@ export class HomeApp extends App {
this.state.completedActions = params.completedActions;
this.state.avatar = params.avatar;
this.state.pinStatus = params.pinStatus;
this.setState(this.state);
this.updateState();
});
break;
@ -100,6 +102,7 @@ export class HomeApp extends App {
onIpc(DidChangeRepositoriesType, msg, params => {
this.state.repositories = { ...params };
this.setState(this.state);
this.updateNoRepo();
});
break;
@ -108,6 +111,7 @@ export class HomeApp extends App {
onIpc(DidChangeConfigurationType, msg, params => {
this.state.plusEnabled = params.plusEnabled;
this.setState(this.state);
this.updatePlusContent();
});
break;
@ -116,6 +120,7 @@ export class HomeApp extends App {
onIpc(DidChangeLayoutType, msg, params => {
this.state.layout = params.layout;
this.setState(this.state);
this.updateLayout();
});
break;

+ 2
- 0
src/webviews/apps/plus/timeline/timeline.ts Ver arquivo

@ -27,6 +27,7 @@ export class TimelineApp extends App {
protected override onInitialize() {
provideVSCodeDesignSystem().register(vsCodeButton(), vsCodeDropdown(), vsCodeOption());
this.state = this.getState() ?? this.state;
this.updateState();
}
@ -53,6 +54,7 @@ export class TimelineApp extends App {
onIpc(DidChangeNotificationType, msg, params => {
this.state = params.state;
this.setState(this.state);
this.updateState();
});
break;

+ 15
- 11
src/webviews/home/homeWebview.ts Ver arquivo

@ -140,7 +140,7 @@ export class HomeWebviewProvider implements WebviewProvider {
}
}
private completeStep({ id, completed = false }: CompleteStepParams) {
private async completeStep({ id, completed = false }: CompleteStepParams) {
const steps = this.container.storage.get('home:steps:completed', []);
const hasStep = steps.includes(id);
@ -149,31 +149,35 @@ export class HomeWebviewProvider implements WebviewProvider {
} else if (hasStep && !completed) {
steps.splice(steps.indexOf(id), 1);
}
void this.container.storage.store('home:steps:completed', steps);
await this.container.storage.store('home:steps:completed', steps);
void this.notifyDidChangeData();
}
private dismissSection(params: DismissSectionParams) {
private async dismissSection(params: DismissSectionParams) {
const sections = this.container.storage.get('home:sections:dismissed', []);
if (sections.includes(params.id)) {
return;
}
if (sections.includes(params.id)) return;
sections.push(params.id);
void this.container.storage.store('home:sections:dismissed', sections);
await this.container.storage.store('home:sections:dismissed', sections);
void this.notifyDidChangeData();
}
private dismissBanner(params: DismissBannerParams) {
private async dismissBanner(params: DismissBannerParams) {
const banners = this.container.storage.get('home:banners:dismissed', []);
if (!banners.includes(params.id)) {
banners.push(params.id);
}
void this.container.storage.store('home:banners:dismissed', banners);
await this.container.storage.store('home:banners:dismissed', banners);
void this.notifyDidChangeData();
}
private dismissPinStatus() {
void this.container.storage.store('home:status:pinned', false);
private async dismissPinStatus() {
await this.container.storage.store('home:status:pinned', false);
void this.notifyDidChangeData();
}
includeBootstrap(): Promise<State> {

Carregando…
Cancelar
Salvar