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

Add modules for socket events #1175

Merged
merged 1 commit into from
Jun 21, 2017
Merged

Add modules for socket events #1175

merged 1 commit into from
Jun 21, 2017

Conversation

AlMcKinlay
Copy link
Member

This one is probably the biggest modularising one. It is quite big, but it's really awkward to split this one down anymore, and it works quite nicely as a chunk together.

@AlMcKinlay AlMcKinlay mentioned this pull request May 19, 2017
15 tasks
@astorije astorije added this to the 2.4.0 milestone May 19, 2017
@astorije astorije added the Type: Feature Tickets that describe a desired feature or PRs that add them to the project. label May 19, 2017
@@ -0,0 +1,11 @@
"use strict";
const $ = require("jquery");
const sidebar = $("#sidebar, #footer");
Copy link
Member

Choose a reason for hiding this comment

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

Don't need footer.

Copy link
Member Author

Choose a reason for hiding this comment

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

I forgot to remove this. Will do so soon.

if (token) {
return;
}
sidebar.find(".sign-in")
Copy link
Member

Choose a reason for hiding this comment

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

Just remove cached sidebar.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yeah, don't need it, will do so.

@AlMcKinlay AlMcKinlay force-pushed the yamanickill/socket-modules branch from 12b838e to 2fb06ca Compare June 13, 2017 11:15
@AlMcKinlay
Copy link
Member Author

I rebased this, so it should be ready to go. There were a couple of small things that I could see that were added to the socket events since I did this PR, so I copied them over to the modules. A second pair of eyes to check I didn't miss something would be good.

@AlMcKinlay AlMcKinlay force-pushed the yamanickill/socket-modules branch 2 times, most recently from 12b838e to 2fb06ca Compare June 14, 2017 13:43
return array;
}

function sortable() {
Copy link
Member

Choose a reason for hiding this comment

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

Make its own module?

Copy link
Member Author

Choose a reason for hiding this comment

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

We probably could do. I could do that in another PR? It'll be easier to move things out of util.js than lounge.js in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

Alright, I just did it.

@AlMcKinlay AlMcKinlay force-pushed the yamanickill/socket-modules branch from 2fb06ca to aa4a263 Compare June 16, 2017 09:17
@AlMcKinlay
Copy link
Member Author

@xPaw Updated

@AlMcKinlay AlMcKinlay force-pushed the yamanickill/socket-modules branch 2 times, most recently from ddf69e5 to 743e653 Compare June 19, 2017 18:23
@AlMcKinlay
Copy link
Member Author

Re-rebased again. Could someone else review this so we can get this in before we get more conflicts? ;-)

@xPaw xPaw modified the milestones: 2.3.2, 2.4.0 Jun 19, 2017
@astorije
Copy link
Member

Uuuuh, sorry...

screen shot 2017-06-20 at 01 35 38

@@ -0,0 +1,192 @@
"use strict";
Copy link
Member

Choose a reason for hiding this comment

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

Any chance you could add a new line between "use strict"; and what comes after in your files?

If this is just too annoying for you, nevermind then, not a big deal :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, but if this is something we want to enforce we should probably see if there's an eslint rule (or write our own) so we don't have to point it out.

Copy link
Member

@astorije astorije Jun 20, 2017

Choose a reason for hiding this comment

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

I guess http://eslint.org/docs/rules/padding-line-between-statements with explicit stuff for "use strict" would do?

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't look like "use strict" is one of the options there, but possibly. Let's not do this in this PR anyway, we can do that in another.

const sorting = require("./sorting");

const chat = $("#chat");
const sidebar = $("#sidebar, #footer");
Copy link
Member

Choose a reason for hiding this comment

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

This is probably extracted from lounge.js, but do we actually want to keep both selectors in there?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably not? I'm not sure why it was in it in lounge.js so I'll need to figure that out in the first place before I delete the footer.

Copy link
Member Author

Choose a reason for hiding this comment

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

Alrighty, so looking and this is for the buttons in the bottom of the sidebar (add server, help, sign out, etc) which are all still handled in lounge.js, so I have removed it from all the plugins (I checked that it didn't need them in each of them, they all seem to just be doing chan stuff).

renderChannelMessages,
renderChannelUsers,
renderNetworks
};
Copy link
Member

Choose a reason for hiding this comment

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

Another no-big-deal question: I was under the impression that it was fairly common/standard to add the exports statement at the end of the JS files, am I incorrect?

Copy link
Member Author

Choose a reason for hiding this comment

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

So, there are 2 standards, 1 is the add it at the end and 1 is the add it at the beginning.

I tend to add it at the beginning because I like have it front and centre, one of the first things you see when you go in, because it gives you a clear indication what is exported straight away.

@astorije
Copy link
Member

I haven't done a full review because of the conflict (sorry!) but I did test this locally and so far no issues.
I'll do a more comprehensive review when you fix the conflict and I promise to look at merging this next so that you don't have to do it again!

@AlMcKinlay
Copy link
Member Author

Uuuuh, sorry...

Are you? Are you really?

@AlMcKinlay AlMcKinlay force-pushed the yamanickill/socket-modules branch from 743e653 to 2abab89 Compare June 20, 2017 06:02
@AlMcKinlay
Copy link
Member Author

Alright, @astorije I have done everything except removing the "#footer". I'll take a look into that now, but you can review the rest whenever you want.

Copy link
Member

@astorije astorije left a comment

Choose a reason for hiding this comment

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

It's actually pretty much impossible to fully review this. I don't have the cognitive abilities to memorize 600+ removed lines and see if they're all correctly re-added later 😅

But the modularization looks sane, what I saw in the changes seems fine, and I tested this successfully.

@thelounge/maintainers, make sure to update your instance with latest master after this is merged so we can have this running in multiple places before we release v2.3.2 (probably in a few days).

We can look into/fix the footer/sidebar thingy in a separate PR.

@astorije astorije merged commit 0b85582 into master Jun 21, 2017
@astorije astorije deleted the yamanickill/socket-modules branch June 21, 2017 03:42
@AlMcKinlay
Copy link
Member Author

It's actually pretty much impossible to fully review this.

Yeah, I know. But I wasn't making a PR per socket event. That would have been dreadful.

Anyway, 🎉 less than 1000 lines in lounge.js now. I'll give it a break before modularising anything else.

But I would like to ask that new code doesn't go in lounge.js unless it has to now.

matburnham pushed a commit to matburnham/lounge that referenced this pull request Sep 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature Tickets that describe a desired feature or PRs that add them to the project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants