Skip to content

Commit d70f1bf

Browse files
committed
GH-1 GH-13: Add Gif Search and improve Settings
1 parent d02b9a8 commit d70f1bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2271
-1129
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"@reduxjs/toolkit": "^1.9.5",
2020
"@tauri-apps/api": "^1.2.0",
2121
"@types/dompurify": "^3.0.1",
22+
"@types/lodash": "^4.14.202",
2223
"@types/marked": "^5.0.0",
2324
"@types/quill": "^2.0.10",
2425
"@types/react-color": "^3.0.6",
@@ -34,6 +35,7 @@
3435
"marked": "^5.0.2",
3536
"marked-highlight": "^2.0.0",
3637
"quill": "^1.3.7",
38+
"quill-delta": "^5.1.0",
3739
"react": "^18.2.0",
3840
"react-color": "^2.19.3",
3941
"react-dom": "^18.2.0",
@@ -43,6 +45,7 @@
4345
"react-router-dom": "^6.10.0",
4446
"socket.io": "^4.7.4",
4547
"socket.io-client": "^4.7.4",
48+
"tauri-plugin-store-api": "https://github.com/tauri-apps/tauri-plugin-store#v1",
4649
"tinycolor2": "^1.6.0"
4750
},
4851
"devDependencies": {

public/locales/de/appearance.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"Primary": "Primär",
77
"Accent": "Akzent",
88
"Disable Auto-Scroll": "Automatisches Scrollen deaktivieren",
9-
"Always auto-scroll, even if scrolled up": "Immer automatisch scrollen, auch wenn nach oben gescrollt wurde"
9+
"Always auto-scroll, even if scrolled up": "Immer automatisch scrollen, auch wenn nach oben gescrollt wurde",
10+
"Enable WYSIWYG Editor": "WYSIWYG-Editor aktivieren"
1011
}

public/locales/de/common.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,7 @@
2727
"Description": "Beschreibung",
2828
"Server": "Server",
2929
"Port": "Port",
30-
"Username": "Benutzername"
30+
"Username": "Benutzername",
31+
"Advanced Settings": "Erweiterte Einstellungen",
32+
"Beta": "Beta"
3133
}

public/locales/dev/appearance.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"Primary": "---",
77
"Accent": "---",
88
"Disable Auto-Scroll": "---",
9-
"Always auto-scroll, even if scrolled up": "---"
9+
"Always auto-scroll, even if scrolled up": "---",
10+
"Enable WYSIWYG Editor": "---"
1011
}

public/locales/dev/common.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,7 @@
2727
"Description": "---",
2828
"Server": "---",
2929
"Port": "---",
30-
"Username": "---"
30+
"Username": "---",
31+
"Advanced Settings": "---",
32+
"Beta": "---"
3133
}

public/locales/en/appearance.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"Primary": "Primary",
77
"Accent": "Accent",
88
"Disable Auto-Scroll": "Disable Auto-Scroll",
9-
"Always auto-scroll, even if scrolled up": "Always auto-scroll, even if scrolled up"
9+
"Always auto-scroll, even if scrolled up": "Always auto-scroll, even if scrolled up",
10+
"Enable WYSIWYG Editor": "Enable WYSIWYG Editor"
1011
}

public/locales/en/common.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@
2828
"Server": "Server",
2929
"Port": "Port",
3030
"Username": "Username",
31-
"Client Certitcate": "Client Certitcate"
31+
"Client Certitcate": "Client Certitcate",
32+
"Advanced Settings": "Advanced Settings",
33+
"Beta": "Beta"
3234
}

public/locales/es/appearance.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"Appearance": "Apariencia",
3+
"Colors": "Colores",
4+
"Background Image": "Imagen de Fondo",
5+
"Profile Image": "Imagen de Perfil",
6+
"Primary": "Principal",
7+
"Accent": "Acento",
8+
"Disable Auto-Scroll": "Desactivar Auto-Scroll",
9+
"Always auto-scroll, even if scrolled up": "Siempre auto-scroll, incluso si se desplaza hacia arriba",
10+
"Enable WYSIWYG Editor": "Habilitar Editor WYSIWYG"
11+
}

public/locales/es/audio.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"Audio": "Audio",
3+
"Input Device": "Dispositivo de entrada",
4+
"Microphone": "Micrófono",
5+
"Voice Activation": "Activación de voz",
6+
"Push To Talk": "Pulsar para hablar",
7+
"Automatically detect Microphone sensitivity": "Detectar automáticamente la sensibilidad del micrófono",
8+
"Hold Activation for": "Mantener activación durante {{duration}}",
9+
"Fade-out Audio after activation for": "Desvanecer audio después de la activación durante {{duration}}",
10+
"Audio activation at": "Activación de audio en {{threshold}}",
11+
"Audio deactivation at": "Desactivación de audio en {{threshold}}",
12+
"Amplification dB": "Amplificación +{{amplification}}dB",
13+
"Echo Cancelation": "Cancelación de eco",
14+
"Noise Suppression": "Supresión de ruido",
15+
"Compressor Threshold": "Umbral del compresor {{threshold}}dB",
16+
"Compressor Ratio": "Relación del compresor {{ratio}}:1",
17+
"Attack Time": "Tiempo de ataque {{duration}}",
18+
"Release Time": "Tiempo de liberación {{duration}}"
19+
}

public/locales/es/common.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"User Profiles": "Perfiles de usuario",
3+
"Profile": "Perfil",
4+
"Add New Server": "Agregar nuevo servidor",
5+
"Fancy Mumble Title": "Título elegante de Mumble",
6+
"Unknown User": "Usuario desconocido",
7+
"Search": "Buscar",
8+
"Search Channel": "Buscar canal",
9+
"Search Tenor": "Buscar Tenor para GIFs",
10+
"Open In Browser": "Abrir en el navegador",
11+
"Muted": "Silenciado",
12+
"Deafened": "Sordo",
13+
"Joined": "Unido",
14+
"User ID": "ID de usuario",
15+
"Settings": "Configuración",
16+
"None": "Ninguno",
17+
"Image too large": "[[ Imagen demasiado grande ({{size}} de {{maximum}}) ]]",
18+
"write something": "Escribe algo :)",
19+
"Feature Not Implemented": "{{feature}} (No implementado)",
20+
"About Me": "Acerca de mí",
21+
"Tell us about yourself": "Cuéntanos sobre ti",
22+
"Edit Image": "Editar imagen",
23+
"Link Preview": "Vista previa del enlace",
24+
"Additional Features": "Funciones adicionales",
25+
"Advanced": "Avanzado",
26+
"Images": "Imágenes",
27+
"Description": "Descripción",
28+
"Server": "Servidor",
29+
"Port": "Puerto",
30+
"Username": "Nombre de usuario",
31+
"Client Certitcate": "Certificado de cliente",
32+
"Advanced Settings": "Configuración avanzada",
33+
"Beta": "Beta"
34+
}

public/locales/es/language.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"Language": "Idioma",
3+
"en": "English",
4+
"en native": "Inglés",
5+
"de": "Deutsch",
6+
"de native": "Alemán",
7+
"fr": "Français",
8+
"fr native": "Francés",
9+
"es": "Español",
10+
"es native": "Español",
11+
"dev": "Development",
12+
"dev native": "Desarrollo"
13+
}

public/locales/es/notifications.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"Notifications": "Notifications",
3+
"Hotkeys": "Hotkeys"
4+
}

public/locales/es/privacy.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"Privacy": "Privacidad",
3+
"Allow URLs from all sources": "Permitir URLs de todas las fuentes",
4+
"Allowed Link Preview Urls": "URLs permitidas para vista previa de enlaces",
5+
"Enable Link Preview": "Habilitar vista previa de enlaces",
6+
"Tenor API Key": "Clave de API de Tenor"
7+
}

public/locales/es/time.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"Timestamp": "Marca de tiempo",
3+
"day short": "d",
4+
"hour short": "h",
5+
"minute short": "m",
6+
"second short": "s",
7+
"millisecond short": "ms"
8+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"Are you sure you want to delete all messages?": "¿Estás seguro de que quieres eliminar todos los mensajes?",
3+
"Yes": "",
4+
"No": "No",
5+
"Skip": "Saltar",
6+
"Cancel": "Cancelar",
7+
"Like": "Me gusta",
8+
"Message": "Mensaje",
9+
"Go Back": "Volver",
10+
"Save": "Guardar",
11+
"Connect": "Conectar",
12+
"Apply": "Aplicar",
13+
"Discard": "Descartar",
14+
"write user a message": "escribe un mensaje a {{user}}...",
15+
"Delete all messages": "Eliminar todos los mensajes",
16+
"Send Message to Channel": "Enviar mensaje a {{channel}}",
17+
"User Joined the Server": "{{user}} se unió al servidor"
18+
}

public/locales/fr/appearance.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"Primary": "Primaire",
77
"Accent": "Accent",
88
"Disable Auto-Scroll": "Désactiver le défilement automatique",
9-
"Always auto-scroll, even if scrolled up": "Toujours défilement automatique, même si défilé vers le haut"
9+
"Always auto-scroll, even if scrolled up": "Toujours défilement automatique, même si défilé vers le haut",
10+
"Enable WYSIWYG Editor": "Activer l'éditeur WYSIWYG"
1011
}

public/locales/fr/common.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,7 @@
2727
"Description": "Description",
2828
"Server": "Serveur",
2929
"Port": "Port",
30-
"Username": "Nom d'utilisateur"
30+
"Username": "Nom d'utilisateur",
31+
"Advanced Settings": "Paramètres avancés",
32+
"Beta": "Bêta"
3133
}

src-tauri/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ patch = "0.7.0"
2222
[dependencies]
2323
serde_json = "1.0"
2424
serde = { version = "1.0", features = ["derive"] }
25-
tauri = { version = "1.4.0", features = ["dialog-open", "global-shortcut-all", "shell-open", "updater", "window-close", "window-hide", "window-maximize", "window-minimize", "window-start-dragging", "window-unmaximize", "window-unminimize"] }
25+
tauri = { version = "1.5.4", features = [ "path-all", "dialog-open", "global-shortcut-all", "shell-open", "updater", "window-close", "window-hide", "window-maximize", "window-minimize", "window-start-dragging", "window-unmaximize", "window-unminimize"] }
2626
futures = "0.3.4"
2727
tokio = { version = "1", features = ["full"] }
2828
tokio-native-tls = "0.3.1"
@@ -44,6 +44,7 @@ webbrowser = "0.8.10"
4444
reqwest = "0.11"
4545
scraper = "0.18.1"
4646
tauri-plugin-window-state = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
47+
tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
4748
symphonia = "0.5.3"
4849
mime_guess = "2.0.4"
4950
uuid = "1.7.0"

src-tauri/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ fn main() -> io::Result<()> {
118118

119119
prost_build::compile_protos(&["src/proto/Mumble.proto"], &["src/"])?;
120120
prost_build::compile_protos(&["src/proto/MumbleUDP.proto"], &["src/"])?;
121+
prost_build::compile_protos(&["src/proto/Fancy.proto"], &["src/"])?;
121122
tauri_build::build();
122123

123124
Ok(())

src-tauri/src/commands/settings_cmd.rs

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
use std::{
22
fs,
3-
io::{Read, Seek, SeekFrom, Write},
4-
sync::RwLock,
3+
io::{Seek, SeekFrom, Write},
54
};
65

7-
use tauri::State;
86
use tracing::{info, trace};
97

108
use crate::{
119
errors::certificate_error::CertificateError,
1210
utils::{constants::get_project_dirs, server::Server},
1311
};
1412

15-
use super::utils::settings::FrontendSettings;
16-
1713
const SERVER_SETTINS_FILE: &str = "server.json";
18-
const FRONTEND_SETTINS_FILE: &str = "frontend_settings.json";
1914

2015
pub fn get_settings_file(file_name: &str) -> Result<std::fs::File, String> {
2116
let project_dirs = get_project_dirs().ok_or("Unable to load project dir")?;
@@ -30,18 +25,6 @@ pub fn get_settings_file(file_name: &str) -> Result<std::fs::File, String> {
3025
Ok(settings_file)
3126
}
3227

33-
pub fn get_settings_file_location(file_name: &str) -> Result<String, String> {
34-
let project_dirs = get_project_dirs().ok_or("Unable to load project dir")?;
35-
let data_dir = project_dirs.config_dir();
36-
std::fs::create_dir_all(data_dir).map_err(|e| format!("{e:?}"))?;
37-
38-
Ok(data_dir
39-
.join(file_name)
40-
.to_str()
41-
.ok_or_else(|| "Unable to get file location".to_string())?
42-
.to_string())
43-
}
44-
4528
#[tauri::command]
4629
pub fn save_server(
4730
description: &str,
@@ -116,60 +99,6 @@ pub fn get_server_list() -> Result<Vec<Server>, String> {
11699
Ok(server_list)
117100
}
118101

119-
pub struct FrontendSettingsState {
120-
pub state: RwLock<bool>,
121-
}
122-
123-
#[allow(clippy::needless_pass_by_value)] // LinkPreview needs to be deserialized
124-
#[allow(clippy::significant_drop_tightening)] // we need this to prevent simultaneous writes
125-
#[tauri::command]
126-
pub fn save_frontend_settings(
127-
state: State<'_, FrontendSettingsState>,
128-
settings_name: &str,
129-
data: FrontendSettings,
130-
) -> Result<(), String> {
131-
trace!("Saving frontend settings: {settings_name}");
132-
133-
trace!("Settings data: {:#?}", data);
134-
let lock = state.state.write();
135-
if let Err(e) = lock {
136-
return Err(format!("Error locking write state: {}", e.get_ref()));
137-
}
138-
let data = serde_json::to_string_pretty(&data).map_err(|e| format!("{e:?}"))?;
139-
140-
fs::write(
141-
get_settings_file_location(&format!("{settings_name}_{FRONTEND_SETTINS_FILE}"))?,
142-
data,
143-
)
144-
.map_err(|e| format!("{e:?}"))?;
145-
146-
Ok(())
147-
}
148-
149-
// State is passed by value by tauri
150-
#[allow(clippy::needless_pass_by_value)]
151-
#[tauri::command]
152-
pub fn get_frontend_settings(
153-
state: State<'_, FrontendSettingsState>,
154-
settings_name: &str,
155-
) -> Result<String, String> {
156-
info!("Getting frontend settings: {settings_name}");
157-
let mut settings_file = get_settings_file(&format!("{settings_name}_{FRONTEND_SETTINS_FILE}"))?;
158-
159-
if let Err(e) = state.state.read() {
160-
return Err(format!("Error locking write state: {}", e.get_ref()));
161-
}
162-
163-
let mut settings_data = String::new();
164-
settings_file
165-
.read_to_string(&mut settings_data)
166-
.map_err(|e| format!("{e:?}"))?;
167-
168-
trace!("Settings data: {:#?}", settings_data);
169-
170-
Ok(settings_data)
171-
}
172-
173102
#[tauri::command]
174103
pub fn get_identity_certs() -> Result<Vec<String>, String> {
175104
let project_dirs = get_project_dirs()

src-tauri/src/commands/web_cmd.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,33 @@ pub async fn get_open_graph_data_from_website(
4545

4646
Ok(result.to_string())
4747
}
48+
49+
#[tauri::command]
50+
pub async fn get_tenor_search_results(
51+
api_key: &str,
52+
query: &str,
53+
limit: u32,
54+
pos: u32,
55+
) -> Result<String, String> {
56+
let params = format!("&q={query}&limit={limit}&pos={pos}");
57+
58+
get_tenor_results(api_key, "search", params).await
59+
}
60+
61+
#[tauri::command]
62+
pub async fn get_tenor_trending_results(api_key: &str) -> Result<String, String> {
63+
get_tenor_results(api_key, "trending", String::new()).await
64+
}
65+
66+
async fn get_tenor_results(api_key: &str, api: &str, params: String) -> Result<String, String> {
67+
let url = format!("https://api.tenor.com/v1/{api}?key={api_key}{params}");
68+
69+
let response = reqwest::get(&url)
70+
.await
71+
.map_err(|e| format!("{e:?}"))?
72+
.text()
73+
.await
74+
.map_err(|e| format!("{e:?}"))?;
75+
76+
Ok(response)
77+
}

0 commit comments

Comments
 (0)