From c36990231c96544ebd71ee244f1927e61332f8bd Mon Sep 17 00:00:00 2001 From: megrogan Date: Fri, 19 Jul 2024 10:22:34 +0100 Subject: [PATCH] Clear referral code if invalid/claimed/expired --- frontend/openchat-client/src/openchat.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontend/openchat-client/src/openchat.ts b/frontend/openchat-client/src/openchat.ts index 41a2aaa7a7..51e84272d3 100644 --- a/frontend/openchat-client/src/openchat.ts +++ b/frontend/openchat-client/src/openchat.ts @@ -4347,8 +4347,16 @@ export class OpenChat extends OpenChatAgentWorker { if (this._referralCode !== undefined) { gaTrack("registered_user_with_referral_code", "registration"); } - this.clearReferralCode(); } + + switch (res.kind) { + case "success": + case "referral_code_invalid": + case "referral_code_already_claimed": + case "referral_code_expired": + this.clearReferralCode(); + } + return res; }) .catch(() => ({ kind: "internal_error" }));