Skip to content

Commit

Permalink
Fix error when posting empty message
Browse files Browse the repository at this point in the history
closes #26

* Added a validation to prevent posting an empty message
* Displays an error notification if the user tries to post without entering a message.
  • Loading branch information
malkoG committed Sep 30, 2023
1 parent bf51981 commit be847df
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lua/mastodon/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ M.toot_message = function()
local active_account = active_accounts[1]
local prompt_message = "-- Your current account is " .. active_account.username .. " --" .. "\nEnter your message: "
local message = vim.fn.input({ prompt = prompt_message })
if message == "" then
vim.notify("You did not input message", "error", {
title = "(Mastodon.nvim) Failed to posting message",
})
return
end
local unescaped_message = string.gsub(message, "\\n", "\n")
local content = api_client.post_message(unescaped_message)

Expand Down

0 comments on commit be847df

Please sign in to comment.