From 650124395b8a42d2a52792492b59f7853bcdc1bf Mon Sep 17 00:00:00 2001
From: gsovereignty
Date: Sat, 11 Nov 2023 13:29:26 +0800
Subject: [PATCH] problem: can't indicate that a problem has been patched
---
.../soft_state/simplifiedProblems.ts | 20 +++--
src/routes/problems/[id]/+page.svelte | 84 ++++++++++++-------
2 files changed, 66 insertions(+), 38 deletions(-)
diff --git a/src/lib/stores/nostrocket_state/soft_state/simplifiedProblems.ts b/src/lib/stores/nostrocket_state/soft_state/simplifiedProblems.ts
index cde899d..ba9f85c 100644
--- a/src/lib/stores/nostrocket_state/soft_state/simplifiedProblems.ts
+++ b/src/lib/stores/nostrocket_state/soft_state/simplifiedProblems.ts
@@ -63,15 +63,17 @@ export function handleProblemStatusChangeEvent(
error =
"you cannot mark this problem as patched unless you are the one who claimed it";
}
- state.Problems.forEach((p) => {
- if (p.ClaimedBy == ev.pubkey) {
- console.log(55);
- error =
- "this pubkey has claimed " +
- p.UID +
- ". Abandon or solve that first before claiming another problem.";
- }
- });
+ if (newStatus == "claimed") {
+ state.Problems.forEach((p) => {
+ if (p.ClaimedBy == ev.pubkey) {
+ console.log(55);
+ error =
+ "this pubkey has claimed " +
+ p.UID +
+ ". Abandon or solve that first before claiming another problem.";
+ }
+ });
+ }
if (error == "") {
problem.Status = newStatus;
problem.ClaimedBy = ev.pubkey;
diff --git a/src/routes/problems/[id]/+page.svelte b/src/routes/problems/[id]/+page.svelte
index 62a3d97..8902ef9 100644
--- a/src/routes/problems/[id]/+page.svelte
+++ b/src/routes/problems/[id]/+page.svelte
@@ -148,8 +148,8 @@
> PATCHED AND WAITING FOR VALIDATION
{/if}
- {#if problem?.Status == "patched"} PATCHED AND WAITING FOR VALIDATION CLOSED
{/if}
@@ -173,6 +173,10 @@
{#if problem?.Status == "claimed"}
Claimed by {claimedBy?.name}
{/if}
+
+ {#if problem?.Status == "patched"}
+ Patched by {claimedBy?.name}
+
{/if}
@@ -182,40 +186,62 @@
-
+
+
-
-
+ {#if claimable}
+
+
+ {/if}
-
-
+ {#if problem?.Status == "claimed"}
+
+ disabled={!(problem?.ClaimedBy == $currentUser?.pubkey)}
+ icon={PlayFilledAlt}
+ size="small"
+ kind="primary"
+ on:click={() => {
+ updateStatus("patched")
+ .then((response) => {
+ console.log(response);
+ })
+ .catch((response) => {
+ console.log(response);
+ statusErrorText = response;
+ });
+ }}>Mark this problem as patched and ready for review
+ {/if}
+
+
+ {#if statusErrorText}
+
+ {/if}
+
- {#if statusErrorText}
-
- {/if}
+
{:else}