add: show_nsfw, hide_extra_post_tabs settings
add: ability to remove tokens from account switcher ui
This commit is contained in:
parent
88afb3ec37
commit
701ea79c9a
7 changed files with 70 additions and 77 deletions
|
@ -198,6 +198,7 @@
|
||||||
(text "{% macro profile_nav(selected=\"\") -%}")
|
(text "{% macro profile_nav(selected=\"\") -%}")
|
||||||
(div
|
(div
|
||||||
("class" "pillmenu")
|
("class" "pillmenu")
|
||||||
|
(text "{% if is_self or is_helper or not profile.settings.hide_extra_post_tabs -%}")
|
||||||
(a
|
(a
|
||||||
("href" "/@{{ profile.username }}")
|
("href" "/@{{ profile.username }}")
|
||||||
("class" "{% if selected == 'posts' -%}active{%- endif %}")
|
("class" "{% if selected == 'posts' -%}active{%- endif %}")
|
||||||
|
@ -213,16 +214,16 @@
|
||||||
("class" "{% if selected == 'media' -%}active{%- endif %}")
|
("class" "{% if selected == 'media' -%}active{%- endif %}")
|
||||||
(str (text "auth:label.media")))
|
(str (text "auth:label.media")))
|
||||||
|
|
||||||
(text "{% if is_self or is_helper %}")
|
(text "{% if is_self or is_helper -%}")
|
||||||
(a
|
(a
|
||||||
("href" "/@{{ profile.username }}/outbox")
|
("href" "/@{{ profile.username }}/outbox")
|
||||||
("class" "{% if selected == 'outbox' -%}active{%- endif %}")
|
("class" "{% if selected == 'outbox' -%}active{%- endif %}")
|
||||||
(str (text "auth:label.outbox")))
|
(str (text "auth:label.outbox")))
|
||||||
(text "{% endif %}")
|
(text "{%- endif %}")
|
||||||
|
|
||||||
(text "{% if is_helper %}")
|
(text "{% if is_helper -%}")
|
||||||
(a
|
(a
|
||||||
("href" "/requests?id={{ profile.id }}")
|
("href" "/requests?id={{ profile.id }}")
|
||||||
(str (text "requests:label.requests")))
|
(str (text "requests:label.requests")))
|
||||||
(text "{% endif %}"))
|
(text "{%- endif %} {%- endif %}"))
|
||||||
(text "{%- endmacro %}")
|
(text "{%- endmacro %}")
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
(span
|
(span
|
||||||
(text "{{ text \"requests:label.user_follow_request_message\" }}"))
|
(text "{{ text \"requests:label.user_follow_request_message\" }}"))
|
||||||
(div
|
(div
|
||||||
("class" "card flex w-full secondary gap-2")
|
("class" "card flex flex-wrap w-full secondary gap-2")
|
||||||
(a
|
(a
|
||||||
("href" "/api/v1/auth/user/find/{{ request.id }}")
|
("href" "/api/v1/auth/user/find/{{ request.id }}")
|
||||||
("class" "button")
|
("class" "button")
|
||||||
|
|
|
@ -1247,6 +1247,16 @@
|
||||||
\"{{ profile.settings.private_last_seen }}\",
|
\"{{ profile.settings.private_last_seen }}\",
|
||||||
\"checkbox\",
|
\"checkbox\",
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
[\"hide_extra_post_tabs\", \"Hide extra post tabs (replies, media)\"],
|
||||||
|
\"{{ profile.settings.hide_extra_post_tabs }}\",
|
||||||
|
\"checkbox\",
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[\"show_nsfw\", \"Show NSFW posts\"],
|
||||||
|
\"{{ profile.settings.show_nsfw }}\",
|
||||||
|
\"checkbox\",
|
||||||
|
],
|
||||||
[[], \"Questions\", \"title\"],
|
[[], \"Questions\", \"title\"],
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
|
|
|
@ -271,25 +271,20 @@
|
||||||
("onsubmit" "event.preventDefault()")
|
("onsubmit" "event.preventDefault()")
|
||||||
(div ("id" "tokens") ("style" "display: contents"))
|
(div ("id" "tokens") ("style" "display: contents"))
|
||||||
|
|
||||||
(a
|
|
||||||
("href" "/auth/login")
|
|
||||||
("class" "button")
|
|
||||||
("data-turbo", "false")
|
|
||||||
(icon (text "plus"))
|
|
||||||
(span (str (text "general:action.add_account"))))
|
|
||||||
|
|
||||||
(div
|
(div
|
||||||
("class" "flex justify-between")
|
("class" "flex justify-between")
|
||||||
(div null?)
|
(a
|
||||||
|
("href" "/auth/login")
|
||||||
|
("class" "button")
|
||||||
|
("data-turbo", "false")
|
||||||
|
(icon (text "plus"))
|
||||||
|
(span (str (text "general:action.add_account"))))
|
||||||
|
|
||||||
(div
|
(button
|
||||||
("class" "flex gap-2")
|
("class" "quaternary")
|
||||||
(button
|
("onclick" "document.getElementById('tokens_dialog').close()")
|
||||||
("class" "quaternary")
|
("type" "button")
|
||||||
("onclick" "document.getElementById('tokens_dialog').close()")
|
(icon (text "check")))))))
|
||||||
("type" "button")
|
|
||||||
(icon (text "check"))
|
|
||||||
(span "{{ text \"dialog:action.okay\" }}")))))))
|
|
||||||
|
|
||||||
; user scripts
|
; user scripts
|
||||||
(text "{%- endif %} {% if user and use_user_theme -%} {{ components::theme(user=user, theme_preference=user.settings.theme_preference) }}
|
(text "{%- endif %} {% if user and use_user_theme -%} {{ components::theme(user=user, theme_preference=user.settings.theme_preference) }}
|
||||||
|
|
|
@ -438,7 +438,7 @@
|
||||||
["object"],
|
["object"],
|
||||||
);
|
);
|
||||||
|
|
||||||
self.define("login", ({ $ }, username) => {
|
self.define("login", (_, username) => {
|
||||||
const token = self.LOGIN_ACCOUNT_TOKENS[username];
|
const token = self.LOGIN_ACCOUNT_TOKENS[username];
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
|
@ -448,20 +448,41 @@
|
||||||
window.location.href = `/api/v1/auth/token?token=${token}`;
|
window.location.href = `/api/v1/auth/token?token=${token}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
self.define("remove_token", async (_, username) => {
|
||||||
|
if (
|
||||||
|
!(await trigger("atto::confirm", [
|
||||||
|
"Are you sure you would like to do this?",
|
||||||
|
]))
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete self.LOGIN_ACCOUNT_TOKENS[username];
|
||||||
|
self.set_login_account_tokens(self.LOGIN_ACCOUNT_TOKENS);
|
||||||
|
|
||||||
|
trigger("atto::toast", ["success", "Token removed"]);
|
||||||
|
});
|
||||||
|
|
||||||
self.define("render_token_picker", ({ $ }, element) => {
|
self.define("render_token_picker", ({ $ }, element) => {
|
||||||
element.innerHTML = "";
|
element.innerHTML = "";
|
||||||
for (const token of Object.entries($.LOGIN_ACCOUNT_TOKENS)) {
|
for (const token of Object.entries($.LOGIN_ACCOUNT_TOKENS)) {
|
||||||
element.innerHTML += `<button class="quaternary w-full justify-start" onclick="trigger('me::login', ['${token[0]}'])">
|
element.innerHTML += `<div class="flex gap-2 flex-row">
|
||||||
<img
|
<button class="quaternary w-full justify-start" onclick="trigger('me::login', ['${token[0]}'])">
|
||||||
title="${token[0]}'s avatar"
|
<img
|
||||||
src="/api/v1/auth/user/${token[0]}/avatar?selector_type=username"
|
title="${token[0]}'s avatar"
|
||||||
alt="Avatar image"
|
src="/api/v1/auth/user/${token[0]}/avatar?selector_type=username"
|
||||||
class="avatar"
|
alt="Avatar image"
|
||||||
style="--size: 24px"
|
class="avatar"
|
||||||
/>
|
style="--size: 24px"
|
||||||
|
/>
|
||||||
|
|
||||||
<span>${token[0]}</span>
|
<span>${token[0]}</span>
|
||||||
</button>`;
|
</button>
|
||||||
|
|
||||||
|
<button onclick="trigger('me::remove_token', ['${token[0]}'])" class="small square red quaternary">
|
||||||
|
-
|
||||||
|
</button>
|
||||||
|
</div>`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -435,8 +435,6 @@ impl DataManager {
|
||||||
page: usize,
|
page: usize,
|
||||||
user: &Option<User>,
|
user: &Option<User>,
|
||||||
) -> Result<Vec<Post>> {
|
) -> Result<Vec<Post>> {
|
||||||
let other_user = self.get_user_by_id(id).await?;
|
|
||||||
|
|
||||||
let conn = match self.connect().await {
|
let conn = match self.connect().await {
|
||||||
Ok(c) => c,
|
Ok(c) => c,
|
||||||
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
||||||
|
@ -446,13 +444,7 @@ impl DataManager {
|
||||||
let mut hide_nsfw: bool = true;
|
let mut hide_nsfw: bool = true;
|
||||||
|
|
||||||
if let Some(ua) = user {
|
if let Some(ua) = user {
|
||||||
if ua.id == other_user.id {
|
hide_nsfw = !ua.settings.show_nsfw;
|
||||||
hide_nsfw = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if other_user.settings.private_profile {
|
|
||||||
hide_nsfw = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
@ -490,8 +482,6 @@ impl DataManager {
|
||||||
page: usize,
|
page: usize,
|
||||||
user: &Option<User>,
|
user: &Option<User>,
|
||||||
) -> Result<Vec<Post>> {
|
) -> Result<Vec<Post>> {
|
||||||
let other_user = self.get_user_by_id(id).await?;
|
|
||||||
|
|
||||||
let conn = match self.connect().await {
|
let conn = match self.connect().await {
|
||||||
Ok(c) => c,
|
Ok(c) => c,
|
||||||
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
||||||
|
@ -501,13 +491,7 @@ impl DataManager {
|
||||||
let mut hide_nsfw: bool = true;
|
let mut hide_nsfw: bool = true;
|
||||||
|
|
||||||
if let Some(ua) = user {
|
if let Some(ua) = user {
|
||||||
if ua.id == other_user.id {
|
hide_nsfw = !ua.settings.show_nsfw;
|
||||||
hide_nsfw = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if other_user.settings.private_profile {
|
|
||||||
hide_nsfw = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
@ -545,8 +529,6 @@ impl DataManager {
|
||||||
page: usize,
|
page: usize,
|
||||||
user: &Option<User>,
|
user: &Option<User>,
|
||||||
) -> Result<Vec<Post>> {
|
) -> Result<Vec<Post>> {
|
||||||
let other_user = self.get_user_by_id(id).await?;
|
|
||||||
|
|
||||||
let conn = match self.connect().await {
|
let conn = match self.connect().await {
|
||||||
Ok(c) => c,
|
Ok(c) => c,
|
||||||
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
||||||
|
@ -556,13 +538,7 @@ impl DataManager {
|
||||||
let mut hide_nsfw: bool = true;
|
let mut hide_nsfw: bool = true;
|
||||||
|
|
||||||
if let Some(ua) = user {
|
if let Some(ua) = user {
|
||||||
if ua.id == other_user.id {
|
hide_nsfw = !ua.settings.show_nsfw;
|
||||||
hide_nsfw = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if other_user.settings.private_profile {
|
|
||||||
hide_nsfw = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
@ -603,8 +579,6 @@ impl DataManager {
|
||||||
text_query: &str,
|
text_query: &str,
|
||||||
user: &Option<&User>,
|
user: &Option<&User>,
|
||||||
) -> Result<Vec<Post>> {
|
) -> Result<Vec<Post>> {
|
||||||
let other_user = self.get_user_by_id(id).await?;
|
|
||||||
|
|
||||||
let conn = match self.connect().await {
|
let conn = match self.connect().await {
|
||||||
Ok(c) => c,
|
Ok(c) => c,
|
||||||
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
||||||
|
@ -614,13 +588,7 @@ impl DataManager {
|
||||||
let mut hide_nsfw: bool = true;
|
let mut hide_nsfw: bool = true;
|
||||||
|
|
||||||
if let Some(ua) = user {
|
if let Some(ua) = user {
|
||||||
if ua.id == other_user.id {
|
hide_nsfw = !ua.settings.show_nsfw;
|
||||||
hide_nsfw = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if other_user.settings.private_profile {
|
|
||||||
hide_nsfw = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
@ -697,8 +665,6 @@ impl DataManager {
|
||||||
page: usize,
|
page: usize,
|
||||||
user: &Option<User>,
|
user: &Option<User>,
|
||||||
) -> Result<Vec<Post>> {
|
) -> Result<Vec<Post>> {
|
||||||
let other_user = self.get_user_by_id(id).await?;
|
|
||||||
|
|
||||||
let conn = match self.connect().await {
|
let conn = match self.connect().await {
|
||||||
Ok(c) => c,
|
Ok(c) => c,
|
||||||
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
Err(e) => return Err(Error::DatabaseConnection(e.to_string())),
|
||||||
|
@ -708,13 +674,7 @@ impl DataManager {
|
||||||
let mut hide_nsfw: bool = true;
|
let mut hide_nsfw: bool = true;
|
||||||
|
|
||||||
if let Some(ua) = user {
|
if let Some(ua) = user {
|
||||||
if ua.id == other_user.id {
|
hide_nsfw = !ua.settings.show_nsfw;
|
||||||
hide_nsfw = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if other_user.settings.private_profile {
|
|
||||||
hide_nsfw = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
|
|
@ -216,6 +216,12 @@ pub struct UserSettings {
|
||||||
/// Require an account to view the user's profile.
|
/// Require an account to view the user's profile.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub require_account: bool,
|
pub require_account: bool,
|
||||||
|
/// If NSFW content should be shown.
|
||||||
|
#[serde(default)]
|
||||||
|
pub show_nsfw: bool,
|
||||||
|
/// If extra post tabs are hidden (replies, media).
|
||||||
|
#[serde(default)]
|
||||||
|
pub hide_extra_post_tabs: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mime_avif() -> String {
|
fn mime_avif() -> String {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue