Fix native open dialogs and attach the save packed content window as a modal
This commit is contained in:
parent
aa55072323
commit
3eb9105daa
|
@ -16,7 +16,7 @@ import { remote } from 'electron';
|
|||
import Content from './content';
|
||||
import Globals from './globals';
|
||||
import Database from './database';
|
||||
import { Utils, FileUtils, ClientLogger as Logger } from 'common';
|
||||
import { Utils, FileUtils, ClientLogger as Logger, ClientIPC } from 'common';
|
||||
import { SettingsSet, ErrorEvent } from 'structs';
|
||||
import { Modals } from 'ui';
|
||||
import Combokeys from 'combokeys';
|
||||
|
@ -73,23 +73,23 @@ export default class {
|
|||
}
|
||||
|
||||
static async packContent(path, contentPath) {
|
||||
return new Promise((resolve, reject) => {
|
||||
remote.dialog.showSaveDialog({
|
||||
title: 'Save Package',
|
||||
defaultPath: path,
|
||||
filters: [
|
||||
{
|
||||
name: 'BetterDiscord Package',
|
||||
extensions: ['bd']
|
||||
}
|
||||
]
|
||||
}, filepath => {
|
||||
if (!filepath) return;
|
||||
const filepath = await ClientIPC.send('bd-native-save', {
|
||||
title: 'Save Package',
|
||||
defaultPath: path,
|
||||
filters: [
|
||||
{
|
||||
name: 'BetterDiscord Package',
|
||||
extensions: ['bd']
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
asar.uncache(filepath);
|
||||
asar.createPackage(contentPath, filepath, () => {
|
||||
resolve(filepath);
|
||||
});
|
||||
if (!filepath) return;
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
asar.uncache(filepath);
|
||||
asar.createPackage(contentPath, filepath, () => {
|
||||
resolve(filepath);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -82,6 +82,12 @@ class Comms {
|
|||
});
|
||||
});
|
||||
|
||||
BDIpc.on('bd-native-save', (event, options) => {
|
||||
dialog.showSaveDialog(OriginalBrowserWindow.fromWebContents(event.ipcEvent.sender), options, filename => {
|
||||
event.reply(filename);
|
||||
});
|
||||
});
|
||||
|
||||
BDIpc.on('bd-compileSass', (event, options) => {
|
||||
if (typeof options.path === 'string' && typeof options.data === 'string') {
|
||||
options.data = `${options.data} @import '${options.path.replace(/\\/g, '\\\\').replace(/'/g, '\\\'')}';`;
|
||||
|
@ -196,6 +202,11 @@ class BrowserWindow extends OriginalBrowserWindow {
|
|||
}
|
||||
}
|
||||
|
||||
// Some Electron APIs depend on browserWindow.constructor being BrowserWindow
|
||||
Object.defineProperty(BrowserWindow.prototype, 'constructor', {
|
||||
value: OriginalBrowserWindow
|
||||
});
|
||||
|
||||
export class BetterDiscord {
|
||||
|
||||
get comms() { return this._comms ? this._comms : (this._commas = new Comms(this)); }
|
||||
|
|
Loading…
Reference in New Issue