Skip to content

Commit

Permalink
tweak: tweaked subtitle downloader messages
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasklaen committed Nov 1, 2023
1 parent c173641 commit b862387
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/uosc/lib/menus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -596,28 +596,30 @@ function open_subtitle_downloader()

local handle_select, handle_search

-- Ensures response is valid, and returns its payload, or handles error reporting,
-- and returns `nil`, indicating the consumer should abort response handling.
local function ensure_response_data(success, result, error, check)
local data
if success and result and result.status == 0 then
data = utils.parse_json(result.stdout)
if not data or not check(data) then
data = (data and data.error == true) and data or {
error = true,
message = t('invalid response json'),
message = t('invalid response json (see console for details)'),
message_verbose = 'invalid response json: ' .. utils.to_string(result.stdout),
}
end
else
data = {
error = true,
message = error or t('process exited with code %s', result.status),
message = error or t('process exited with code %s (see console for details)', result.status),
message_verbose = result.stdout .. result.stderr,
}
end

if data.error then
local message = data.message or t('unknown error')
if data.message then msg.error(data.message_verbose or data.message) end
local message, message_verbose = data.message or t('unknown error'), data.message_verbose or data.message
if message_verbose then msg.error(message_verbose) end
menu:update_items({
{
title = message,
Expand Down Expand Up @@ -671,7 +673,7 @@ function open_subtitle_downloader()

menu:update_items({
{
title = t('Subtitles loaded & applied'),
title = t('Subtitles loaded & enabled'),
bold = true,
icon = 'check',
selectable = false,
Expand Down

0 comments on commit b862387

Please # to comment.