From 3788bf8ec1cbd8b28f644002bc995cf081d5781d Mon Sep 17 00:00:00 2001 From: Believethehype <1097224+believethehype@users.noreply.github.com> Date: Mon, 18 Mar 2024 20:17:17 +0100 Subject: [PATCH] ui fixes --- nostr_dvm/subscription.py | 2 ++ ui/noogle/src/components/Login.vue | 2 ++ .../components/RecommendationGeneration.vue | 25 +++++++++++++++++-- ui/noogle/src/components/helper/Helper.vue | 4 +-- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/nostr_dvm/subscription.py b/nostr_dvm/subscription.py index c1ccb7d..2a63c25 100644 --- a/nostr_dvm/subscription.py +++ b/nostr_dvm/subscription.py @@ -230,6 +230,8 @@ class Subscription: try: while True: time.sleep(60.0) + + print("Checking Subscription") except KeyboardInterrupt: print('Stay weird!') diff --git a/ui/noogle/src/components/Login.vue b/ui/noogle/src/components/Login.vue index c061703..575e2ce 100644 --- a/ui/noogle/src/components/Login.vue +++ b/ui/noogle/src/components/Login.vue @@ -817,11 +817,13 @@ export default { } + console.log("hello") let subscription_status = await hasActiveSubscription(store.state.pubkey.toHex(), nip88.d, evt.author.toHex(), nip88.amounts) nip88.hasActiveSubscription = subscription_status.isActive nip88.subscribedUntil = subscription_status.validUntil nip88.subscriptionId = subscription_status.subscriptionId nip88.expires = subscription_status.expires + console.log(subscription_status) jsonentry.nip88 = nip88 diff --git a/ui/noogle/src/components/RecommendationGeneration.vue b/ui/noogle/src/components/RecommendationGeneration.vue index 3060beb..041e246 100644 --- a/ui/noogle/src/components/RecommendationGeneration.vue +++ b/ui/noogle/src/components/RecommendationGeneration.vue @@ -550,7 +550,10 @@ async function cancelSubscription(kind7001, recipent){ async function subscribe_to_dvm() { - + if (!localStorage.getItem("nostr-key-method") || localStorage.getItem("nostr-key-method") === "anon"){ + miniToastr.showMessage("Login to subscribe to a DVM.", "Not logged in", "error") + return + } // We only arrive here if no subscription exists, we might create a 7001 if it doesnt exist and we zap it let client = store.state.client @@ -641,6 +644,21 @@ async function subscribe_to_dvm() { } + + // TODO this is only for viewing, check event (happens on page reload now) + let subscribeduntil = Timestamp.now().asSecs() + if (this.current_subscription_cadence === "daily"){ + subscribeduntil = Timestamp.now().asSecs() + 60*60*24 + } + else if (this.current_subscription_cadence === "weekly"){ + subscribeduntil = Timestamp.now().asSecs() + 60*60*24 * 7 + } + else if (this.current_subscription_cadence === "monthly"){ + subscribeduntil = Timestamp.now().asSecs() + 60*60*24 * 31 + } + else if (this.current_subscription_cadence === "yearly"){ + subscribeduntil = Timestamp.now().asSecs() + 60*60*24 * 365 + } console.log(content) let msg = JSON.stringify(content) console.log(msg) @@ -649,6 +667,9 @@ async function subscribe_to_dvm() { dvms.find(x => x.nip88.eventid === this.current_subscription_dvm.nip88.eventid).nip88.hasActiveSubscription = true dvms.find(x => x.nip88.eventid === this.current_subscription_dvm.nip88.eventid).nip88.expires = false + dvms.find(x => x.nip88.eventid === this.current_subscription_dvm.nip88.eventid).nip88.subscribedUntil = subscribeduntil + + } catch(error){ console.log(error) @@ -1077,7 +1098,7 @@ const closeNWCModal = () => { - diff --git a/ui/noogle/src/components/helper/Helper.vue b/ui/noogle/src/components/helper/Helper.vue index 6bb0cdd..786a51b 100644 --- a/ui/noogle/src/components/helper/Helper.vue +++ b/ui/noogle/src/components/helper/Helper.vue @@ -382,7 +382,7 @@ export async function hasActiveSubscription(pubkeystring, tiereventdtag, tieraut let subscriptionfilter = new Filter().kind(7003).pubkey(PublicKey.parse(tierauthorid)).customTag(SingleLetterTag.uppercase(Alphabet.P), [pubkeystring]).limit(1) let evts = await client.getEventsOf([subscriptionfilter], Duration.fromSecs(5)) - console.log(evts) + if (evts.length > 0){ console.log(evts[0].asJson()) let matchesdtag = false @@ -419,7 +419,7 @@ export async function hasActiveSubscription(pubkeystring, tiereventdtag, tieraut return subscriptionstatus } - + return subscriptionstatus }