mirror of
https://github.com/Vencord/Vesktop.git
synced 2025-02-23 13:45:09 +00:00
fix: excessive connection creation
apparently causes crashes but i cant repro :p #517 should have this same issue so will need this same fix, which is why its in util :3
This commit is contained in:
parent
cab6ba5e70
commit
9716ff4b1d
2 changed files with 19 additions and 2 deletions
|
@ -4,11 +4,12 @@
|
||||||
* Copyright (c) 2023 Vendicated and Vencord contributors
|
* Copyright (c) 2023 Vendicated and Vencord contributors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import dbus from "@homebridge/dbus-native";
|
|
||||||
import { app, NativeImage, nativeImage } from "electron";
|
import { app, NativeImage, nativeImage } from "electron";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import { BADGE_DIR } from "shared/paths";
|
import { BADGE_DIR } from "shared/paths";
|
||||||
|
|
||||||
|
import { dbus, getSessionBus } from "./utils/dbus";
|
||||||
|
|
||||||
const imgCache = new Map<number, NativeImage>();
|
const imgCache = new Map<number, NativeImage>();
|
||||||
function loadBadge(index: number) {
|
function loadBadge(index: number) {
|
||||||
const cached = imgCache.get(index);
|
const cached = imgCache.get(index);
|
||||||
|
@ -29,7 +30,7 @@ export function setBadgeCount(count: number) {
|
||||||
throw new Error("count must be a number"); // sanitize
|
throw new Error("count must be a number"); // sanitize
|
||||||
}
|
}
|
||||||
|
|
||||||
const sessionBus = dbus.sessionBus();
|
const sessionBus = getSessionBus();
|
||||||
sessionBus.connection.message({
|
sessionBus.connection.message({
|
||||||
type: dbus.messageType.signal,
|
type: dbus.messageType.signal,
|
||||||
serial: 1,
|
serial: 1,
|
||||||
|
|
16
src/main/utils/dbus.ts
Normal file
16
src/main/utils/dbus.ts
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
* SPDX-License-Identifier: GPL-3.0
|
||||||
|
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
|
||||||
|
* Copyright (c) 2023 Vendicated and Vencord contributors
|
||||||
|
*/
|
||||||
|
|
||||||
|
import dbus from "@homebridge/dbus-native";
|
||||||
|
|
||||||
|
let sessionBus: dbus.MessageBus | null;
|
||||||
|
|
||||||
|
export function getSessionBus(): dbus.MessageBus {
|
||||||
|
if (!sessionBus) sessionBus = dbus.sessionBus();
|
||||||
|
return sessionBus;
|
||||||
|
}
|
||||||
|
|
||||||
|
export { dbus };
|
Loading…
Add table
Reference in a new issue