Skip to content

Commit

Permalink
Merge branch 'master' into bash
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Dec 6, 2023
2 parents 9da5dbc + ca52922 commit df2f6cb
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
38 changes: 38 additions & 0 deletions frontend/app/src/components/home/profile/ViewUserProfile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,28 @@
year: "numeric",
});
}
function unsuspendUser() {
client.unsuspendUser(userId).then((success) => {
if (success) {
toastStore.showSuccessToast("unsuspendedUser");
onClose();
} else {
toastStore.showFailureToast("failedToUnsuspendUser");
}
});
}
function suspendUser() {
client.suspendUser(userId, "").then((success) => {
if (success) {
toastStore.showSuccessToast("suspendedUser");
onClose();
} else {
toastStore.showFailureToast("failedToSuspendUser");
}
});
}
</script>

<svelte:window on:resize={onWindowResize} />
Expand Down Expand Up @@ -289,6 +311,18 @@
<Button on:click={unblockUser} small>{$_("profile.unblock")}</Button>
{/if}
</ButtonGroup>
{#if $platformModerator}
<div class="suspend">
<ButtonGroup align={"fill"}>
{#if isSuspended}
<Button on:click={unsuspendUser} small
>{$_("unsuspendUser")}</Button>
{:else}
<Button on:click={suspendUser} small>{$_("suspendUser")}</Button>
{/if}
</ButtonGroup>
</div>
{/if}
</div>
</ModalContent>
</Overlay>
Expand Down Expand Up @@ -371,4 +405,8 @@
}
}
}
.suspend {
margin-top: $sp3;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,11 @@ export class UserIndexClient extends CandidService {

for (const userId of allUsers) {
const cached = fromCacheMap.get(userId);
const userResponse = responseMap.get(userId);
const fromServer = responseMap.get(userId);

if (userResponse !== undefined) {
users.push({
...userResponse,
blobReference: userResponse.blobReference ?? cached?.blobReference,
});
if (fromServer !== undefined) {
responseMap.delete(userId);
users.push(fromServer);
} else if (cached !== undefined) {
if (requestedFromServer.has(userId)) {
// If this user was requested from the server but wasn't included in the response, then that means
Expand All @@ -248,6 +246,11 @@ export class UserIndexClient extends CandidService {
}
}

// This is needed because newly suspended users won't have been included in the `allUsers` array
for (const user of responseMap.values()) {
users.push(user);
}

return {
serverTimestamp: response.serverTimestamp,
users,
Expand Down

0 comments on commit df2f6cb

Please sign in to comment.