Skip to content

Commit

Permalink
Merge branch 'master' into swaps
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Dec 13, 2024
2 parents 6007ba4 + 6158e2e commit 4443882
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion frontend/app/src/components/home/PrizeContent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
if (e.isTrusted && chatId.kind !== "direct_chat" && !me && userEligible) {
claimsStore.add(messageId);
client
.claimPrize(chatId, messageId)
.claimPrize(chatId, messageId, e)
.then((success) => {
if (!success) {
toastStore.showFailureToast(i18nKey("prizes.claimFailed"));
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/utils/bots.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { SlashCommandPermissions } from "openchat-client";

export let botsEnabled = localStorage.getItem("openchat_bots_enabled") === "true";
export const botsEnabled = localStorage.getItem("openchat_bots_enabled") === "true";

export function togglePermission<P extends keyof SlashCommandPermissions>(
permissions: SlashCommandPermissions,
Expand Down
13 changes: 8 additions & 5 deletions frontend/openchat-client/src/openchat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5988,13 +5988,16 @@ export class OpenChat extends OpenChatAgentWorker {
});
}

private stackTrace() {
return new Error().stack ?? "";
private validMouseEvent(e: MouseEvent) {
return e instanceof MouseEvent && e.isTrusted && e.type === "click";
}

claimPrize(chatId: MultiUserChatIdentifier, messageId: bigint): Promise<boolean> {
const stack = this.stackTrace();
if (!stack.includes("HTMLButtonElement.click")) {
claimPrize(
chatId: MultiUserChatIdentifier,
messageId: bigint,
e: MouseEvent,
): Promise<boolean> {
if (!this.validMouseEvent(e)) {
return Promise.resolve(false);
}

Expand Down

0 comments on commit 4443882

Please sign in to comment.