mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-04-10 21:00:02 +02:00
add boosts, fix rating for dvms
This commit is contained in:
parent
06b64f9a48
commit
e489c0451a
@ -485,7 +485,7 @@ const submitHandler = async () => {
|
||||
<div v-for="user in dvm.reactions.positive">
|
||||
<div className="wotplayeauthor-wrapper">
|
||||
<figure>
|
||||
<img className="wotavatar" v-if="user.profile.picture" :src="user.profile.picture" onerror="this.src='https://noogle.lol/favicon.ico'" alt="DVM Picture" />
|
||||
<img className="wotavatar" v-if="user.profile && user.profile.picture" :src="user.profile.picture" onerror="this.src='https://noogle.lol/favicon.ico'" alt="DVM Picture" />
|
||||
<img class="wotavatar" v-else src="@/assets/nostr-purple.svg" />
|
||||
</figure>
|
||||
</div>
|
||||
@ -521,7 +521,7 @@ const submitHandler = async () => {
|
||||
|
||||
<figure>
|
||||
|
||||
<img className="wotavatar" v-if="user.profile.picture" :src="user.profile.picture" onerror="this.src='https://noogle.lol/favicon.ico'" alt="DVM Picture" />
|
||||
<img className="wotavatar" v-if="user.profile && user.profile.picture" :src="user.profile.picture" onerror="this.src='https://noogle.lol/favicon.ico'" alt="DVM Picture" />
|
||||
<img class="wotavatar" v-else src="@/assets/nostr-purple.svg" />
|
||||
</figure>
|
||||
|
||||
@ -616,8 +616,7 @@ h3 {
|
||||
.wotplayeauthor-wrapper {
|
||||
padding: 0px;
|
||||
display: flex;
|
||||
align-items: start;
|
||||
justify-items: start
|
||||
|
||||
;
|
||||
}
|
||||
.wotavatar {
|
||||
|
@ -4,7 +4,7 @@
|
||||
:items="data"
|
||||
:sort-by="sortBy"
|
||||
:sort-type="sortType">
|
||||
<template #item-content="{content, author, authorurl, avatar, indicator, links, lud16, id, authorid, zapped, zapAmount, reacted, reactions, event}">
|
||||
<template #item-content="{content, author, authorurl, avatar, indicator, links, lud16, id, authorid, zapped, zapAmount, reacted, reactions, boosts, boosted, event}">
|
||||
|
||||
<div class="playeauthor-wrapper">
|
||||
|
||||
@ -31,6 +31,10 @@
|
||||
|
||||
<div class="flex" >
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="flex" style="margin-left: auto; margin-right: 5px;" v-if="!reacted" @click="react(id, authorid, event)">
|
||||
<div style="margin-left: auto; margin-right: 5px; float: left;">
|
||||
<svg style="margin-top:4px" width="14" height="12" xmlns="http://www.w3.org/2000/svg" class="bi bi-heart" fill-rule="evenodd" fill="currentColor" viewBox="0 0 20 25" clip-rule="evenodd"><path d="M12 21.593c-5.63-5.539-11-10.297-11-14.402 0-3.791 3.068-5.191 5.281-5.191 1.312 0 4.151.501 5.719 4.457 1.59-3.968 4.464-4.447 5.726-4.447 2.54 0 5.274 1.621 5.274 5.181 0 4.069-5.136 8.625-11 14.402m5.726-20.583c-2.203 0-4.446 1.042-5.726 3.238-1.285-2.206-3.522-3.248-5.719-3.248-3.183 0-6.281 2.187-6.281 6.191 0 4.661 5.571 9.429 12 15.809 6.43-6.38 12-11.148 12-15.809 0-4.011-3.095-6.181-6.274-6.181"/></svg> </div>
|
||||
@ -40,15 +44,15 @@
|
||||
</div>
|
||||
<div class="flex" v-if="reacted" style="margin-left: auto; margin-right: 5px;" @click="react(id, authorid, event)">
|
||||
<div style="margin-left: auto; margin-right: 5px; float: left;">
|
||||
<svg style="margin-top:4px" xmlns="http://www.w3.org/2000/svg" width="14" height="12" class="bi bi-heart fill-nostr" viewBox="0 0 20 25"><path d="M12 4.419c-2.826-5.695-11.999-4.064-11.999 3.27 0 7.27 9.903 10.938 11.999 15.311 2.096-4.373 12-8.041 12-15.311 0-7.327-9.17-8.972-12-3.27z"/></svg> </div>
|
||||
<svg style="margin-top:4px" xmlns="http://www.w3.org/2000/svg" width="14" height="12" class="bi bi-heart fill-red-500" viewBox="0 0 20 25"><path d="M12 4.419c-2.826-5.695-11.999-4.064-11.999 3.27 0 7.27 9.903 10.938 11.999 15.311 2.096-4.373 12-8.041 12-15.311 0-7.327-9.17-8.972-12-3.27z"/></svg> </div>
|
||||
|
||||
<div>
|
||||
<p className="text-nostr" style="float: left;">{{reactions}}</p>
|
||||
<p className="text-red-500" style="float: left;">{{reactions}}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="flex" v-if="lud16 != null && lud16 != '' && !zapped" @click="zap_local(lud16, id, authorid)">
|
||||
<div class="flex" v-if="lud16 != null && lud16 != '' && !zapped" style="margin-right: 5px;" @click="zap_local(lud16, id, authorid)">
|
||||
<div style="margin-left: auto; margin-right: 5px; float: left;">
|
||||
<svg style="margin-top:4px" xmlns="http://www.w3.org/2000/svg" width="14" height="16" fill="currentColor" class="bi bi-lightning" viewBox="0 0 16 20">
|
||||
<path d="M5.52.359A.5.5 0 0 1 6 0h4a.5.5 0 0 1 .474.658L8.694 6H12.5a.5.5 0 0 1 .395.807l-7 9a.5.5 0 0 1-.873-.454L6.823 9.5H3.5a.5.5 0 0 1-.48-.641zM6.374 1 4.168 8.5H7.5a.5.5 0 0 1 .478.647L6.78 13.04 11.478 7H8a.5.5 0 0 1-.474-.658L9.306 1z"/>
|
||||
@ -58,7 +62,7 @@
|
||||
<p style="float: left;">{{zapAmount/1000}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex" v-if="lud16 != null && lud16 != '' && zapped" @click="zap_local(lud16, id, authorid)" >
|
||||
<div class="flex" v-if="lud16 != null && lud16 != '' && zapped" style="margin-right: 5px;" @click="zap_local(lud16, id, authorid)" >
|
||||
<div style="margin-left: auto; margin-right: 5px;">
|
||||
<svg style="margin-top:4px" xmlns="http://www.w3.org/2000/svg" width="14" height="16" class="bi bi-lightning fill-amber-400" viewBox="0 0 16 20">
|
||||
<path d="M5.52.359A.5.5 0 0 1 6 0h4a.5.5 0 0 1 .474.658L8.694 6H12.5a.5.5 0 0 1 .395.807l-7 9a.5.5 0 0 1-.873-.454L6.823 9.5H3.5a.5.5 0 0 1-.48-.641z"/>
|
||||
@ -68,6 +72,23 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex" v-if="!boosted" @click="boost(id, authorid, event)">
|
||||
<div style="margin-left: auto; margin-right: 5px; float: left;">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="28" viewBox="0 0 20 34"><path class="bi" fill="currentColor" d="M19 7a1 1 0 0 0-1-1h-8v2h7v5h-3l3.969 5L22 13h-3zM5 17a1 1 0 0 0 1 1h8v-2H7v-5h3L6 6l-4 5h3z"/></svg> </div>
|
||||
|
||||
<div>
|
||||
<p style="float: left;">{{boosts}}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex" v-if="boosted" @click="boost(id, authorid, event)">
|
||||
<div style="margin-left: auto; margin-right: 5px; float: left;">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="28" viewBox="0 0 20 34"><path class="bi fill-green-700" d="M19 7a1 1 0 0 0-1-1h-8v2h7v5h-3l3.969 5L22 13h-3zM5 17a1 1 0 0 0 1 1h8v-2H7v-5h3L6 6l-4 5h3z"/></svg> </div>
|
||||
|
||||
<div>
|
||||
<p className="text-green-700" style="float: left;">{{boosts}}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -125,7 +146,7 @@ async function react(eventid, authorid, evt){
|
||||
content: "🧡",
|
||||
kind: 7,
|
||||
pubkey: store.state.pubkey.toHex(),
|
||||
tags: [],
|
||||
tags: [["e", eventid]],
|
||||
createdAt: Date.now()
|
||||
};
|
||||
let res = await amberSignerService.signEvent(draft)
|
||||
@ -133,22 +154,65 @@ async function react(eventid, authorid, evt){
|
||||
let requestid = res.id;
|
||||
}
|
||||
else {
|
||||
// let event = new EventBuilder(7, "🧡", [])
|
||||
let event = EventBuilder.reaction(evt, "🧡")
|
||||
let requestid = await client.sendEventBuilder(event);
|
||||
}
|
||||
|
||||
objects.reacted = true
|
||||
objects.reactions += 1
|
||||
console.log("reacted")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async function boost(eventid, authorid, evt){
|
||||
|
||||
// TODO
|
||||
let event_id = EventId.parse(eventid)
|
||||
let public_key = PublicKey.parse(authorid);
|
||||
let signer = store.state.signer
|
||||
let client = store.state.client
|
||||
let objects = (props.data.find(x=> x.id === eventid))
|
||||
if (objects !== undefined){
|
||||
if(!objects.boosted ){
|
||||
|
||||
console.log(evt.asJson())
|
||||
let relay = "wss://relay.damus.io"
|
||||
for (let tag of evt.tags){
|
||||
if (tag.asVec()[0] == "relays"){
|
||||
console.log(tag.asVec()[1])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (localStorage.getItem('nostr-key-method') === 'android-signer') {
|
||||
|
||||
let draft = {
|
||||
content: evt.asJson(),
|
||||
kind: 6,
|
||||
pubkey: store.state.pubkey.toHex(),
|
||||
tags: [["e", eventid]],
|
||||
createdAt: Date.now()
|
||||
};
|
||||
let res = await amberSignerService.signEvent(draft)
|
||||
await client.sendEvent(Event.fromJson(JSON.stringify(res)))
|
||||
let requestid = res.id;
|
||||
}
|
||||
else {
|
||||
let event = EventBuilder.repost(evt)
|
||||
let requestid = await client.sendEventBuilder(event);
|
||||
}
|
||||
|
||||
objects.boosted = true
|
||||
objects.boosts += 1
|
||||
|
||||
|
||||
|
||||
//props.data.push.apply(props.data.find(x=> x.id === eventid), objects)
|
||||
|
||||
console.log("reacted")
|
||||
console.log("boosted")
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ import {data} from "autoprefixer";
|
||||
import {requestProvider} from "webln";
|
||||
import Newnote from "@/components/Newnote.vue";
|
||||
import SummarizationGeneration from "@/components/SummarizationGeneration.vue"
|
||||
import {sleep, get_user_infos, get_zaps, hasActiveSubscription, getEventsOriginalOrder, parseandreplacenpubsName} from "../components/helper/Helper.vue"
|
||||
import {sleep, get_user_infos, get_event_reactions, hasActiveSubscription, getEventsOriginalOrder, parseandreplacenpubsName} from "../components/helper/Helper.vue"
|
||||
import {zap, createBolt11Lud16, zaprequest} from "../components/helper/Zap.vue"
|
||||
import { ref } from "vue";
|
||||
import ModalComponent from "../components/Newnote.vue";
|
||||
@ -431,7 +431,7 @@ async function listen() {
|
||||
}
|
||||
|
||||
}
|
||||
let zaps = await get_zaps(ids)
|
||||
let zaps = await get_event_reactions(ids)
|
||||
let items = []
|
||||
let index = 0
|
||||
for (const evt of events) {
|
||||
@ -488,6 +488,8 @@ async function listen() {
|
||||
zapAmount: react.amount,
|
||||
reacted: react.reactedbyUser,
|
||||
reactions: react.reactions,
|
||||
boosts: react.reposts,
|
||||
boosted: react.repostedbyUser
|
||||
|
||||
})
|
||||
index = index + 1
|
||||
|
@ -47,16 +47,37 @@ export async function post_note(note){
|
||||
}
|
||||
export async function react_to_dvm(dvm, reaction) {
|
||||
let client = store.state.client
|
||||
let event = EventBuilder.reaction(dvm.event, reaction)
|
||||
let requestid = await client.sendEventBuilder(event);
|
||||
if (localStorage.getItem('nostr-key-method') === 'android-signer') {
|
||||
let draft = {
|
||||
content: reaction,
|
||||
kind: 7,
|
||||
pubkey: store.state.pubkey.toHex(),
|
||||
tags: [["e", dvm.event.id.toHex()]],
|
||||
createdAt: Date.now()
|
||||
};
|
||||
let res = await amberSignerService.signEvent(draft)
|
||||
await client.sendEvent(Event.fromJson(JSON.stringify(res)))
|
||||
let requestid = res.id;
|
||||
}
|
||||
else {
|
||||
let event = EventBuilder.reaction(dvm.event, reaction)
|
||||
let requestid = await client.sendEventBuilder(event);
|
||||
}
|
||||
|
||||
|
||||
let pk = PublicKey.parse(store.state.pubkey.toHex())
|
||||
|
||||
let users = await get_user_infos([pk])
|
||||
console.log(users[0])
|
||||
if (reaction === "👎"){
|
||||
dvm.reactions.negativeUser = true
|
||||
dvm.reactions.negative.push(store.state.pubkey.toHex())
|
||||
|
||||
|
||||
dvm.reactions.negative.push(users[0])
|
||||
}
|
||||
else {
|
||||
dvm.reactions.positiveUser = true
|
||||
dvm.reactions.positive.push(store.state.pubkey.toHex())
|
||||
dvm.reactions.positive.push(users[0])
|
||||
}
|
||||
|
||||
}
|
||||
@ -164,7 +185,7 @@ export async function get_user_infos(pubkeys){
|
||||
return profiles
|
||||
|
||||
}
|
||||
export async function get_zaps(ids){
|
||||
export async function get_event_reactions(ids){
|
||||
let zapsandreactions = []
|
||||
|
||||
for (let id of ids){
|
||||
@ -172,12 +193,14 @@ export async function get_zaps(ids){
|
||||
id: id.toHex(),
|
||||
amount: 0,
|
||||
reactions: 0,
|
||||
reposts: 0,
|
||||
zappedbyUser: false,
|
||||
reactedbyUser: false,})
|
||||
reactedbyUser: false,
|
||||
repostedbyUser: false,})
|
||||
}
|
||||
|
||||
let client = store.state.client
|
||||
const zap_filter = new Filter().kinds([9735, 7]).events(ids)
|
||||
const zap_filter = new Filter().kinds([9735, 6, 7]).events(ids)
|
||||
let evts = await client.getEventsOf([zap_filter], Duration.fromSecs(10))
|
||||
|
||||
for (const entry of evts){
|
||||
@ -220,6 +243,20 @@ export async function get_zaps(ids){
|
||||
|
||||
|
||||
}
|
||||
else if (entry.kind === 6) {
|
||||
for (let tag of entry.tags) {
|
||||
|
||||
if (tag.asVec()[0] === "e") {
|
||||
if (entry.author.toHex() === localStorage.getItem("nostr-key")) {
|
||||
zapsandreactions.find(x => x.id === tag.asVec()[1]).repostedbyUser = true
|
||||
}
|
||||
zapsandreactions.find(x => x.id === tag.asVec()[1]).reposts += 1
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//console.log(contentjson)
|
||||
|
Loading…
x
Reference in New Issue
Block a user