-
-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Handle media links #740
Conversation
d6a8fd6
to
7ba52ef
Compare
7ba52ef
to
86b1955
Compare
83586a7
to
6c60a48
Compare
6c60a48
to
daf0ffe
Compare
dac7a73
to
c79d297
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@preetmishra Thanks for working on this and pushing this forward 👍 We may be able to merge the core commits quickly and leave the UI tuning for later PRs or merged later from this PR.
Tests added and amendments made by Preet Mishra to make it usable for MessageLinkButton and PopUpConfirmationView later. Co-authored by: Preet Mishra <[email protected]>
c79d297
to
ef32f4a
Compare
The parameter is useful for prompts that have long descriptions. Used 'center' location for show_media_confirmation_popup().
Hello @preetmishra, it seems like you have referenced #764 in your pull request description, but you have not referenced them in your commit message description(s). When you reference an issue in a commit message, it automatically closes the corresponding issue when the commit is merged. Please run An example of a correctly-formatted commit:
Thank you for your contributions to Zulip! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@preetmishra The latest conflict is small, and I wanted to get this in soon if we can - having just tested it again it seems to work fine, and it'll be great to have merged 👍
It would be good if we could keep the UI out of the helper code, which may require a little restructuring of the control flow but should be fairly straightforward.
@amanagr Could you (or a delegated WSL contributor) check the feasibility of explorer
on WSL, as used in this PR?
@andersk Do you have further thoughts or concerns here?
error = [ | ||
' The command ', ('bold', command), ' did not run successfully' | ||
'. Exited with ', ('bold', str(exit_status)), | ||
] | ||
except FileNotFoundError: | ||
error = [' The command ', ('bold', command), ' could not be found'] | ||
|
||
if error: | ||
controller.view.set_footer_text(error, duration=3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep the UI-centric parts out of helper.py
?
if LINUX: | ||
command = 'xdg-open' | ||
elif WSL: | ||
command = 'explorer' # Needs testing. | ||
elif MACOS: | ||
command = 'open' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: It would be useful if the user was able to know what the file was going to be opened with in the popup (see other comment)
if isinstance(self.controller.loop.widget, urwid.Overlay): | ||
self.controller.exit_popup() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this check avoid? I know you've used it elsewhere, but I don't remember what the conclusion was - can we discuss and then maybe add a comment. Does it belong in exit_popup
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@preetmishra could you elaborate this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ezio-Sarthak The pop-ups open in an urwid Overlay. This check is to make sure exit_popup
is only called when an Overlay exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see that now. If I avoid that check, there is some unwanted synchronous behavior in footer and popup, if that makes any sense.
controller.view.set_footer_text([ | ||
' Downloading ', ('bold', media_name), | ||
]) | ||
controller.view.set_footer_text([' Downloaded ', ('bold', media_name)], | ||
duration=3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this will end up needing it's own commit, but perhaps make these callbacks to keep the UI separate in any case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we have report_*
methods, would it be OK to use here?
'Your requested media has been downloaded at ', | ||
('bold', media_path), | ||
'. Do you want to view it?' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the length of the download URLs for some files, this might well benefit from more vertical spacing, eg.
Your requested media has been downloaded to:
<filename>
Do you want the application to open it with <tool>?
@@ -678,7 +678,7 @@ def process_media(controller: Any, media_link: str) -> None: | |||
elif MACOS: | |||
command = 'open' | |||
|
|||
open_media(controller, command, media_path) | |||
controller.show_media_confirmation_popup(open_media, command, media_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing you're trying to synchronize the asynch download terminating?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I fully understood your comment, but I think the callback would be working fine in any case?
@@ -1006,9 +1006,13 @@ def __init__(self, controller: Any, title: str) -> None: | |||
super().__init__(controller, widgets, 'HELP', popup_width, title) | |||
|
|||
|
|||
PopUpConfirmationViewLocation = Literal['top-left', 'center'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment should go before the previous one, as there is nowhere near enough space in the top-left for showing the download information :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean commit?
(Sorry I no longer have access to WSL) |
It may be better to use |
Heads up @preetmishra, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
The followup to this was merged with slight adjustments in #1223 🎉 Thanks @amanagr, @preetmishra and @Ezio-Sarthak 👍 |
Thanks to @amanagr for his initial work in #359. 👍
The PR extracts a few common elements from the PR but has changes to make the function compatible with
MessageLinkButton
.Commits
MessageLinkButton
.MesssageLinkButton
to handle media links.open_media
asynch and shows downloading updates in the footer.PopUpConfirmationView
instantiation for its subsequent commit where it is used inopen_media
.Potential follow-up
I would greatly appreciate any early feedback and bug/caveats report.
Partially fixes #764.