π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Use 1
Manav Rathib365e03acd86
diff --git a/desktop/src/main.ts b/desktop/src/main.tsindex 8a43b01a30..d733ce69e6 100644--- a/desktop/src/main.ts+++ b/desktop/src/main.ts@@ -143,12 +143,16 @@ const registerPrivilegedSchemes = () => {* This window will show the HTML served from {@link rendererURL}.*/const createMainWindow = () => {+ const rect = windowRect();+// Create the main window. This'll show our web content.const window = new BrowserWindow({webPreferences: {preload: path.join(__dirname, "preload.js"),sandbox: true,},+ // Set the window's position and size (if we have one saved).+ ...(rect ?? {}),// The color to show in the window until the web content gets loaded.// See: https://www.electronjs.org/docs/latest/api/browser-window#setting-the-backgroundcolor-propertybackgroundColor: "black",@@ -164,8 +168,10 @@ const createMainWindow = () => {// On macOS, also hide the dock icon on macOS.if (process.platform == "darwin") app.dock.hide();} else {- // Show our window (maximizing it) otherwise.- window.maximize();+ // Show our window otherwise.+ //+ // If we did not give it an explicit size, maximize it+ rect ? window.show() : window.maximize();}// Open the DevTools automatically when running in dev mode@@ -211,11 +217,74 @@ const createMainWindow = () => {return window;};+/**+ * Determine the position and size of our app's main window based on the+ * position and size of the window the last time around (if any).+ *+ * The saved size is compared to the current screen size to ensure we don't do+ * anything too wonky if say the user's screen size has changed since the last+ * time our app was running.+ *+ * If it doubt (and where there is no previous saved state), return `undefined`.+ * This should be taken to mean that the app's main window should be maximized.+ */+const windowRect = () => {+ return userPreferences.get("windowRect");+ // return undefined;+};++/**+ * On Linux the app does not show a dock icon by default, attempt to fix this by+ * returning the path to an icon as the "icon" property that can be passed to+ * the BrowserWindow during creation.+ */+const windowIconOptions = () => {+ if (process.platform != "linux") return {};++ // There are two, possibly three, different issues with icons on Linux.+ //+ // Firstly, the AppImage itself doesn't show an icon. There does not seem to+ // be a reasonable workaround either currently. See:+ // https://github.com/AppImage/AppImageKit/issues/346+ //+ // Secondly, and this is the problem we're trying to fix here, when the app+ // is started it does not show a dock icon (Ubuntu 22) or shows the generic+ // gear icon (Ubuntu 24). The issue possibly exists on other distributions+ // too.+ //+ // Electron provides a `BrowserWindow.setIcon` function which should solve+ // our issue, we could call it selectively on Linux. There is also an+ // apparently undocumented "icon" option that can be passed when creating a+ // new BrowserWindow, and that is what most of the other code I saw on+ // GitHub seems to be doing.+ //+ // However, try what I may, I can't get either of these to work. Which leads+ // me to believe there is a third issue: I can't get it to work because I'm+ // testing on an Ubuntu 24 VM, where this might just not be working:+ // https://askubuntu.com/questions/1511534/ubuntu-24-04-skype-logo-on-the-dock-not-showing-skype-logo+ //+ // 24 isn't likely the year of the Linux desktop either.+ //+ // For now, I'm adding a very specific incantation taken from+ // https://github.com/arduino/arduino-ide/blob/main/arduino-ide-extension/src/electron-main/fix-app-image-icon.ts+ //+ // Possibly all this specific naming of the file etc is superstition, and+ // just any name would do as long as the path is correct, but let me try it+ // this way and see if this gets the icon to appear on Ubuntu 22 etc.++ const icon = path.join(+ isDev ? "build" : process.resourcesPath,+ "icons/512x512.png",+ );++ return { icon };+};+/*** Automatically set the save path for user initiated downloads to the system's* "downloads" directory instead of asking the user to select a save location.*/-export const setDownloadPath = (webContents: WebContents) => {+const setDownloadPath = (webContents: WebContents) => {webContents.session.on("will-download", (_, item) => {item.setSavePath(uniqueSavePath(app.getPath("downloads"), item.getFilename()),@@ -243,7 +312,7 @@ const uniqueSavePath = (dirPath: string, fileName: string) => {** @param webContents The renderer to configure.*/-export const allowExternalLinks = (webContents: WebContents) =>+const allowExternalLinks = (webContents: WebContents) =>// By default, if the user were open a link, say// https://github.com/ente-io/ente/discussions, then it would open a _new_// BrowserWindow within our app.@@ -275,7 +344,7 @@ export const allowExternalLinks = (webContents: WebContents) =>* "Access-Control-Allow-Origin: *" or do a echo-back of `Origin`, we add a* workaround here instead, intercepting the ACAO header and allowing `*`.*/-export const allowAllCORSOrigins = (webContents: WebContents) =>+const allowAllCORSOrigins = (webContents: WebContents) =>webContents.session.webRequest.onHeadersReceived(({ responseHeaders }, callback) => {const headers: NonNullable<typeof responseHeaders> = {};@@ -315,53 +384,6 @@ const setupTrayItem = (mainWindow: BrowserWindow) => {tray.setContextMenu(createTrayContextMenu(mainWindow));};-/**- * On Linux the app does not show a dock icon by default, attempt to fix this by- * returning the path to an icon as the "icon" property that can be passed to- * the BrowserWindow during creation.- */-const windowIconOptions = () => {- if (process.platform != "linux") return {};-- // There are two, possibly three, different issues with icons on Linux.- //- // Firstly, the AppImage itself doesn't show an icon. There does not seem to- // be a reasonable workaround either currently. See:- // https://github.com/AppImage/AppImageKit/issues/346- //- // Secondly, and this is the problem we're trying to fix here, when the app- // is started it does not show a dock icon (Ubuntu 22) or shows the generic- // gear icon (Ubuntu 24). The issue possibly exists on other distributions- // too.- //- // Electron provides a `BrowserWindow.setIcon` function which should solve- // our issue, we could call it selectively on Linux. There is also an- // apparently undocumented "icon" option that can be passed when creating a- // new BrowserWindow, and that is what most of the other code I saw on- // GitHub seems to be doing.- //- // However, try what I may, I can't get either of these to work. Which leads- // me to believe there is a third issue: I can't get it to work because I'm- // testing on an Ubuntu 24 VM, where this might just not be working:- // https://askubuntu.com/questions/1511534/ubuntu-24-04-skype-logo-on-the-dock-not-showing-skype-logo- //- // 24 isn't likely the year of the Linux desktop either.- //- // For now, I'm adding a very specific incantation taken from- // https://github.com/arduino/arduino-ide/blob/main/arduino-ide-extension/src/electron-main/fix-app-image-icon.ts- //- // Possibly all this specific naming of the file etc is superstition, and- // just any name would do as long as the path is correct, but let me try it- // this way and see if this gets the icon to appear on Ubuntu 22 etc.-- const icon = path.join(- isDev ? "build" : process.resourcesPath,- "icons/512x512.png",- );-- return { icon };-};-/*** Older versions of our app used to maintain a cache dir using the main* process. This has been removed in favor of cache on the web layer. Delete the