Skip to content

Commit f90ee9c

Browse files
authored
Merge pull request #16 from hackthedev/beta
Beta
2 parents dc6914e + b9952f6 commit f90ee9c

54 files changed

Lines changed: 3300 additions & 2422 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.idea/.gitignore

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/dcts-client-shipping.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

electron/index.js

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,14 @@ if (!fs.existsSync(profilePath)) fs.mkdirSync(profilePath);
3535

3636

3737
let server = null
38+
let localServerUrl = null;
3839

3940
function startLocalServer() {
41+
// so this is needed because with file:// we get some shitty ass
42+
// issues. because i wrote this comment some time later i already forgot
43+
// the exact error, but it was shit like cors errors etc, which is resolved
44+
// by doing it this way.
45+
4046
return new Promise((resolve) => {
4147
const web = express()
4248
const publicDir = path.join(__dirname, "web")
@@ -48,7 +54,12 @@ function startLocalServer() {
4854

4955
server = web.listen(0, "127.0.0.1", () => {
5056
const { port } = server.address()
51-
resolve(`http://127.0.0.1:${port}`)
57+
let address = `http://127.0.0.1:${port}`;
58+
59+
// used later
60+
localServerUrl = address;
61+
62+
resolve(address)
5263
})
5364
})
5465
}
@@ -78,11 +89,15 @@ function registerWindowBoundsPersistence(win) {
7889
}
7990

8091
async function createWindow(width, height) {
92+
let localUrl = await startLocalServer();
93+
8194
// installing multiple packages
8295
const results = await FrontendLibs.installMultiple([
8396
{ package: '@hackthedev/icons@latest', path: libDir },
97+
{ package: '@hackthedev/element-loader@latest', path: libDir },
8498
{ package: '@hackthedev/mobile-ui@latest', path: libDir },
8599
{ package: '@hackthedev/prompts@latest', path: libDir },
100+
{ package: '@hackthedev/file-manager', path: libDir },
86101
{ package: '@hackthedev/rich-editor', path: libDir },
87102
{ package: '@hackthedev/json-editor', path: libDir },
88103
{ package: '@hackthedev/chat-tools@1.0.0', path: libDir },
@@ -111,7 +126,10 @@ async function createWindow(width, height) {
111126
sandbox: false,
112127
devTools: true,
113128
webviewTag: true,
114-
additionalArguments: ["--appdata=" + applicationDataDir],
129+
additionalArguments: [
130+
"--appdata=" + applicationDataDir,
131+
"--localServerUrl=" + localServerUrl,
132+
],
115133
},
116134
});
117135

@@ -139,7 +157,6 @@ async function createWindow(width, height) {
139157
}
140158
)
141159

142-
let localUrl = await startLocalServer();
143160
await win.loadURL(localUrl)
144161
//win.loadFile(path.join(__dirname, "web/index.html"));
145162
}
@@ -172,6 +189,8 @@ app.commandLine.appendSwitch(
172189

173190
app.whenReady().then(async () => {
174191
// Check for fucking update
192+
193+
/* Commented out for now as it needs a bit more work to work fine with linux too etc
175194
let updateCheck = await AppUpdater.check("https://dcts.community/app/electron", {
176195
includeOsUrl: true,
177196
version: app.getVersion()
@@ -226,10 +245,13 @@ app.whenReady().then(async () => {
226245
}
227246
}
228247
248+
*/
249+
229250

230251
await Settings.initSettings(applicationDataDir);
231252

232-
// youtube embed fix — header spoofing
253+
// youtube embed fix - header spoofing or some shit.
254+
// it semi works?? still need to figure this shit out more
233255
session.defaultSession.webRequest.onBeforeSendHeaders(
234256
{ urls: ['*://*.youtube-nocookie.com/*', '*://*.youtube.com/*', '*://*.googlevideo.com/*', '*://*.ytimg.com/*'] },
235257
(details, callback) => {
@@ -242,13 +264,19 @@ app.whenReady().then(async () => {
242264
const primaryDisplay = screen.getPrimaryDisplay();
243265
const {width, height} = primaryDisplay.workAreaSize;
244266

245-
session.defaultSession.setDisplayMediaRequestHandler((request, callback) => {
246-
desktopCapturer
247-
.getSources({types: ["window", "screen"]})
248-
.then((sources) => {
249-
callback({video: sources[0]});
250-
});
251-
})
267+
// until there is a better solution.
268+
// i had the idea of possibly adding some display fetching and selecting inside
269+
// the web frontend itself to then just tell the backend (electron) which screen
270+
// to use exactly. Just some idea for now tho.
271+
if(isLinux){
272+
session.defaultSession.setDisplayMediaRequestHandler((request, callback) => {
273+
desktopCapturer
274+
.getSources({types: ["window", "screen"]})
275+
.then((sources) => {
276+
callback({video: sources[0]});
277+
});
278+
})
279+
}
252280

253281
await createWindow(
254282
1080,

electron/modules/DeleteChat.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import Settings from "./settings.js";
2+
3+
export const DeleteChat = async ({ signer, applicationDataDir }, chatId) => {
4+
if(!chatId) throw new Error("chatId must be provided");
5+
return await Settings.Message.deleteChat(chatId)
6+
}

electron/modules/ExportKey.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
export const ExportKey = async ({ signer, applicationDataDir }, code) => {
3+
if(!code || code?.length < 24) throw new Error("Export code is not secure enough!");
4+
5+
let privateKey = await signer.getPrivateKey();
6+
let encrypted = await signer.encrypt(privateKey, code);
7+
privateKey = null;
8+
9+
return encrypted
10+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
export const GetLocalServerAddress = async ({ signer, applicationDataDir, localServerUrl }) => {
3+
return localServerUrl;
4+
}

electron/modules/GetSignature.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Settings from "./settings.js";
2+
3+
export const GetSignature = async ({ signer, applicationDataDir }) => {
4+
return await Settings.settings?.user?.signature ?? null;
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Settings from "./settings.js";
2+
3+
export const GetUnreadChats = async ({ signer, applicationDataDir }) => {
4+
return await Settings.Message.getChatsUnread();
5+
}

0 commit comments

Comments
 (0)