Alex313031 / ArmCord-Win7

ArmCord is a custom client designed to enhance your Discord experience while keeping everything lightweight. Windows 7/8/8.1 builds.
https://github.com/Alex313031/ArmCord-Win7
Open Software License 3.0
18 stars 1 forks source link

Missing ping count at the beginning of window #5

Closed K4sum1 closed 4 months ago

K4sum1 commented 4 months ago

So this was a bug with ArmCord post 3.2.1 that somehow still hasn't been fixed. Doubt it will be fixed officially since it's still a problem, so I will contribute it here.

Inside app.asar/ts-out/window.js there is a bit of code that is supposed to add the ArmCord title to the window, this only fires if the dynamic tray icon is used for some reason. This code is bugged and removes the ping count from the title bar. The fix is to replace this bit of code.

        if (await (0, utils_1.getConfig)("dynamicIcon")) {
            exports.mainWindow.setIcon(trayPath);
        }
    });
    exports.mainWindow.webContents.on("page-title-updated", async (e, title) => {
        const armCordSuffix = " - ArmCord"; /* identify */
        if (!title.endsWith(armCordSuffix)) {
            e.preventDefault();
            await exports.mainWindow.webContents.executeJavaScript(`document.title = '${(title.split(" | ")[1] ?? title) + armCordSuffix}'`);
        }
    });
}
const userDataPath = electron_1.app.getPath("userData");
const themesFolder = `${userDataPath}/themes/`;

with this

        if (await (0, utils_1.getConfig)("dynamicIcon")) {
            exports.mainWindow.setIcon(trayPath);
        }
    });
}
exports.mainWindow.webContents.on("page-title-updated", async (e, title) => {
    const armCordSuffix = " - ArmCord"; 
    if (!title.endsWith(armCordSuffix)) {
        e.preventDefault();
        var prefix = title.split(" | ")[1] ? title.split(" | ")[0].replace("Discord", "").replace(" ", "")+" " : "";
        await exports.mainWindow.webContents.executeJavaScript(`document.title = '${prefix +(title.split(" | ")[1] ?? title) + armCordSuffix}'`);
    }
});
const userDataPath = electron_1.app.getPath("userData");
const themesFolder = `${userDataPath}/themes/`;
smartfrigde commented 4 months ago

https://github.com/ArmCord/ArmCord/commit/052ef80e061953272821bd23d97a8a242b37ae6e fixed upstream here.

So this was a bug with ArmCord post 3.2.1 that somehow still hasn't been fixed

I honestly didn't know about this, if you reported this anywhere I must've missed it lol

K4sum1 commented 4 months ago

Huh idk then. Fairly certain I would've reported it but idk. Your fix looks a lot simpler but still only fires with dynamic tray icon. Is there a reason for that?

smartfrigde commented 4 months ago

https://github.com/ArmCord/ArmCord/commit/a532cb9a72aaa3f6365561849ac55fdef605f088 Fixed that too, thanks :)

K4sum1 commented 4 months ago

Could you give an app.asar? I would like to try here assuming replacing it just works.

Edit: I just realized it's probably better if I made it myself. I'll do that in a bit.

K4sum1 commented 4 months ago

So I manually applied it and it worked woo. I tried just pasting in the commit, but ArmCord just wouldn't open. So I manually applied it keeping the same formatting and whatever and it worked.

The fix now is this since it seems to be an older format here idk why.

        if (await (0, utils_1.getConfig)("dynamicIcon")) {
            exports.mainWindow.setIcon(trayPath);
        }
    });
}
exports.mainWindow.webContents.on("page-title-updated", async (e, title) => {
    const armCordSuffix = " - ArmCord"; /* identify */
    if (!title.endsWith(armCordSuffix)) {
        e.preventDefault();
        await exports.mainWindow.webContents.executeJavaScript(`document.title = '${title.replace("Discord |", "") + armCordSuffix}'`);
    }
});
const userDataPath = electron_1.app.getPath("userData");
const themesFolder = `${userDataPath}/themes/`;
Alex313031 commented 4 months ago

@K4sum1 Rebasing on latest version which will have this fix.

Also @smartfrigde I noticed the new "win7" branch. Did you make that because of this repo?

Also in src/preload/settings.ts, instead of setting the :any type for webviewtag, the proper way (and also guarantees it will work), is to replace import {WebviewTag} from "electron"; with type WebviewTag = Electron.WebviewTag;

The reason is that this is a bug in Electron 21, 22, and 23, where although Electron has the webviewtag, the .d.ts definitions do not export it, so Typescript thinks it doesn't exist and gives errors about it being an implicit any type.

After looking through Electron's github issues, this is the fix they recommend.

smartfrigde commented 4 months ago

@Alex313031 Huge chunk of Windows ArmCord users are still running Win7/8.1 (I ran a poll on the Discord recently). And since I'm getting back into ArmCord development I decided to officially pick up legacy windows support again. You're welcome to contribute to the win7 branch on the main repo. I still haven't decided if I wanna base that branch on stable or semi-regularly on devbuilds.

Thanks for maintaining this repo though! I hope you didn't really suffer much with my spaghetti code

Alex313031 commented 4 months ago

@K4sum1 https://github.com/Alex313031/ArmCord-Win7/releases/tag/v3.3.3

K4sum1 commented 4 months ago

It works, thanks

Also check out roytam1's issue in Throium-Legacy pls.