Skip to content

Implements yammer message list#1171

Closed
plamber wants to merge 5 commits intopnp:devfrom
plamber:yammer-message-list
Closed

Implements yammer message list#1171
plamber wants to merge 5 commits intopnp:devfrom
plamber:yammer-message-list

Conversation

@plamber
Copy link
Copy Markdown
Contributor

@plamber plamber commented Oct 22, 2019

Implements #1104

@coveralls
Copy link
Copy Markdown

coveralls commented Oct 22, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling 50a496e on plamber:yammer-message-list into 44a99ba on pnp:dev.

@waldekmastykarz
Copy link
Copy Markdown
Member

Thank you! We'll review it shortly 👍

Copy link
Copy Markdown
Contributor

@VelinGeorgiev VelinGeorgiev left a comment

Choose a reason for hiding this comment

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

Thank you very much Patrick @plamber ! I tested the command and it worked for many of the scenarios so well done. It looks like a complex one and you've managed to make it work.

There are several suggestions for improvement inline in the code as well as two here:

  1. The command should show messages when the --output is text. I could not see any messages when running it in text mode. See the screen above
    image

Yes, I can see a bunch of ids, but no messages are listed, and the command I believe is about messages :)
. Could you make sure you display in text output one of the message formats we get when output is json
parsed, plain or rich? Probably plain? Maybe you can remove the sender or created date or both to save space for the message.

  1. When I run the command like this yammer message list --threaded extended, it still behaves as I would run it like yammer message list --threaded true. If I completely remove the option like yammer message list then it shows more info.

Can I suggest we turn the --threaded option into switch option meaning when it is specified then the threaded=true, when it is not specified then you can automatically assign threaded=extended. This will save you some checks you are doing atm . Please refer to my comments in the code.

Comment thread docs/manual/docs/cmd/yammer/message/message-list.md Outdated
Comment thread src/o365/yammer/commands/message/message-list.ts Outdated
Comment thread src/o365/yammer/commands/message/message-list.ts Outdated
Comment thread src/o365/yammer/commands/message/message-list.ts Outdated
Comment thread src/o365/yammer/commands/message/message-list.ts Outdated
Comment thread src/o365/yammer/commands/message/message-list.ts Outdated
Comment thread src/o365/yammer/commands/message/message-list.ts Outdated
Comment thread src/o365/yammer/commands/message/message-list.ts
Comment thread src/o365/yammer/commands/message/message-list.ts
Comment thread docs/manual/docs/cmd/yammer/message/message-list.md
@plamber
Copy link
Copy Markdown
Contributor Author

plamber commented Oct 27, 2019

@VelinGeorgiev
The message hasn't been shown on purpose since it is not formatting very well (too long text). Initially, I thought to use the JSON parameter to get back everything. On the other side, I agree when you are saying that the command should also return the messages. :)

I simplified the threaded option. You misinterpreted it. These are two separate use cases provided by the Yammer API (thread first message and thread fist message + first two messages of that thread (extended)). I am going to simplify this API by providing just the threaded option without the extension.

I am trying to implement the rest as suggested. I might need help from you on a specific request since I am not 100% sure how to do it properly.

@waldekmastykarz
Copy link
Copy Markdown
Member

waldekmastykarz commented Oct 27, 2019

Would it make sense to show the first n characters of the message? Otherwise, it's hard to find out which message is which based just on its id.

@plamber
Copy link
Copy Markdown
Contributor Author

plamber commented Oct 27, 2019

@waldekmastykarz what about returning the first 25 chars?

@plamber
Copy link
Copy Markdown
Contributor Author

plamber commented Oct 27, 2019

@VelinGeorgiev and @waldekmastykarz

I think the revisited version is better now. I am outputting the first 35 chars of a message in the "test" output version and add "..." in case more text is available.

I simplified the "threaded" part and kept the "extended" parameter completely out of the equation for now. In case it becomes required in the future, we could consider an extension of this command.

@VelinGeorgiev
Copy link
Copy Markdown
Contributor

You misinterpreted it.

Thanks for the clarification @plamber, I indeed did not know how that thing is working. It is somewhat odd the way the Yammer guys implemented this.

I would suggest keeping just option one as you suggested and if there is a need to pull more messages from the specific thread, then we could use another API to pull just the thread messages. I hope that there is such an API. @waldekmastykarz what do you think?

@waldekmastykarz
Copy link
Copy Markdown
Member

Makes sense @VelinGeorgiev 👍

@plamber
Copy link
Copy Markdown
Contributor Author

plamber commented Oct 27, 2019

@VelinGeorgiev I just pushed a small version changing just the order of the commands in the docs and adding the type (n: any)

Copy link
Copy Markdown
Contributor

@VelinGeorgiev VelinGeorgiev left a comment

Choose a reason for hiding this comment

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

Waldek @waldekmastykarz , Patrick @plamber I just noticed that initializing property in the constructor does not work quite as we expect when CLI in interactive mode. Take this example:
image

I would think that the items array should be [] every time we call the command, but in interactive mode the constructor is being called only once ever so we get more and more items in the array with every new command. Here is an example:
image

A simple solution to prevent this could be to reset the value of the property under the commandAction method.
image

This is a valid scenario for all the commands. I would usually use variables inside commandAction method instead of class properties, but I was not doing it intentionally. This is why I caught this behavior just now.

@plamber
Copy link
Copy Markdown
Contributor Author

plamber commented Nov 1, 2019

@VelinGeorgiev let us go for this change. Do you change it directly?

Copy link
Copy Markdown
Contributor

@VelinGeorgiev VelinGeorgiev left a comment

Choose a reason for hiding this comment

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

Thank you Patrick @plamber ! Your PR will be merged from here: https://github.com/VelinGeorgiev/office365-cli/tree/yammer-message-list

You can find some minor changes I did in the comments below.

};

public commandAction(cmd: CommandInstance, args: CommandArgs, cb: () => void): void {
this
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added this line of code to reset the items array in CLI interactive mode this.items = []; // this will reset the items array in interactive mode

}

if (args.options.threaded) {
if (endPoint.indexOf("?") > -1)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added curly brackets to improve readiness.

@waldekmastykarz
Copy link
Copy Markdown
Member

Merged manually. Thank you! 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants