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

refactor: views: Add year in message info view. #930

Closed
wants to merge 2 commits into from

Conversation

jalajcodes
Copy link
Collaborator

Added Year in the message info popup box.
image

Fixes #879

@zulipbot zulipbot added the size: S [Automatic label added by zulipbot] label Feb 18, 2021
zulipterminal/model.py Outdated Show resolved Hide resolved
@neiljp neiljp added PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback area: UI General user interface update labels Feb 18, 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.

This does seem to work OK, but there are some general aspects in general you might wanna know 👍

It is generally preferred to keep a refactor commit in the beginning. One way this helps is to avoid changing related code in multiple commits (referring to one of my comments below). If you think this is something we could add in the docs, do let us know :)

The show_year param might also not need a default value (coz we're validating it anyway).

return local_time.strftime('%a %b %-d %Y %-H:%M:%S')
else:
return local_time.strftime('%a %b %d %H:%M')
format_codes = (
Copy link
Member

Choose a reason for hiding this comment

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

It's a good practice to make intermediate variable names context dependent, in general. Something like "format_date" could work?

@@ -1216,7 +1216,8 @@ def __init__(self, controller: Any, msg: Message, title: str,
self.message_links = message_links
self.time_mentions = time_mentions
date_and_time = controller.model.formatted_local_time(
msg['timestamp'], show_year=True)
msg['timestamp'], show_seconds=True, show_year=True
Copy link
Member

Choose a reason for hiding this comment

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

You might have observed, that you had to change the parameter you added, in both the commits, when you refactor in a later commit. See my review comment for reference :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, I didn't quite catch what you're trying to say. What do you mean by refactor in a later commit? I didn't have to make any changes in this file in the second commit.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, that is surely a confusion. See my comment here Apologies 😅

@jalajcodes
Copy link
Collaborator Author

jalajcodes commented Feb 19, 2021

It is generally preferred to keep a refactor commit in the beginning

Can you please elaborate?

The show_year param might also not need a default value (coz we're validating it anyway).

I don't think so, as removing the default value will make the show_year parameter required and this will cause an error where we don't pass it.

@Ezio-Sarthak

@Ezio-Sarthak
Copy link
Member

Can you please elaborate?

Sure, For instance, I have a commit that adds a key-value pair in a dictionary. As a refactor, I want that dict to convert into an OrderedDict. So, ideally, what I wish to do is to convert that dict to OrderedDict prior to adding key-value pairs in it. To compare with your code, you've added the show_year parameter first and declared a general format_date string in the later commit. Hope this helps :)

I don't think so, as removing the default value will make the show_year parameter required and this will cause an error where we don't pass it.

Ah I see, I thought we're adding show_year param for each call. Apologies for confusion 😅

local_time = datetime.datetime.fromtimestamp(timestamp)
if show_seconds:
return local_time.strftime('%a %b %d %H:%M:%S')
if show_year:
Copy link
Member

Choose a reason for hiding this comment

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

I was referring this addition. Notice that you're indirectly modifying this condition in the later commit (where you're declaring intermediate variable). However, since code-wise this is an insignificant change, I guess we shouldn't bother about discussing it more :)

@zulipbot
Copy link
Member

Heads up @jalajcodes, 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 Feb 20, 2021

@jalajcodes Thanks for working on this! 👍 I just squashed these commits together, made a little reformatting and merged as 74a78be 🎉

I squashed since the commits were very small, though refactoring to put the f-string conditional in-line might have been one option. There was a minor bug in the output with regard to spaces which I fixed - though we should probably add a test for this method to prevent introducing this kind of regression :)

@neiljp neiljp closed this Feb 20, 2021
@neiljp neiljp added this to the Next Release milestone Feb 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: UI General user interface update has conflicts PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback size: S [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Message Info Popup: Add Year to date of message
4 participants