-
Notifications
You must be signed in to change notification settings - Fork 6
feat(frontend): finish toast part remove let chatbar handle polling #211
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
Open
PengyuChen01
wants to merge
19
commits into
main
Choose a base branch
from
feat-frontend-add-global-notification-when-project-finish
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
763e534
finish toast part remove let chatbar handle polling
b1d14c1
implement toast component
384b552
finished notification
f4eceea
adjust the bugs for sending getchatdetail twice
d3cc6b2
add my project and community project
175bbc7
finish all the logical part
3552609
my project works
d667c77
add missing global project poller
b7c9245
finish caching problem and half way through the project
86c8eba
current progress
1974769
revert: remove sensitive values from .env.example
ac64d52
working with everything but preview and photourl broken
b0dec4a
revert route
1e27c8d
fix the problem doesn't allow for screenshot
a3376d8
worked screenshot
ee918f2
fix the avatar
3961c14
modify the preview
59f86b0
clear chinese comment and update model
8f2af7c
[autofix.ci] apply automated fixes
autofix-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ import { | |
ForbiddenException, | ||
} from '@nestjs/common'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Between, In, IsNull, Not, Repository } from 'typeorm'; | ||
import { Between, In, Not, Repository } from 'typeorm'; | ||
import { Project } from './project.model'; | ||
import { ProjectPackages } from './project-packages.model'; | ||
import { | ||
|
@@ -644,9 +644,8 @@ export class ProjectService { | |
const limit = input.size > 50 ? 50 : input.size; | ||
|
||
const whereCondition = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add back photoUrl: Not(IsNull()) and is public check |
||
isPublic: true, | ||
isDeleted: false, | ||
photoUrl: Not(IsNull()), | ||
userId: Not(input.currentUserId), // Exclude current user's projects | ||
}; | ||
|
||
if (input.strategy === 'latest') { | ||
|
@@ -808,7 +807,7 @@ export class ProjectService { | |
this.logger.log( | ||
'check if the github project exist: ' + project.isSyncedWithGitHub, | ||
); | ||
// 2) Check user’s GitHub installation | ||
// 2) Check user's GitHub installation | ||
if (!user.githubInstallationId) { | ||
throw new Error('GitHub App not installed for this user'); | ||
} | ||
|
@@ -819,7 +818,7 @@ export class ProjectService { | |
); | ||
const userOAuthToken = user.githubAccessToken; | ||
|
||
// 4) Create the repo if the project doesn’t have it yet | ||
// 4) Create the repo if the project doesn't have it yet | ||
if (!project.githubRepoName || !project.githubOwner) { | ||
// Use project.projectName or generate a safe name | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { | ||
BadRequestException, | ||
ConflictException, | ||
Injectable, | ||
NotFoundException, | ||
} from '@nestjs/common'; | ||
|
@@ -107,4 +108,69 @@ export class UserService { | |
|
||
return true; | ||
} | ||
|
||
/** | ||
* Checks if a username already exists in the database | ||
* @param username Username to check | ||
* @param excludeUserId Optional user ID to exclude from the check (for updates) | ||
* @returns Boolean indicating if the username exists | ||
*/ | ||
async isUsernameExists( | ||
username: string, | ||
excludeUserId?: string, | ||
): Promise<boolean> { | ||
const query = this.userRepository | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like unuse code please remove if is really unuse |
||
.createQueryBuilder('user') | ||
.where('LOWER(user.username) = LOWER(:username)', { | ||
username: username.toLowerCase(), | ||
}); | ||
|
||
if (excludeUserId) { | ||
query.andWhere('user.id != :userId', { userId: excludeUserId }); | ||
} | ||
|
||
const count = await query.getCount(); | ||
return count > 0; | ||
} | ||
|
||
/** | ||
* Updates a user's username with uniqueness validation | ||
* @param userId User ID | ||
* @param newUsername New username to set | ||
* @returns Updated user object | ||
*/ | ||
async updateUsername(userId: string, newUsername: string): Promise<User> { | ||
if (!newUsername || newUsername.trim().length < 3) { | ||
throw new BadRequestException( | ||
'Username must be at least 3 characters long', | ||
); | ||
} | ||
|
||
// Check if the username is already taken | ||
const exists = await this.isUsernameExists(newUsername, userId); | ||
if (exists) { | ||
throw new ConflictException( | ||
`Username '${newUsername}' is already taken. Please choose another one.`, | ||
); | ||
} | ||
|
||
const user = await this.userRepository.findOneBy({ id: userId }); | ||
if (!user) { | ||
throw new NotFoundException('User not found'); | ||
} | ||
|
||
user.username = newUsername; | ||
|
||
try { | ||
return await this.userRepository.save(user); | ||
} catch (error) { | ||
// Check for unique constraint error (just in case of race condition) | ||
if (error.code === '23505' || error.message.includes('duplicate')) { | ||
throw new ConflictException( | ||
`Username '${newUsername}' is already taken. Please choose another one.`, | ||
); | ||
} | ||
throw error; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove all test code in pr like this