aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authortheiereman <[email protected]>2024-07-01 12:30:27 +0200
committerGitHub <[email protected]>2024-07-01 12:30:27 +0200
commit2714af1eeb8f460b4d42c85ef7bec80b217dc3ea (patch)
tree673e92affa271c5ecc8354690b732b3b24c82985
parent2da6e555ccbdd98266cdbc514dc2f94152053dce (diff)
downloadmonkeytype-2714af1eeb8f460b4d42c85ef7bec80b217dc3ea.tar.gz
monkeytype-2714af1eeb8f460b4d42c85ef7bec80b217dc3ea.zip
impr(server): trim consecutive newlines when updating user profile (theiereman) (#5538)
-rw-r--r--backend/src/api/controllers/user.ts2
-rw-r--r--backend/src/utils/misc.ts1
-rw-r--r--frontend/src/ts/ape/endpoints/users.ts2
-rw-r--r--frontend/src/ts/modals/edit-profile.ts2
4 files changed, 4 insertions, 3 deletions
diff --git a/backend/src/api/controllers/user.ts b/backend/src/api/controllers/user.ts
index 304cc8008..931b4a7f7 100644
--- a/backend/src/api/controllers/user.ts
+++ b/backend/src/api/controllers/user.ts
@@ -847,7 +847,7 @@ export async function updateProfile(
await UserDAL.updateProfile(uid, profileDetailsUpdates, user.inventory);
- return new MonkeyResponse("Profile updated");
+ return new MonkeyResponse("Profile updated", profileDetailsUpdates);
}
export async function getInbox(
diff --git a/backend/src/utils/misc.ts b/backend/src/utils/misc.ts
index e5177a75d..46dc856ad 100644
--- a/backend/src/utils/misc.ts
+++ b/backend/src/utils/misc.ts
@@ -160,6 +160,7 @@ export function sanitizeString(str: string | undefined): string | undefined {
return str
.replace(/[\u0300-\u036F]/g, "")
.trim()
+ .replace(/\n{3,}/g, "\n\n")
.replace(/\s{3,}/g, " ");
}
diff --git a/frontend/src/ts/ape/endpoints/users.ts b/frontend/src/ts/ape/endpoints/users.ts
index 1297745d7..f6b095b83 100644
--- a/frontend/src/ts/ape/endpoints/users.ts
+++ b/frontend/src/ts/ape/endpoints/users.ts
@@ -221,7 +221,7 @@ export default class Users {
async updateProfile(
profileUpdates: Partial<SharedTypes.UserProfileDetails>,
selectedBadgeId?: number
- ): Ape.EndpointResponse<null> {
+ ): Ape.EndpointResponse<SharedTypes.UserProfileDetails> {
return await this.httpClient.patch(`${BASE_PATH}/profile`, {
payload: {
...profileUpdates,
diff --git a/frontend/src/ts/modals/edit-profile.ts b/frontend/src/ts/modals/edit-profile.ts
index c50af841c..b179968fb 100644
--- a/frontend/src/ts/modals/edit-profile.ts
+++ b/frontend/src/ts/modals/edit-profile.ts
@@ -158,7 +158,7 @@ async function updateProfile(): Promise<void> {
return;
}
- snapshot.details = updates;
+ snapshot.details = response.data ?? updates;
snapshot.inventory?.badges.forEach((badge) => {
if (badge.id === currentSelectedBadgeId) {
badge.selected = true;