Skip to content

Comments

Added ability to create a group#1

Closed
kelliherm wants to merge 9 commits intomainfrom
create-group
Closed

Added ability to create a group#1
kelliherm wants to merge 9 commits intomainfrom
create-group

Conversation

@kelliherm
Copy link
Collaborator

No description provided.

@kelliherm
Copy link
Collaborator Author

@copilot Please make a review and make sure that everything will work as expected.

Copy link

Copilot AI commented Nov 15, 2025

@kelliherm I've opened a new pull request, #2, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds the ability to create groups with custom or auto-generated codes and introduces group naming functionality. It also refactors map initialization to prevent race conditions and adds cleanup mechanisms for empty groups.

  • Added group creation feature with custom or auto-generated 4-8 character alphanumeric codes
  • Introduced group naming with optional display names that default to the group code
  • Refactored map initialization and added presence cleanup handlers for disconnections

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 259 to 273
setCurrentGroup(code);
// Fetch meta name if exists
try {
const metaSnap = await database.ref(`groups/${code}/meta/name`).once('value');
if (metaSnap.exists()) {
setCurrentGroupName(metaSnap.val());
} else {
setCurrentGroupName(null);
}
} catch (e) {
console.warn('Could not load group name:', e);
}

// Add user to group members
await database.ref(`groups/${code}/members/${user.uid}`).set({
Copy link

Copilot AI Nov 15, 2025

Choose a reason for hiding this comment

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

Missing validation: The function doesn't verify if the group exists before joining. A user can join a non-existent group code, creating an empty group entry. Consider checking if the group exists or has at least one member before allowing a join.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

}
try {
let codeInput = groupCode.trim().toUpperCase();
const codePattern = /^[A-Z0-9]{4,8}$/; // allow 4-8 chars alphanumeric
Copy link

Copilot AI Nov 15, 2025

Choose a reason for hiding this comment

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

Magic numbers in regex pattern. The min length (4) and max length (8) are hardcoded here and also at line 418 (maxLength="8"). Consider extracting these as named constants (e.g., MIN_GROUP_CODE_LENGTH, MAX_GROUP_CODE_LENGTH) to keep them in sync and improve maintainability.

Copilot uses AI. Check for mistakes.
@@ -182,6 +257,17 @@ function App() {

const code = groupCode.toUpperCase();
setCurrentGroup(code);
Copy link

Copilot AI Nov 15, 2025

Choose a reason for hiding this comment

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

State is updated before validation completes. If the subsequent database operations fail (lines 262-284), currentGroup remains set to the failed group code, potentially causing the app to render the map view for a group the user never successfully joined. Move setCurrentGroup to after successful member addition.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

}
console.log('[CreateGroup] Final code selected:', finalCode);
setGroupCode(finalCode);
setCurrentGroup(finalCode); // triggers map view render
Copy link

Copilot AI Nov 15, 2025

Choose a reason for hiding this comment

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

Similar to handleJoinGroup, state is set before database operations complete. If any of the subsequent database writes fail (lines 341-355), the user will see the map view but won't actually be a member of the group. Consider setting setCurrentGroup only after all critical database operations succeed.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

kelliherm and others added 3 commits November 15, 2025 13:46
[WIP] Add ability to create a group
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

Copilot AI commented Nov 15, 2025

@kelliherm I've opened a new pull request, #3, to work on those changes. Once the pull request is ready, I'll request review from you.

kelliherm and others added 2 commits November 15, 2025 13:47
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

Copilot AI commented Nov 15, 2025

@kelliherm I've opened a new pull request, #4, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link

Copilot AI commented Nov 15, 2025

@kelliherm I've opened a new pull request, #5, to work on those changes. Once the pull request is ready, I'll request review from you.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@kelliherm kelliherm closed this Nov 16, 2025
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.

2 participants