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

[WIP] footlinks: Add threshold configuration for footlinks. #780

Closed
wants to merge 1 commit into from

Conversation

shanukun
Copy link
Collaborator

@shanukun shanukun commented Aug 19, 2020

This enables user to configure footlinks threshold settings
using footlinks_threshold in zuliprc.

#773 .

@zulipbot zulipbot added the size: S [Automatic label added by zulipbot] label Aug 19, 2020
@shanukun
Copy link
Collaborator Author

@preetmishra can you please review this and suggest the changes regarding linting.

Copy link
Member

@preetmishra preetmishra left a comment

Choose a reason for hiding this comment

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

@shanukun Thanks for working on this. 👍 It seems to work well with footlinks=enabled. However, we'd likely want to only have footlinks_threshold.

The linting error is a mypy bug. It was triggered due to the double dict unpacking in the Controller instantiation.

The code in run.py doesn't seem to be in-line with how the other existing boolean setting is handled. You might want to read the existing code to explore it further. That said, we could also refactor the existing code if you think we could handle it in a better way.

See also https://chat.zulip.org/#narrow/stream/206-zulip-terminal/topic/Configurable.20footlinks.20by.20threshold/near/993363.

def __init__(
self, config_file: str, theme: ThemeSpec, color_depth: int,
autohide: bool, notify: bool, footlinks: bool, footlinks_threshold: int
) -> None:
self.theme = theme
self.color_depth = color_depth
self.autohide = autohide
self.notify_enabled = notify
self.footlinks_enabled = footlinks
Copy link
Member

Choose a reason for hiding this comment

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

We would likely want to only have footlinks_threshold.

@@ -535,7 +535,13 @@ def footlinks_view(
return None

footlinks = []
for link, (text, index, show_footlink) in message_links.items():
for limit, message_link in enumerate(message_links.items()):
# print("Value:", self.model.controller.footlinks_threshold)
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove the print comment. :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah. Definitely.

if (limit == self.model.controller.footlinks_threshold):
break

link, (text, index, show_footlink) = message_link
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps iterate over the key, link, and unpack its value here?

@@ -535,7 +535,13 @@ def footlinks_view(
return None

footlinks = []
for link, (text, index, show_footlink) in message_links.items():
for limit, message_link in enumerate(message_links.items()):
Copy link
Member

Choose a reason for hiding this comment

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

limit feels like a misnomer. Would index be better?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We are already using index for storing message_link index. Using index will not affect the code but it will definitely be confusing.
Maybe pos or position?

Copy link
Member

Choose a reason for hiding this comment

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

Could we rather not change this line and use the existing index for the check? That would be a lot cleaner and would not require #780 (comment) either.

Copy link
Collaborator Author

@shanukun shanukun Aug 20, 2020

Choose a reason for hiding this comment

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

I tried that but message_links does not contain all the links from 1 to n maybe because some links (like chat.zulip.org) are indexed but not added to message_links

  • Here I set footlinks_threshold=5 but I only got 4 links
    Screenshot from 2020-08-21 03-24-55

Copy link
Member

@preetmishra preetmishra Aug 21, 2020

Choose a reason for hiding this comment

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

Ah, yes. We skip trivial footlinks to save screen real-estate. The earlier approach would be okay.

footlinks_threshold = zterm['footlinks_threshold'][0]
if footlinks_threshold.isnumeric():
int_settings['footlinks_threshold'] = int(footlinks_threshold)

Copy link
Member

Choose a reason for hiding this comment

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

See review.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So I should remove footlinks=enabled setting and keep only footlinks_threshold and also should change all bool settings to int?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that's what I was suggesting - remove footlinks and only have footlinks_threshold.

I believe the current set of boolean settings are user-friendly with enabled and disabled. We shouldn't change all the settings to int.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  • I meant storing them in Dict() as int.

@@ -321,7 +327,8 @@ def main(options: Optional[List[str]]=None) -> None:
Controller(zuliprc_path,
theme_data,
int(args.color_depth),
**boolean_settings).main()
**boolean_settings,
**int_settings).main()
Copy link
Member

Choose a reason for hiding this comment

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

See the second point in the review.

@preetmishra
Copy link
Member

@shanukun I was meaning to put this in the last review but it slipped my mind!

You could include Fixes #issue_index in the commit description to let GitHub detect and automatically close the issue as soon as the commit is merged.

You can read more about Zulip's commit guidelines here: https://zulip.readthedocs.io/en/latest/contributing/version-control.html#commit-messages.

@shanukun shanukun force-pushed the enchance-773 branch 2 times, most recently from c3eeec4 to 002bbee Compare August 20, 2020 19:58
@zulipbot zulipbot added size: M [Automatic label added by zulipbot] and removed size: S [Automatic label added by zulipbot] labels Aug 20, 2020
This enables user to configure footlinks threshold settings
using footlinks_threshold in zuliprc.

Fixes zulip#773.
@shanukun
Copy link
Collaborator Author

@preetmishra can you please review the changes again.

@preetmishra
Copy link
Member

preetmishra commented Aug 25, 2020

@shanukun I have not tested the pull request locally, but it appears that we still do not have a way to replicate the 'enabled' mode with the new threshold setting. Let's continue the discussion in #zulip-terminal>Configurable footlinks by threshold before moving ahead with the pull request.

@neiljp
Copy link
Collaborator

neiljp commented Nov 23, 2020

@shanukun @preetmishra Where do we stand on this PR?

@preetmishra
Copy link
Member

@neiljp Primarily, it needs a response from Shanu re the implementation plan that he has as the PR currently doesn't have a way to replicate the original 'enabled' mode, where all the footlinks are shown.

@neiljp neiljp added the PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback label Nov 23, 2020
@neiljp
Copy link
Collaborator

neiljp commented Nov 23, 2020

@preetmishra Thanks for the summary 👍 I think @shanukun may be contributing elsewhere, but of course is welcome to pick this back up.

@neiljp
Copy link
Collaborator

neiljp commented Jan 15, 2021

@shanukun Thanks for your work on starting this feature 👍 @Abhirup-99 has extended this in #841 so I'm closing this now.

@neiljp neiljp closed this Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback size: M [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants