Standardize FrontendMessage message names

This commit is contained in:
Keavon Chambers
2022-01-12 14:16:13 -08:00
parent ae829c63b4
commit 6c639270ae
17 changed files with 154 additions and 152 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
import { reactive, readonly } from "vue";
import { DisplayAboutGraphiteDialog } from "@/dispatcher/js-messages";
import { DisplayDialogAboutGraphite } from "@/dispatcher/js-messages";
import { EditorState } from "@/state/wasm-loader";
import { IconName } from "@/utilities/icons";
import { stripIndents } from "@/utilities/strip-indents";
@@ -106,7 +106,7 @@ export function createDialogState(editor: EditorState) {
};
// Run on creation
editor.dispatcher.subscribeJsMessage(DisplayAboutGraphiteDialog, () => onAboutHandler());
editor.dispatcher.subscribeJsMessage(DisplayDialogAboutGraphite, () => onAboutHandler());
return {
state: readonly(state),
+8 -13
View File
@@ -4,11 +4,10 @@ import { reactive, readonly } from "vue";
import {
DisplayConfirmationToCloseAllDocuments,
DisplayConfirmationToCloseDocument,
ExportDocument,
TriggerFileDownload,
FrontendDocumentDetails,
OpenDocumentBrowse,
SaveDocument,
SetActiveDocument,
TriggerFileUpload,
UpdateActiveDocument,
UpdateOpenDocumentsList,
} from "@/dispatcher/js-messages";
import { DialogState } from "@/state/dialog";
@@ -81,9 +80,9 @@ export function createDocumentsState(editor: EditorState, dialogState: DialogSta
state.documents = updateOpenDocumentList.open_documents;
});
editor.dispatcher.subscribeJsMessage(SetActiveDocument, (setActiveDocument) => {
editor.dispatcher.subscribeJsMessage(UpdateActiveDocument, (updateActiveDocument) => {
// Assume we receive a correct document id
const activeId = state.documents.findIndex((doc) => doc.id === setActiveDocument.document_id);
const activeId = state.documents.findIndex((doc) => doc.id === updateActiveDocument.document_id);
state.activeDocumentIndex = activeId;
});
@@ -95,18 +94,14 @@ export function createDocumentsState(editor: EditorState, dialogState: DialogSta
closeAllDocumentsWithConfirmation();
});
editor.dispatcher.subscribeJsMessage(OpenDocumentBrowse, async () => {
editor.dispatcher.subscribeJsMessage(TriggerFileUpload, async () => {
const extension = editor.rawWasm.file_save_suffix();
const data = await upload(extension);
editor.instance.open_document_file(data.filename, data.content);
});
editor.dispatcher.subscribeJsMessage(ExportDocument, (exportDocument) => {
download(exportDocument.name, exportDocument.document);
});
editor.dispatcher.subscribeJsMessage(SaveDocument, (saveDocument) => {
download(saveDocument.name, saveDocument.document);
editor.dispatcher.subscribeJsMessage(TriggerFileDownload, (triggerFileDownload) => {
download(triggerFileDownload.name, triggerFileDownload.document);
});
// Get the initial documents