diff --git a/postman/src/sender.rs b/postman/src/sender.rs index 22fc91c..1bfd6af 100644 --- a/postman/src/sender.rs +++ b/postman/src/sender.rs @@ -492,7 +492,9 @@ WHERE w.content(&reminder.content).tts(reminder.tts); if let Some(username) = &reminder.username { - w.username(username); + if !username.is_empty() { + w.username(username); + } } if let Some(avatar) = &reminder.avatar { diff --git a/web/src/routes/dashboard/export.rs b/web/src/routes/dashboard/export.rs index f71b071..0c2ab06 100644 --- a/web/src/routes/dashboard/export.rs +++ b/web/src/routes/dashboard/export.rs @@ -172,7 +172,7 @@ pub async fn import_reminders( create_reminder( ctx.inner(), - pool.inner(), + transaction, GuildId(id), UserId(user_id), reminder, @@ -320,13 +320,6 @@ pub async fn import_todos( } } - let _ = sqlx::query!( - "DELETE FROM todos WHERE guild_id = (SELECT id FROM guilds WHERE guild = ?)", - id - ) - .execute(pool.inner()) - .await; - let query_str = format!( "INSERT INTO todos (value, channel_id, guild_id) VALUES {}", vec![query_placeholder].repeat(query_params.len()).join(",") diff --git a/web/src/routes/dashboard/mod.rs b/web/src/routes/dashboard/mod.rs index 35182a9..611fe18 100644 --- a/web/src/routes/dashboard/mod.rs +++ b/web/src/routes/dashboard/mod.rs @@ -353,7 +353,7 @@ pub struct TodoCsv { pub async fn create_reminder( ctx: &Context, - pool: &Pool, + pool: impl sqlx::Executor<'_, Database = Database> + Copy, guild_id: GuildId, user_id: UserId, reminder: Reminder, @@ -450,6 +450,11 @@ pub async fn create_reminder( // base64 decode error dropped here let attachment_data = reminder.attachment.as_ref().map(|s| base64::decode(s).ok()).flatten(); let name = if reminder.name.is_empty() { name_default() } else { reminder.name.clone() }; + let username = if reminder.username.as_ref().map(|s| s.is_empty()).unwrap_or(true) { + None + } else { + reminder.username + }; let new_uid = generate_uid(); @@ -507,7 +512,7 @@ pub async fn create_reminder( name, reminder.restartable, reminder.tts, - reminder.username, + username, reminder.utc_time, ) .execute(pool) diff --git a/web/static/js/main.js b/web/static/js/main.js index 9ac1e85..2bb3d40 100644 --- a/web/static/js/main.js +++ b/web/static/js/main.js @@ -60,14 +60,15 @@ function update_select(sel) { sel.closest("div.reminderContent").querySelector("img.discord-avatar").src = sel.selectedOptions[0].dataset["webhookAvatar"]; } else { - sel.closest("div.reminderContent").querySelector("img.discord-avatar").src = ""; + sel.closest("div.reminderContent").querySelector("img.discord-avatar").src = + "/static/img/icon.png"; } if (sel.selectedOptions[0].dataset["webhookName"]) { sel.closest("div.reminderContent").querySelector("input.discord-username").value = sel.selectedOptions[0].dataset["webhookName"]; } else { sel.closest("div.reminderContent").querySelector("input.discord-username").value = - ""; + "Reminder"; } } @@ -723,6 +724,7 @@ $createReminderBtn.addEventListener("click", async () => { let reminder = await serialize_reminder($createReminder, "create"); if (reminder.error) { show_error(reminder.error); + $createReminderBtn.querySelector("span.icon > i").classList = ["fas fa-sparkles"]; return; } diff --git a/web/templates/dashboard.html.tera b/web/templates/dashboard.html.tera index 4a56955..3e459a7 100644 --- a/web/templates/dashboard.html.tera +++ b/web/templates/dashboard.html.tera @@ -191,19 +191,8 @@ -
-
- -
-

-
- By selecting "Import", you understand that this will overwrite existing data. -
Please first read the support page
diff --git a/web/templates/support/iemanager.html.tera b/web/templates/support/iemanager.html.tera index 2bf4ac2..8d4d920 100644 --- a/web/templates/support/iemanager.html.tera +++ b/web/templates/support/iemanager.html.tera @@ -26,8 +26,7 @@

Import data

- You can import previous exports or modified exports. When importing a file, existing data - will be overwritten. + You can import previous exports or modified exports. When importing a file, the new data will be added alongside existing data.