evanyeung / terminal-slack

Terminal client for slack
MIT License
1.03k stars 78 forks source link

Get older messages #52

Open grifball opened 7 years ago

grifball commented 7 years ago

Currently the program only grabs history with the default value for latest 'now', which means it only grabs the default number of messages '100' and older messages can't be retrieved. I like keeping the default number of messages (100) for pagination but also, I want to be able to go back and grab messages older than that. I've coded this into my copy of terminal slack, along with additional controls for history (page up/down home/end), but it's hacky. I'll clean it up and post it here if there's interest.

grifball commented 7 years ago

Actually, I ended up cleaning it up and I applied it to direct messages as well (you can now go back through old history with direct messaging). I started combining the interfaces for Channels, Groups, and IMs into just "Channels" since the API for the 3 seem to be the same. This should link to the latest commit: 92058de6bc24b4378855310a10628feb3dde1d84 The biggest changes are that when you scroll to the top of the chat window and try to scroll further, older messages will load. I also added functionality for page up/down and home/end.

evanyeung commented 7 years ago

Hey, these sound like good ideas overall. Just one thing after a quick look at the most recent commit, please try to keep to a similar style of code and run eslint before committing. It looks like there is some wonky indentation and non-es6 code.

Also, why are channels being merged? And why are channel ids being moved into a channel object?

grifball commented 7 years ago

Hey, thanks for the reply,

I merged channels because it makes it so there's less repeated code. All of the return objects for Channels, Groups, and IMs are pretty much the same, as are their method names in the slack API. I called the combined functions "Channels" because it seemed like a decent name, but it's more like a generic channel interface.

I changed it from using the channel id to using a channel object because the slack API doesn't explicitly state that the first letter of the ID determines it's type and I was going to add a few variables like "is_group" or "is_channel" to avoid parsing the ID. Also, I was using it to store some data that removes some of the need for string parsing. There's a few other spots where just remembering some data objects could help avoid some string parsing, like on the pending messages code, which had a bug in it actually.

Oh yeah, also, I left in timestamps, they're useful for me as they are but I can take them out.

grifball commented 7 years ago

Hey, so I linted it, and fixed a bug, but it still has channel objects, the generic channel interface and timestamps. Let me know if you want any of these removed.

I was thinking about switching development to make an transparent IRC proxy instead, but editing is a great feature of slack that's hard to emulate with an IRC proxy. Still deciding on it, but if I keep working on this project I'll probably implement editing next.