Skip to content

Commit

Permalink
feat(macos-document-handling): implement representedFilename API (#907)
Browse files Browse the repository at this point in the history
  • Loading branch information
2xAA authored May 4, 2024
1 parent edb4d7b commit 6fb56ed
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 19 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test:e2e": "npx playwright test"
},
"dependencies": {
"@electron/remote": "^2.0.4",
"@electron/remote": "^2.1.2",
"animated-gif-detector": "^1.2.0",
"animejs": "3.2.1",
"canvas-text-wrapper": "github:cyberj/canvas-text-wrapper#master",
Expand Down Expand Up @@ -79,7 +79,7 @@
"babel-eslint": "^10.0.3",
"babel-loader": "^9.1.2",
"core-js": "^3.19.1",
"electron": "25.1.1",
"electron": "29.1.5",
"electron-builder": "^22.9.1",
"electron-notarize": "^1.2.2",
"electron-playwright-helpers": "^1.5.3",
Expand Down Expand Up @@ -109,4 +109,4 @@
"resolutions": {
"electron-builder": "23.0.2"
}
}
}
3 changes: 1 addition & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>modV</title>
</head>

<body>
Expand All @@ -20,4 +19,4 @@
<!-- built files will be auto injected -->
</body>

</html>
</html>
7 changes: 7 additions & 0 deletions src/background/menu-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ async function save(filePath) {
} catch (e) {
console.error(e);
}

windows["mainWindow"].setRepresentedFilename(lastFileSavedPath);
windows["mainWindow"].setDocumentEdited(false);
windows["mainWindow"].setTitle(path.basename(lastFileSavedPath));
}

async function writePresetToFile(filePath) {
Expand Down Expand Up @@ -99,6 +103,9 @@ export function generateMenuTemplate() {
if (!result.canceled) {
const filePath = result.filePaths[0];
openFile(filePath);
windows["mainWindow"].setRepresentedFilename(filePath);
windows["mainWindow"].setDocumentEdited(false);
windows["mainWindow"].setTitle(path.basename(filePath));
}
}
},
Expand Down
6 changes: 6 additions & 0 deletions src/background/window-prefs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { app, dialog, ipcMain, screen, BrowserWindow } from "electron";
import os from "node:os";

import store from "../media-manager/store";
import { autoUpdater } from "electron-updater";
Expand Down Expand Up @@ -81,6 +82,10 @@ const windowPrefs = {

ipcMain.handle("is-modv-ready", () => modVReady);

window.setRepresentedFilename(os.homedir());
window.setDocumentEdited(true);
window.setTitle("Untitled");

// Configure child windows to open without a menubar (windows/linux)
window.webContents.on(
"new-window",
Expand Down Expand Up @@ -189,6 +194,7 @@ const windowPrefs = {
ipcMain.removeAllListeners("save-file");
ipcMain.removeAllListeners("current-project");
ipcMain.removeAllListeners("input-update");
ipcMain.removeHandler("is-modv-ready");
}
},

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/spec/general/rendersTheMainWindow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ test("renders the main window", async () => {
const { page } = modVApp;

const title = await page.title();
expect(title).toBe("modV");
expect(title).toBe("Untitled");
});
33 changes: 20 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1077,10 +1077,10 @@
optionalDependencies:
global-agent "^3.0.0"

"@electron/remote@^2.0.4":
version "2.0.10"
resolved "https://registry.yarnpkg.com/@electron/remote/-/remote-2.0.10.tgz#133e2f607b1861ac249bd78b5abd1e961feed713"
integrity sha512-3SFKKaQXcyWgwmibud+UqJl/XlHOgLcI3fwtB9pNelPSJAcTxocOJrF6FaxBIQaj1+R05Di6xuAswZpXAW7xhA==
"@electron/remote@^2.1.2":
version "2.1.2"
resolved "https://registry.yarnpkg.com/@electron/remote/-/remote-2.1.2.tgz#52a97c8faa5b769155b649ef262f2f8c851776e6"
integrity sha512-EPwNx+nhdrTBxyCqXt/pftoQg/ybtWDW3DUWHafejvnB1ZGGfMpv6e15D8KeempocjXe78T7WreyGGb3mlZxdA==

"@electron/universal@1.0.5":
version "1.0.5"
Expand Down Expand Up @@ -1535,10 +1535,12 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.3.0.tgz#719498898d5defab83c3560f45d8498f58d11938"
integrity sha512-cumHmIAf6On83X7yP+LrsEyUOf/YlociZelmpRYaGFydoaPdxdt80MAbu6vWerQT2COCp2nPvHdsbD7tHn/YlQ==

"@types/node@^18.11.18":
version "18.16.18"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.16.18.tgz#85da09bafb66d4bc14f7c899185336d0c1736390"
integrity sha512-/aNaQZD0+iSBAGnvvN2Cx92HqE5sZCPZtx2TsK+4nvV23fFe09jVDvpArXr2j9DnYlzuU9WuoykDDc6wqvpNcw==
"@types/node@^20.9.0":
version "20.11.30"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.11.30.tgz#9c33467fc23167a347e73834f788f4b9f399d66f"
integrity sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==
dependencies:
undici-types "~5.26.4"

"@types/normalize-package-data@^2.4.0":
version "2.4.1"
Expand Down Expand Up @@ -5141,13 +5143,13 @@ electron-updater@^4.3.1:
lodash.isequal "^4.5.0"
semver "^7.3.5"

electron@25.1.1:
version "25.1.1"
resolved "https://registry.yarnpkg.com/electron/-/electron-25.1.1.tgz#b7aaf0d66a56fbbbad987c13cee108642f63bd50"
integrity sha512-WvFUfVsJn6YiP35UxdibYVjU2LceastyMm4SVp2bmb4XvKEvItAIiwxgm7tPC5Syl1243aRCvQLqr84sZ71pyQ==
electron@29.1.5:
version "29.1.5"
resolved "https://registry.yarnpkg.com/electron/-/electron-29.1.5.tgz#b745b4d201c1ac9f84d6aa034126288dde34d5a1"
integrity sha512-1uWGRw/ffA62lcrklxGUgVxVtOHojsg/nwsYr+/F9cVjipZJn8iPv/ABGIIexhmUqWcho8BqfTJ4osCBa29gBg==
dependencies:
"@electron/get" "^2.0.0"
"@types/node" "^18.11.18"
"@types/node" "^20.9.0"
extract-zip "^2.0.1"

elegant-spinner@^1.0.1:
Expand Down Expand Up @@ -12777,6 +12779,11 @@ unbox-primitive@^1.0.2:
has-symbols "^1.0.3"
which-boxed-primitive "^1.0.2"

undici-types@~5.26.4:
version "5.26.5"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==

unicode-canonical-property-names-ecmascript@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz#301acdc525631670d39f6146e0e77ff6bbdebddc"
Expand Down

0 comments on commit 6fb56ed

Please sign in to comment.