Skip to content

Commit dac7a73

Browse files
committed
helper: Show confirmation overlay before displaying any media.
Test amended.
1 parent ff53ffd commit dac7a73

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

tests/helper/test_helper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,11 @@ def test_open_media(mocker, media_link, message_id, expected_path, platform,
327327
sys = mocker.patch('zulipterminal.helper.sys')
328328
sys.platform = platform
329329
open = mocker.patch('zulipterminal.helper.open')
330+
partial = mocker.patch('zulipterminal.helper.partial')
330331

331332
open_media(controller, media_link, message_id)
332333

333-
params = subprocess.run.call_args_list[0][0][0]
334+
params = partial.call_args_list[0][0][1]
334335
assert params[0] == expected_command
335336
assert params[1] == expected_path
337+
controller.show_confirmation_overlay.called

zulipterminal/helper.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sys
55
import time
66
from collections import OrderedDict, defaultdict
7-
from functools import wraps
7+
from functools import partial, wraps
88
from itertools import chain, combinations
99
from re import ASCII, match
1010
from tempfile import gettempdir
@@ -16,6 +16,7 @@
1616

1717
import lxml.html
1818
import requests
19+
import urwid
1920
from mypy_extensions import TypedDict
2021

2122

@@ -676,4 +677,7 @@ def open_media(controller: Any, media_link: str, message_id: int) -> None:
676677
'darwin': 'open',
677678
}
678679
command = image_viewers[sys.platform]
679-
subprocess.run([command, img_path])
680+
callback = partial(subprocess.run, [command, img_path])
681+
question = urwid.Text("Your requested media has been downloaded."
682+
" Do you want to view it?")
683+
controller.show_confirmation_overlay(question, callback)

0 commit comments

Comments
 (0)