Skip to content
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

boxes: Disable stream change during edit. #870

Closed
wants to merge 1 commit into from

Conversation

Abhirup-99
Copy link
Contributor

Partially fixes #774

Copy link
Member

@prah23 prah23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Abhirup-99 Thanks for working on this 👍

I would suggest restructuring to use stream_box_edit_view solely to make the changes instead of the is_in_edit state, self.stream_write_box's nature can be overwritten inside stream_box_edit_view since the latter is extended from stream_box_view. You might have to mention self.header_write_box to include the overwritten stream box in the header box, but it would reduce the extra boolean you currently need, considering that we have a separate edit view for such specifications.

zulipterminal/ui_tools/boxes.py Outdated Show resolved Hide resolved
zulipterminal/ui_tools/boxes.py Outdated Show resolved Hide resolved
@Abhirup-99
Copy link
Contributor Author

@Abhirup-99 Thanks for working on this

I would suggest restructuring to use stream_box_edit_view solely to make the changes instead of the is_in_edit state, self.stream_write_box's nature can be overwritten inside stream_box_edit_view since the latter is extended from stream_box_view. You might have to mention self.header_write_box to include the overwritten stream box in the header box, but it would reduce the extra boolean you currently need, considering that we have a separate edit view for such specifications.

Thanks for the review, I agree it's a valid concern that this should completely be done in the edit box but if I use self.header_write_boxinstead of the current approach, the corresponding syntax becomes
python self.header_write_box.widget_list[0] = .....
this would seem a bit more confusing than the current approach to anyone extending it, at least in my view because the entire first element gets overwritten. The current approach grants just seem better to me for the sake of understanding. I guess we can wait for Neil to suggest this part.

@Abhirup-99 Abhirup-99 force-pushed the block_cycle branch 2 times, most recently from 6ed6932 to fa8d43f Compare January 9, 2021 18:45
@prah23
Copy link
Member

prah23 commented Jan 9, 2021

@Abhirup-99 I meant rewriting the stream_write_box to be a urwid.Text or so (as appropriate), and then use it in the same header_write_box as before. We wouldn't be changing the orientation or structure of the header_write_box. I believe the header_write_box's syntax or behavior shouldn't change.
Here's a snippet that might help make my suggestion clear for extending it in the stream_box_edit_view.

        self.stream_write_box = urwid.Text(u"")
        self.header_write_box = urwid.Columns(
            [self.stream_write_box, self.title_write_box],
            dividechars=1
        )

Copy link
Contributor Author

@Abhirup-99 Abhirup-99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Abhirup-99 I meant rewriting the stream_write_box to be a urwid.Text or so (as appropriate), and then use it in the same header_write_box as before. We wouldn't be changing the orientation or structure of the header_write_box. I believe the header_write_box's syntax or behavior shouldn't change.
Here's a snippet that might help make my suggestion clear for extending it in the stream_box_edit_view.

        self.stream_write_box = urwid.Text(u"")
        self.header_write_box = urwid.Columns(
            [self.stream_write_box, self.title_write_box],
            dividechars=1
        )

I got your point on this part, let me try adding a helper function for this change then because even with this approach, there would be code duplication.

@Abhirup-99
Copy link
Contributor Author

@prah23 take a look now

@prah23
Copy link
Member

prah23 commented Jan 9, 2021

@Abhirup-99 It looks well segregated 👍. It seems a little more complicated now though, but I got your point about prioritizing non-redundant code. I'm probably still biased towards the stream_box_edit_view extension approach because though it needed registering the stream box again, it seemed simpler to understand for me. We can definitely wait for Neil's opinion, I just wanted to drop in some suggestions, in case they helped.

Also, in your current approach, we wouldn't be needing the is_in_edit boolean, would we? Considering that you have separate views now.

@Abhirup-99
Copy link
Contributor Author

@Abhirup-99 It looks well segregated . It seems a little more complicated now though, but I got your point about prioritizing non-redundant code. I'm probably still biased towards the stream_box_edit_view extension approach because though it needed registering the stream box again, it seemed simpler to understand for me. We can definitely wait for Neil's opinion, I just wanted to drop in some suggestions, in case they helped.

Also, in your current approach, we wouldn't be needing the is_in_edit boolean, would we? Considering that you have separate views now.

Yeah it's required while cycling through the tabs.

@neiljp neiljp added the PR needs review PR requires feedback to proceed label Jan 10, 2021
Copy link
Member

@Ezio-Sarthak Ezio-Sarthak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! The UI seems to be on the right path!

However, there is a scope for improving/simplifying the code logic. Leaving some quick comments below :)

zulipterminal/ui_tools/boxes.py Show resolved Hide resolved
zulipterminal/ui_tools/boxes.py Outdated Show resolved Hide resolved
@neiljp neiljp added this to the Release after next milestone Jan 28, 2021
Base automatically changed from master to main January 30, 2021 20:31
@zulipbot zulipbot added size: M [Automatic label added by zulipbot] and removed has conflicts labels Jan 31, 2021
@neiljp
Copy link
Collaborator

neiljp commented Feb 17, 2021

I see there has been discussion about this - how ready is this?

@Abhirup-99
Copy link
Contributor Author

@neiljp this pr is ready for review. I have removed all conflicts.

@zulipbot
Copy link
Member

Heads up @Abhirup-99, 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 upstream/main branch and resolve your pull request's merge conflicts accordingly.

@neiljp
Copy link
Collaborator

neiljp commented Mar 13, 2022

This code is merged after simplification as #1161, which was itself merged manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has conflicts PR needs review PR requires feedback to proceed size: M [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable cycling to stream and recipients while editing
5 participants