Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

. #16

Merged
merged 103 commits into from
May 21, 2024
Merged

. #16

Changes from 1 commit
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
60e6fda
Resolve PluginSettings circular deps better
Nuckyz May 5, 2024
a090872
ImplicitRelationships: Properly test find
Nuckyz May 5, 2024
45c1e42
ReviewDB: Fix context menus being added to folders (#2416)
Faf4a May 5, 2024
61235ce
ImageLink: Fix embed showing in gifs (#2417)
Sqaaakoi May 5, 2024
ecf6af5
FakeNitro: Make disableEmbedPermissionCheck setting not private
Nuckyz May 6, 2024
72b1776
upgrade nodejs & pnpm to latest versions
Vendicated May 7, 2024
0e66c4a
Fix subscribing to plugin flux events twice
Nuckyz May 7, 2024
7584714
FakeNitro: Add custom notifications sound bypass
Nuckyz May 7, 2024
97acffa
fix useStateFromStores JSDoc
Vendicated May 7, 2024
799b903
Revert "messageLogger: fix niche bug ignoring edits when content is s…
Vendicated May 7, 2024
53dda32
BetterFolders: Fix broken patch
Nuckyz May 8, 2024
21d2019
improve SupportHelper
Vendicated May 8, 2024
e2dc9e7
new plugin WebScreenShareFixes: remove low stream bitrate limit (#2405)
catgirlcataclysm May 8, 2024
efca196
new plugin MessageLatency: indicator for other people's latency (#2353)
arHSM May 8, 2024
d3acd7e
new plugin ReplyTimestamp: show timestamps of replied messages (#2296)
Kyuuhachi May 8, 2024
1317222
feat(plugin): VoiceDownload (#2280)
puv May 8, 2024
5c78714
showHiddenThings: also show ModView & hidden discovery servers (#2415)
dolfies May 8, 2024
dd3b7e5
LastfmRichPresence: Add option to use album name as status name (#2400)
KK2-5 May 8, 2024
449f955
bump to v1.8.2
Vendicated May 8, 2024
6ad17ff
BetterFolders: Fix component erroring
Nuckyz May 8, 2024
b1cc67a
fix(BetterSettings): do not catch errors of other ui
Vendicated May 8, 2024
0251935
VoiceDownload: fix doing nothing on discord desktop app
Vendicated May 8, 2024
6bd0898
fix(SupportHelper): dont flag vencord web as externally updated
Vendicated May 8, 2024
840a8f1
CrashHandler: Increment timeout for trying to recover
Nuckyz May 8, 2024
a2acce5
BetterSettings: fix error handling crashing in some niche cases
Vendicated May 9, 2024
251ee32
new plugin ShowTimeoutDuration ~ shows how much longer a user's timeo…
Vendicated May 9, 2024
14e68d9
im the dumbest dumdum
Vendicated May 9, 2024
1a3a378
ErrorBoundary some more components
Nuckyz May 9, 2024
395b000
permissionsViewer: add role & user context menus to copy id (#2436)
PonyGirlDShadow May 11, 2024
fbaa4ad
XSOverlay: add settings for different notification types (#2055)
nyakowint May 11, 2024
6b88eac
messageLatency: fix grammar & add aliucord/kotlin client tooltip (#2426)
arHSM May 11, 2024
2eb8ba1
SilentTyping: add chat input context menu option to toggle (#2386)
ImBonana May 11, 2024
9b328da
ThemeAttributes: add data-author-username to messages (#2422)
OvercastWarmth May 11, 2024
207fe84
CustomRPC: show warning when game activity is disabled (#2245)
nin0-dev May 11, 2024
c55b0de
FakeNitro: Update description
Nuckyz May 11, 2024
cc5e39c
Dearrow: allow configuring which elements get dearrowd (#2414)
Faf4a May 11, 2024
b22bfc8
pronounDB: Update to API v2 (#2355)
EdVraz May 11, 2024
0f9acba
settingsSync: include date in filename for better sorting
Vendicated May 12, 2024
f21db5c
add Native settings implementation (#2346)
MachineMuse May 12, 2024
d650794
Plugin Settings: fix text overflow for long plugin names (#2383)
HAHALOSAH May 12, 2024
a993545
feat(Translate): add toggle for chat bar icon (#2418)
Cats1337 May 12, 2024
bbec51f
but here's the bumper (v1.8.3)
Vendicated May 12, 2024
5c7fa55
XSOverlay: Adjust message length timeout (#2445)
nyakowint May 12, 2024
fd7dafb
fix(MessageLatency): Adjust for Discord kotlin clients (#2443)
dolfies May 12, 2024
902b6bc
PinDMs: ErrorBoundary renderChannel
Nuckyz May 12, 2024
1f1c80c
ValidUser: fix crashing when viewing a valid-userd staff's profile
Vendicated May 13, 2024
f676581
ValidUser: fix rendering old mentions when message is edited
Vendicated May 13, 2024
59ee9c5
feat(ShowHiddenThings): Remove Discovery banned/NSFW filters (#2453)
dolfies May 13, 2024
9621dc7
EmoteCloner: allow cloning from reactions (#2458)
axiand May 14, 2024
bd6f9e6
fix(MutualGroupDMs): properly pass props (#2457)
aamiaa May 14, 2024
5d04953
FakeNitro: allow using subscription-locked emojis (#2456)
nakoyasha May 14, 2024
8921674
MessageLogger: use discord variables instead of hardcoded colors (#2428)
AnubisNekhet May 14, 2024
9dc8e4e
Properly ErrorBoundary recent changes
Nuckyz May 14, 2024
d4ebfc2
Make all RestAPI calls use Endpoints object
Nuckyz May 14, 2024
12376c6
fix settings ui on canary
Vendicated May 14, 2024
a54b55e
bump to v1.8.4
Vendicated May 14, 2024
719c614
fix Vencord Settings section being added multiple times
Vendicated May 14, 2024
d8b3869
ThemeAttributes: add larger avatar url variables to avatars (#2449)
BoardTM May 14, 2024
5232a85
new plugin NoServerEmoji ~ hides server emojis from autocomplete (#1787)
UlyssesZh May 14, 2024
81d3f5d
new plugin CtrlEnterSend (#1794)
UlyssesZh May 14, 2024
97dd56c
MoreUserTags: Add chat moderator tag (#2424)
eepyfemboi May 15, 2024
840d571
Fix BetterSettings & StartupTimings patch
Nuckyz May 15, 2024
0e4724e
Settings: remove obsolete patch; add redundancy & more useful dbg copy
Vendicated May 15, 2024
46801de
chore: tidy up suggested vscode extensions list (#2221)
mcpower May 15, 2024
1fea842
BetterFolders: Fix scrolling
Nuckyz May 15, 2024
4d57267
new plugin ValidReply ~ fix "Message could not be loaded" (#2337)
waresnew May 15, 2024
f4d6461
feat(plugins/openInApp) Add tidal support (#2404)
Aztup May 15, 2024
4da8b9a
PetPet: Fix Upload Image Option (#2461)
ScattrdBlade May 15, 2024
f74da73
feat: Allow finds to use regex (#2452)
Nuckyz May 15, 2024
54f58cd
Fix: Canonicalize regex finds
Nuckyz May 15, 2024
0460374
Fix: Plugins without start/stop function failing to stop/start (#2463)
waresnew May 16, 2024
c0c897f
extractAndLoadChunksLazy: Cache result to avoid searching factories e…
Nuckyz May 16, 2024
7b4ecff
feat(MessageLatency): Show milliseconds option (#2454)
rozbrajaczpoziomow May 16, 2024
09f8944
MessageLatency: Fix wrong constant & false positive
Nuckyz May 16, 2024
4281b7a
ShowTimeoutDuration: Simplify tooltip style, allow changing style wit…
Sqaaakoi May 16, 2024
fb19642
fix(readAllNotificationsButton): Mark threads as read (#2437)
PonyGirlDShadow May 16, 2024
cddc811
feat(ViewIcons): Group & User DMs icons support (#2464)
verticalsync May 16, 2024
c5e554e
ViewIcon: Replace regex find with string find
Nuckyz May 16, 2024
0c50e15
FakeNitro: Fix & rewrite emoji bypass patches
Nuckyz May 17, 2024
03d83e1
new plugin AutomodContext (#2290)
JohnyTheCarrot May 17, 2024
ffe1d7c
new plugin ReplaceGoogleSearch (#2450)
ImpishMoxxie May 17, 2024
6547cc1
FakeNitro: Fix attempting to bypass unicode emojis
Nuckyz May 17, 2024
60f8225
chore: Fix non standard plugin names
Nuckyz May 17, 2024
0b4b603
new plugin NoDefaultHangStatus (#2468)
D3SOX May 17, 2024
84e477f
Add missing README to new plugins
Nuckyz May 17, 2024
5fc6ba8
fix(replaceGoogleSearch): correct GitHub casing (#2471)
D3SOX May 17, 2024
54817ab
lastfmRPC: add setting to toggle "View Song" button (#2292)
Yumiro May 17, 2024
c3757a2
add package for publishing types to npm (#2473)
Vendicated May 17, 2024
8b0e703
ViewIcons: Fix Group Icons being clickable in channel list
Nuckyz May 17, 2024
4e92612
ResurrectHome: Likely fix breaking latest messages in chat
Nuckyz May 17, 2024
04a8649
FriendsSince: Show in user profile modal
Nuckyz May 18, 2024
54e1bac
new plugin CustomIdle (#2342)
waresnew May 18, 2024
caed7cd
MoreUserTags: If server owner tag is disabled, do not give other tags…
Noxillio May 19, 2024
d437318
Fix: PatchHelper not auto filling match field (#2338)
waresnew May 19, 2024
eac8a02
fix(PatchHelper): Make find and match more responsive
Nuckyz May 19, 2024
bc8b465
chore: Make package manager version not strict
Nuckyz May 19, 2024
b33b5bd
MessageLinkEmbeds: Add limit for nested links
Nuckyz May 19, 2024
a94b88c
MessageLinkEmbeds: No longer need to reset global regex
Nuckyz May 19, 2024
5f8b96d
Change duplicate find for SHC and VCDoubleClick
Nuckyz May 20, 2024
0a59512
Fix: Ignore bundled lib webpack on web
Nuckyz May 20, 2024
025508f
StartupTimings: Fix patch
Nuckyz May 20, 2024
dac2d75
bump to v1.8.5
Vendicated May 20, 2024
935028a
Merge branch 'main' into main
Johannes7k75 May 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(MessageLatency): Adjust for Discord kotlin clients (Vendicated#2443)
  • Loading branch information
dolfies committed May 12, 2024
commit fd7dafb15327efa95eedc313998e6900715f67f4
47 changes: 36 additions & 11 deletions src/plugins/messageLatency/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,27 @@ interface Diff {
seconds: number;
}

const DISCORD_KT_DELAY = 1471228.928;
const HiddenVisually = findExportedComponentLazy("HiddenVisually");

export default definePlugin({
name: "MessageLatency",
description: "Displays an indicator for messages that took ≥n seconds to send",
authors: [Devs.arHSM],

settings: definePluginSettings({
latency: {
type: OptionType.NUMBER,
description: "Threshold in seconds for latency indicator",
default: 2
},
detectDiscordKotlin: {
type: OptionType.BOOLEAN,
description: "Detect old Discord Android clients",
default: true
}
}),

patches: [
{
find: "showCommunicationDisabledStyles",
Expand All @@ -46,6 +54,7 @@ export default definePlugin({
}
}
],

stringDelta(delta: number) {
const diff: Diff = {
days: Math.round(delta / (60 * 60 * 24)),
Expand All @@ -71,49 +80,64 @@ export default definePlugin({
);
}, "");

return [ts || "0 seconds", diff.days === 17 && diff.hours === 1] as const;
return ts || "0 seconds";
},

latencyTooltipData(message: Message) {
const { latency, detectDiscordKotlin } = this.settings.store;
const { id, nonce } = message;

// Message wasn't received through gateway
if (!isNonNullish(nonce)) return null;

const delta = Math.round((SnowflakeUtils.extractTimestamp(id) - SnowflakeUtils.extractTimestamp(nonce)) / 1000);
let isDiscordKotlin = false;
let delta = Math.round((SnowflakeUtils.extractTimestamp(id) - SnowflakeUtils.extractTimestamp(nonce)) / 1000);

// Old Discord Android clients have a delay of around 17 days
// This is a workaround for that
if (-delta >= DISCORD_KT_DELAY - 86400) { // One day of padding for good measure
isDiscordKotlin = detectDiscordKotlin;
delta += DISCORD_KT_DELAY;
}

// Thanks dziurwa (I hate you)
// This is when the user's clock is ahead
// Can't do anything if the clock is behind
const abs = Math.abs(delta);
const ahead = abs !== delta;

const [stringDelta, isSuspectedKotlinDiscord] = this.stringDelta(abs);
const isKotlinDiscord = ahead && isSuspectedKotlinDiscord;
const stringDelta = abs >= latency ? this.stringDelta(abs) : null;

// Also thanks dziurwa
// 2 minutes
const TROLL_LIMIT = 2 * 60;
const { latency } = this.settings.store;

const fill: Fill = isKotlinDiscord
const fill: Fill = isDiscordKotlin
? ["status-positive", "status-positive", "text-muted"]
: delta >= TROLL_LIMIT || ahead
? ["text-muted", "text-muted", "text-muted"]
: delta >= (latency * 2)
? ["status-danger", "text-muted", "text-muted"]
: ["status-warning", "status-warning", "text-muted"];

return abs >= latency ? { delta: stringDelta, ahead, fill, isKotlinDiscord } : null;
return (abs >= latency || isDiscordKotlin) ? { delta: stringDelta, ahead, fill, isDiscordKotlin } : null;
},

Tooltip() {
return ErrorBoundary.wrap(({ message }: { message: Message; }) => {

const d = this.latencyTooltipData(message);

if (!isNonNullish(d)) return null;

let text: string;
if (!d.delta) {
text = "User is suspected to be on an old Discord Android client";
} else {
text = (d.ahead ? `This user's clock is ${d.delta} ahead.` : `This message was sent with a delay of ${d.delta}.`) + (d.isDiscordKotlin ? " User is suspected to be on an old Discord Android client." : "");
}

return <Tooltip
text={d.ahead ? `This user's clock is ${d.delta} ahead. ${d.isKotlinDiscord ? "User is suspected to be on an old mobile client" : ""}` : `This message was sent with a delay of ${d.delta}.`}
text={text}
position="top"
>
{
Expand All @@ -126,8 +150,9 @@ export default definePlugin({
</Tooltip>;
});
},

Icon({ delta, fill, props }: {
delta: string;
delta: string | null;
fill: Fill,
props: {
onClick(): void;
Expand All @@ -147,7 +172,7 @@ export default definePlugin({
role="img"
fill="none"
style={{ marginRight: "8px", verticalAlign: -1 }}
aria-label={delta}
aria-label={delta ?? "Old Discord Android client"}
aria-hidden="false"
{...props}
>
Expand Down