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

Room search changes #41

Merged
merged 9 commits into from
Aug 31, 2020
Merged

Room search changes #41

merged 9 commits into from
Aug 31, 2020

Conversation

ace-1331
Copy link
Contributor

@ace-1331 ace-1331 commented Aug 5, 2020

See the related client-side PR for the description.

This change is compatible with current version. No side effects should be seen.

Highlights

Since the indentation changed and makes the diff look like a lot has changed and I know changing the server is a touchy subject, let me point out what lines I've added/modified here:

Receiving a new optional full room boolean from the query

Here is where we acknowledge it and make it default to existing behavior. (Must be a bool)

var FullRooms = false;
if ((data.FullRooms != null) && (typeof data.FullRooms === "boolean")) FullRooms = data.FullRooms;

Here is the existing if statement modified to take it into account. (TRUE if show full rooms is true or if room is not full).
At this stage we know FullRooms is a boolean.
if ((ChatRoom[C] != null) && ((FullRooms) || (ChatRoom[C].Account.length < ChatRoom[C].Limit)))

Room number

I have changed the query size limit on this line. (24 to 60)
for (var C = ChatRoom.length - 1; ((C >= 0) && (CR.length <= 60)); C--)

Receiving a new ignored room string array from the query

We default to an empty array, if we received an array, we clean it by making sure we only received an array of string and valid room names.

var IgnoredRooms = [];
if ((data.Ignore != null) && (Array.isArray(data.Ignore))) IgnoredRooms = data.Ignore;
var LN = /^[a-zA-Z0-9 ]+$/; 
IgnoredRooms = IgnoredRooms.filter(R => typeof R === "string" && R.match(LN));

We check if the name was ignored in the search loop. If the name of the room is not found, we continue.
This prevents your search from having less than the maximum amount of room if you hide too many rooms (like troll spam rooms).
At this stage, we know IgnoredRooms is an array of string. We also know that the chatroom name is a string and it exists
if (IgnoredRooms.indexOf(ChatRoom[C].Name.toUpperCase()) == -1)

@Ben987 Ben987 merged commit 1809409 into Ben987:master Aug 31, 2020
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