This commit is contained in:
thororen1234 2024-10-14 19:33:17 -04:00
parent 75fac79ad1
commit deceb2ba97
13 changed files with 186 additions and 58 deletions

View file

@ -218,7 +218,8 @@ export default definePlugin({
// @ts-ignore Typescript will add userAgentData IMMEDIATELY
|| navigator.userAgentData?.brands?.find(b => b.brand === "Chromium" || b.brand === "Google Chrome")?.version
|| null;
} catch { // inb4 some stupid browser throws unsupported error for navigator.userAgentData, it's only in chromium
} catch {
// inb4 some stupid browser throws unsupported error for navigator.userAgentData, it's only in chromium
return null;
}
},

View file

@ -83,14 +83,16 @@ export default definePlugin({
const connectionSuccessful = await new Promise(res => setTimeout(() => res(ws.readyState === WebSocket.OPEN), 1000)); // check if open after 1s
if (!connectionSuccessful) {
showNotice("Failed to connect to arRPC, is it running?", "Retry", () => { // show notice about failure to connect, with retry/ignore
showNotice("Failed to connect to arRPC, is it running?", "Retry", () => {
// show notice about failure to connect, with retry/ignore
popNotice();
this.start();
});
return;
}
Toasts.show({ // show toast on success
Toasts.show({
// show toast on success
message: "Connected to arRPC",
type: Toasts.Type.SUCCESS,
id: Toasts.genId(),

View file

@ -84,19 +84,22 @@ export default definePlugin({
{
find: "this.renderArtisanalHack()",
replacement: [
{ // Fade in on layer
{
// Fade in on layer
match: /(?<=\((\i),"contextType",\i\.\i\);)/,
replace: "$1=$self.Layer;",
predicate: () => settings.store.disableFade
},
{ // Lazy-load contents
{
// Lazy-load contents
match: /createPromise:\(\)=>([^:}]*?),webpackId:"?\d+"?,name:(?!="CollectiblesShop")"[^"]+"/g,
replace: "$&,_:$1",
predicate: () => settings.store.eagerLoad
}
]
},
{ // For some reason standardSidebarView also has a small fade-in
{
// For some reason standardSidebarView also has a small fade-in
find: 'minimal:"contentColumnMinimal"',
replacement: [
{
@ -110,7 +113,8 @@ export default definePlugin({
],
predicate: () => settings.store.disableFade
},
{ // Load menu TOC eagerly
{
// Load menu TOC eagerly
find: "Messages.USER_SETTINGS_WITH_BUILD_OVERRIDE.format",
replacement: {
match: /(\i)\(this,"handleOpenSettingsContextMenu",.{0,100}?null!=\i&&.{0,100}?(await Promise\.all[^};]*?\)\)).*?,(?=\1\(this)/,
@ -118,7 +122,8 @@ export default definePlugin({
},
predicate: () => settings.store.eagerLoad
},
{ // Settings cog context menu
{
// Settings cog context menu
find: "Messages.USER_SETTINGS_ACTIONS_MENU_LABEL",
replacement: [
{

View file

@ -84,7 +84,8 @@ export default definePlugin({
});
},
getIdleTimeout() { // milliseconds, default is 6e5
getIdleTimeout() {
// milliseconds, default is 6e5
const { idleTimeout } = settings.store;
return idleTimeout === 0 ? Infinity : idleTimeout * 60000;
}

View file

@ -108,7 +108,8 @@ export default definePlugin({
// Old Discord Android clients have a delay of around 17 days
// This is a workaround for that
if (-delta >= DISCORD_KT_DELAY - 86400000) { // One day of padding for good measure
if (-delta >= DISCORD_KT_DELAY - 86400000) {
// One day of padding for good measure
isDiscordKotlin = detectDiscordKotlin;
delta += DISCORD_KT_DELAY;
}

View file

@ -135,7 +135,8 @@ function jumpIfOffScreen(channelId: string, messageId: string) {
function getNextMessage(isUp: boolean, isReply: boolean) {
let messages: Array<Message & { deleted?: boolean; }> = MessageStore.getMessages(SelectedChannelStore.getChannelId())._array;
if (!isReply) { // we are editing so only include own
if (!isReply) {
// we are editing so only include own
const meId = UserStore.getCurrentUser().id;
messages = messages.filter(m => m.author.id === meId);
}