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

Settings overhaul #275

Closed
wants to merge 2 commits into from
Closed

Conversation

maxpoulin64
Copy link
Member

@maxpoulin64 maxpoulin64 commented Apr 25, 2016

This redoes pretty much everything related to client-side settings and unties them from the DOM. Most of the action happens in the Settings class in preparation for a future client-side API, which makes listening to setting changes a lot easier. Setting handlers never touches or sees the DOM.

It also makes the binding glue between the settings and the DOM work the other way, so invisible settings are possible and can be tied to multiple controls or sources at once. This could be used later, for example, by a /set command or for any other reason.

Communication with the server is also made separate for good measures, so the settings are usable without any active socket.

A similar API is exposed on the server through client.settings, with the same separation of concerns, and will update all clients. These settings can be further used by the server to save preferences server-side, such as an highlight word list, auto away on/off, and many other things.

Obviously, it comes with a new settings page on the client.


This doesn't exactly solve #85 as the focus of this PR wasn't to fix the settings UI, but to provide the backend infrastructure for server settings so we're not stuck waiting for design just to implement features. It just happened that I had to redo the frontend to both to avoid unnecessary pain plugging it back in, as well as showcase the thing in action.


Suggestions welcome. I think it's really pretty good so far, and allows for a lot of future customization.

capture d ecran_2016-04-24_23-16-49

Demo video: https://d.max-p.me/irc/settings.mp4

@maxpoulin64 maxpoulin64 added the Type: Feature Tickets that describe a desired feature or PRs that add them to the project. label Apr 25, 2016
This redoes pretty much everything related to client-side settings and unties them from the DOM. Most of the action happens in the `Settings` class in preparation for a future client-side API, which makes listening to setting changes a lot easier. Setting handlers never touches or sees the DOM.

It also makes the binding glue between the settings and the DOM work the other way, so invisible settings are possible and can be tied to multiple controls or sources at once. This could be used later, for example, by a `/set` command or for any other reason.

Communication with the server is also made separate for good measures, so the settings are usable without any active socket.

A similar API is exposed on the server through `client.settings`, with the same separation of concerns, and will update all clients. These settings can be further used by the server to save preferences server-side, such as an highlight word list, auto away on/off, and many other things.
});

client.settings.bindToSocket(socket);
Copy link
Member

Choose a reason for hiding this comment

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

This shouldn't be bound in public mode.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually yes. It's not currently needed, but I prefer having the functionality than it being a limitation later on. As I mentioned in the PR text itself, I'm aiming for API-ready code so I try to avoid putting arbitrary limitations. There are a few limited cases in which having the server aware of some settings could be useful. It's not used strictly for settings persistance, but also just for the server to share settings in general. I'm thinking /ignore support, auto away and others.

There's a (one-time) check here to not persist settings in public mode. I'm using client.name so if we eventually allow both public and private mode at the same time, it's ready.

Copy link
Member

Choose a reason for hiding this comment

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

For mixed public/private mode we should have some better check other than client.name then.

@xPaw
Copy link
Member

xPaw commented Apr 25, 2016

We probably want to namespace the settings. As settings like hiding joins, hiding quits, notifyAllMessages ideally would be set per channel.

So the current settings window would be global, and settings in each channel would overrule the channel ones.

}

window.localStorage.setItem("settings", JSON.stringify(options));
settings.element.find("input[name^='setting:'], textarea[name^='setting:']").each(function() {
Copy link
Member

Choose a reason for hiding this comment

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

Why not just use event delegation?

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 could but since this is a two-way sync, I'd need to keep querying and checking the type of element for every setting change. I thought it was clearer that way, especially since we don't have that many boxes to bind.

@xPaw
Copy link
Member

xPaw commented Apr 26, 2016

Just tested this locally, works fine, great work there!

Only suggestion I have is to enable synchronization by default.

@maxpoulin64 maxpoulin64 mentioned this pull request Apr 28, 2016

<div class="col-sm-12">
<h2>
Custom Stylesheet
Copy link
Member

Choose a reason for hiding this comment

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

Make this a label and target it at the textarea please.

@astorije astorije added the Meta: Do Not Merge This PR should not be merged. label Jun 1, 2016
@xPaw xPaw added this to the Next Release milestone Jun 13, 2016
@xPaw xPaw removed this from the Next Release milestone Sep 24, 2016
@AlMcKinlay
Copy link
Member

What's the deal with this? Are we planning on getting this updated to master? I think this is a sorely missed feature that would be fantastic to get in.

@xPaw
Copy link
Member

xPaw commented Dec 17, 2016

I will close this PR for now. I've moved the settings branch into this repository and it needs a major rebase to continue work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Meta: Do Not Merge This PR should not be merged. 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.

None yet

4 participants