Skip to content

Commit

Permalink
Merge pull request #1958 from googlefonts/more-view-controller
Browse files Browse the repository at this point in the history
Move export-as actions to view-controller
  • Loading branch information
justvanrossum authored Jan 16, 2025
2 parents 5c55b60 + 697337d commit 3a4921a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
18 changes: 17 additions & 1 deletion src/fontra/client/core/view-controller.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { registerAction } from "./actions.js";
import { Backend } from "./backend-api.js";
import { FontController } from "./font-controller.js";
import { getRemoteProxy } from "./remote.js";
Expand Down Expand Up @@ -32,6 +33,7 @@ export class ViewController {
);

await controller.start();
controller.afterStart();
return controller;
}

Expand All @@ -40,7 +42,21 @@ export class ViewController {
}

async start() {
console.error("ViewController.start() not implemented");
await this.fontController.initialize();
}

afterStart() {
for (const format of this.fontController.backendInfo.projectManagerFeatures[
"export-as"
] || []) {
registerAction(
`action.export-as.${format}`,
{
topic: "0035-action-topics.export-as",
},
(event) => this.fontController.exportAs({ format })
);
}
}

/**
Expand Down
13 changes: 1 addition & 12 deletions src/fontra/views/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,17 +625,6 @@ export class EditorController extends ViewController {
}

initActionsAfterStart() {
for (const format of this.fontController.backendInfo.projectManagerFeatures[
"export-as"
] || []) {
registerAction(
`action.export-as.${format}`,
{
topic: "0035-action-topics.export-as",
},
(event) => this.fontController.exportAs({ format })
);
}
if (this.fontController.backendInfo.features["find-glyphs-that-use-glyph"]) {
registerAction(
"action.find-glyphs-that-use",
Expand Down Expand Up @@ -773,7 +762,7 @@ export class EditorController extends ViewController {
}

async _start() {
await this.fontController.initialize();
await super.start();
const rootSubscriptionPattern = {};
for (const rootKey of this.fontController.getRootKeys()) {
rootSubscriptionPattern[rootKey] = null;
Expand Down
2 changes: 1 addition & 1 deletion src/fontra/views/fontinfo/fontinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class FontInfoController extends ViewController {
}

async start() {
await this.fontController.initialize();
await super.start();

const url = new URL(window.location);
this.selectedPanel = url.hash ? url.hash.slice(1) : "font-info-panel";
Expand Down
2 changes: 1 addition & 1 deletion src/fontra/views/fontoverview/fontoverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class FontOverviewController extends ViewController {
}

async _start() {
await this.fontController.initialize();
await super.start();

this.fontSources = await this.fontController.getSources();

Expand Down

0 comments on commit 3a4921a

Please sign in to comment.