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

Fixes #112 Fix game link orientation #388

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mathgeek
Copy link
Collaborator

@mathgeek mathgeek commented Nov 1, 2021

No description provided.

// }
// )
//
// // TODO: Add asserts on formatSpy - asynchronous nature of event handler breaks spies
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Played around with this for a while - spies always get triggered before the async event handler gets called. Open to any ideas for potentially finding a way around it.

@mathgeek mathgeek changed the title Game link orientation Fixes #112 Fix game link orientation Nov 1, 2021
.map(_.toLower)
.value()
const possibleSources = _.concat(sources, teamNames)
const teamNamesWithContext: SourceWithContext[] = sources
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was my first crack at a data model for passing around the source context - could potentially be extended to add whether notification came from a team (which could help solve #109). This is definitely the biggest change here.

@@ -541,7 +597,7 @@ export async function tellMeWhenHandler(
// -----------------------------------------------------------------------------
export async function helpHandler(bot: SlackBot, message: CommandMessage) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we also have an explicit return type here that will help us catch if we don't return properly in the future? Not necessary for this PR, but in general, I'd like to see us rely less on the type-inference in cases like this.

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'm all in favor of more explicit typing

Copy link
Collaborator

Choose a reason for hiding this comment

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

Great. Same here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't mind type inference in callbacks, where it's obvious, but in top-level functions and the like, I prefer explicit typing.

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 think I'll open a ticket to go through all these handlers later, we should figure out what we want to do with them. Right now these callbacks are (bot, message) => void so we should probably decide if that's the paradigm we want to have in mind with them or if we want to clean them all up and start bubbling up promises for error handling and such

@@ -18,6 +18,17 @@ export const emitter = new ChessLeagueEmitter()
type Context = any
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should get rid of these. :( Fully meant to do that back when I first wrong them. we can turn on eslint no-explicit-any and fix from there.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In this case, I think you should probably go ahead and get rid of this any for this change, to make sure we're probably using the context throughout.

@@ -131,52 +168,73 @@ function formatNoTeamResponse() {
return "You can't use my-team or my-team-channel since you don't have a team right now."
}

export function emitEvent(eventName: string, _league: League, sources: [string, string], context: Context): void {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It might even just make sense to get rid of the emitter pattern entirely, only thing it’s really using now is the reference to the bot object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants