Browse Source

Fixes state not being restored on Home webview

main
Eric Amodio 1 year ago
parent
commit
ec5beb905c
4 changed files with 26 additions and 12 deletions
  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 View File

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

+ 5
- 0
src/webviews/apps/home/home.ts View File

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

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

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

+ 15
- 11
src/webviews/home/homeWebview.ts View File

@ -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 steps = this.container.storage.get('home:steps:completed', []);
const hasStep = steps.includes(id); const hasStep = steps.includes(id);
@ -149,31 +149,35 @@ export class HomeWebviewProvider implements WebviewProvider {
} else if (hasStep && !completed) { } else if (hasStep && !completed) {
steps.splice(steps.indexOf(id), 1); 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', []); 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); 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', []); const banners = this.container.storage.get('home:banners:dismissed', []);
if (!banners.includes(params.id)) { if (!banners.includes(params.id)) {
banners.push(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> { includeBootstrap(): Promise<State> {

Loading…
Cancel
Save