fix: notifs stream reconnection

This commit is contained in:
trisua 2025-06-30 12:20:44 -04:00
parent b501a7c5f0
commit 14936b8b90
5 changed files with 81 additions and 22 deletions

46
Cargo.lock generated
View file

@ -488,7 +488,7 @@ checksum = "93698b29de5e97ad0ae26447b344c482a7284c737d9ddc5f9e52b74a336671bb"
dependencies = [ dependencies = [
"chrono", "chrono",
"chrono-tz-build", "chrono-tz-build",
"phf", "phf 0.11.3",
] ]
[[package]] [[package]]
@ -498,7 +498,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1" checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1"
dependencies = [ dependencies = [
"parse-zoneinfo", "parse-zoneinfo",
"phf", "phf 0.11.3",
"phf_codegen", "phf_codegen",
] ]
@ -648,7 +648,7 @@ dependencies = [
"cssparser-macros", "cssparser-macros",
"dtoa-short", "dtoa-short",
"itoa", "itoa",
"phf", "phf 0.11.3",
"smallvec", "smallvec",
] ]
@ -728,11 +728,11 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
[[package]] [[package]]
name = "emojis" name = "emojis"
version = "0.6.4" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99e1f1df1f181f2539bac8bf027d31ca5ffbf9e559e3f2d09413b9107b5c02f4" checksum = "0a08afd8e599463c275703532e707c767b8c068a826eea9ca8fceaf3435029df"
dependencies = [ dependencies = [
"phf", "phf 0.12.1",
] ]
[[package]] [[package]]
@ -2164,7 +2164,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078" checksum = "1fd6780a80ae0c52cc120a26a1a42c1ae51b247a253e4e06113d23d2c2edd078"
dependencies = [ dependencies = [
"phf_macros", "phf_macros",
"phf_shared", "phf_shared 0.11.3",
]
[[package]]
name = "phf"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "913273894cec178f401a31ec4b656318d95473527be05c0752cc41cdc32be8b7"
dependencies = [
"phf_shared 0.12.1",
] ]
[[package]] [[package]]
@ -2174,7 +2183,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a" checksum = "aef8048c789fa5e851558d709946d6d79a8ff88c0440c587967f8e94bfb1216a"
dependencies = [ dependencies = [
"phf_generator", "phf_generator",
"phf_shared", "phf_shared 0.11.3",
] ]
[[package]] [[package]]
@ -2183,7 +2192,7 @@ version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d"
dependencies = [ dependencies = [
"phf_shared", "phf_shared 0.11.3",
"rand 0.8.5", "rand 0.8.5",
] ]
@ -2194,7 +2203,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216" checksum = "f84ac04429c13a7ff43785d75ad27569f2951ce0ffd30a3321230db2fc727216"
dependencies = [ dependencies = [
"phf_generator", "phf_generator",
"phf_shared", "phf_shared 0.11.3",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.101", "syn 2.0.101",
@ -2209,6 +2218,15 @@ dependencies = [
"siphasher", "siphasher",
] ]
[[package]]
name = "phf_shared"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06005508882fb681fd97892ecff4b7fd0fee13ef1aa569f8695dae7ab9099981"
dependencies = [
"siphasher",
]
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.2.16" version = "0.2.16"
@ -3067,7 +3085,7 @@ checksum = "bf776ba3fa74f83bf4b63c3dcbbf82173db2632ed8452cb2d891d33f459de70f"
dependencies = [ dependencies = [
"new_debug_unreachable", "new_debug_unreachable",
"parking_lot", "parking_lot",
"phf_shared", "phf_shared 0.11.3",
"precomputed-hash", "precomputed-hash",
"serde", "serde",
] ]
@ -3079,7 +3097,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c711928715f1fe0fe509c53b43e993a9a557babc2d0a3567d0a3006f1ac931a0" checksum = "c711928715f1fe0fe509c53b43e993a9a557babc2d0a3567d0a3006f1ac931a0"
dependencies = [ dependencies = [
"phf_generator", "phf_generator",
"phf_shared", "phf_shared 0.11.3",
"proc-macro2", "proc-macro2",
"quote", "quote",
] ]
@ -3476,7 +3494,7 @@ dependencies = [
"log", "log",
"parking_lot", "parking_lot",
"percent-encoding", "percent-encoding",
"phf", "phf 0.11.3",
"pin-project-lite", "pin-project-lite",
"postgres-protocol", "postgres-protocol",
"postgres-types", "postgres-types",
@ -4066,7 +4084,7 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "954c5a41f2bcb7314344079d0891505458cc2f4b422bdea1d5bfbe6d1a04903b" checksum = "954c5a41f2bcb7314344079d0891505458cc2f4b422bdea1d5bfbe6d1a04903b"
dependencies = [ dependencies = [
"phf", "phf 0.11.3",
"phf_codegen", "phf_codegen",
"string_cache", "string_cache",
"string_cache_codegen", "string_cache_codegen",

View file

@ -33,6 +33,6 @@ async-stripe = { version = "0.41.0", features = [
"billing", "billing",
"runtime-tokio-hyper", "runtime-tokio-hyper",
] } ] }
emojis = "0.6.4" emojis = "0.7.0"
webp = "0.3.0" webp = "0.3.0"
bberry = "0.2.0" bberry = "0.2.0"

View file

@ -101,6 +101,11 @@
} }
setTimeout(() => { setTimeout(() => {
if (globalThis.notifs_stream_init) {
return;
}
globalThis.notifs_stream_init = true;
trigger(\"me::notifications_stream\"); trigger(\"me::notifications_stream\");
}, 250); }, 250);
}); });

View file

@ -47,12 +47,24 @@
(span (span
(text "{{ text \"auth:action.unfollow\" }}"))) (text "{{ text \"auth:action.unfollow\" }}")))
(text "{%- endif %} {% if not is_blocking -%}") (text "{%- endif %} {% if not is_blocking -%}")
(button (div
("onclick" "toggle_block_user()") ("class" "dropdown")
("class" "lowered red") (button
(text "{{ icon \"shield\" }}") ("onclick" "trigger('atto::hooks::dropdown', [event])")
(span ("exclude" "dropdown")
(text "{{ text \"auth:action.block\" }}"))) ("class" "lowered red")
(icon_class (text "chevron-down") (text "dropdown-arrow"))
(str (text "auth:action.block")))
(div
("class" "inner left")
(button
("onclick" "toggle_block_user()")
(icon (text "shield"))
(str (text "auth:action.block")))
(button
("onclick" "ip_block_user()")
(icon (text "wifi"))
(str (text "auth:action.ip_block")))))
(text "{% else %}") (text "{% else %}")
(button (button
("onclick" "toggle_block_user()") ("onclick" "toggle_block_user()")
@ -151,6 +163,30 @@
res.message, res.message,
]); ]);
}); });
};
globalThis.ip_block_user = async () => {
if (
!(await trigger(\"atto::confirm\", [
\"Are you sure you would like to do this?\",
]))
) {
return;
}
fetch(
\"/api/v1/auth/user/{{ profile.id }}/block_ip\",
{
method: \"POST\",
},
)
.then((res) => res.json())
.then((res) => {
trigger(\"atto::toast\", [
res.ok ? \"success\" : \"error\",
res.message,
]);
});
};")) };"))
(text "{%- endif %}") (text "{%- endif %}")
(a (a

View file

@ -17,6 +17,6 @@ async-recursion = "1.1.1"
md-5 = "0.10.6" md-5 = "0.10.6"
base16ct = { version = "0.2.0", features = ["alloc"] } base16ct = { version = "0.2.0", features = ["alloc"] }
base64 = "0.22.1" base64 = "0.22.1"
emojis = "0.6.4" emojis = "0.7.0"
regex = "1.11.1" regex = "1.11.1"
oiseau = { version = "0.1.2", default-features = false, features = ["postgres", "redis"] } oiseau = { version = "0.1.2", default-features = false, features = ["postgres", "redis"] }