fixes for noogle

This commit is contained in:
Believethehype 2024-01-17 15:08:24 +01:00
parent 3587be5b5b
commit 702a151451
4 changed files with 65 additions and 110 deletions

View File

@ -72,9 +72,12 @@ export default {
//await client.addRelay("wss://relay.damus.io");
//await client.addRelay("wss://nos.lol");
await client.addRelay("wss://relay.nostr.band");
await client.addRelay("wss://nostr-pub.wellorder.net")
await client.addRelay("wss://nos.lol");
await client.addRelay("wss://relay.f7z.io")
await client.addRelay("wss://pablof7z.nostr1.com")
//await client.addRelay("wss://relay.nostr.net")
//await client.addRelay("wss://relay.nostr.band");
//await client.addRelay("wss://nostr-pub.wellorder.net")
const pubkey = await nip07_signer.getPublicKey();
await client.connect();

View File

@ -1,101 +0,0 @@
<script setup>
import {EventId, Filter, PublicKey} from "@rust-nostr/nostr-sdk";
import store from '../store';
import {computed, onMounted, ref, watch} from "vue";
const props = defineProps({
content: {
type: String,
required: true
},
author: {
type: String,
required: true
}
})
async function get_user_info(pubkey){
let client = store.state.client
const profile_filter = new Filter().kind(0).author(PublicKey.fromHex(pubkey)).limit(1)
let evts = await client.getEventsOf([profile_filter], 10)
console.log("PROFILES:" + evts.length)
if (evts.length > 0){
let latest_entry = evts[0]
let latest_time = 0
for (const entry of evts){
if (entry.createdAt.asSecs() > latest_time){
latest_time = entry.createdAt.asSecs();
latest_entry = entry
}
}
return JSON.parse(latest_entry.content);
}
}
const content_placeholder = ref()
const author_placeholder = ref()
const author_image_placeholder = ref()
const author_url_placeholder = ref()
onMounted(async () => {
content_placeholder.value = "Event not found"
author_placeholder.value = ""
author_image_placeholder.value = ""
author_url_placeholder.value = ""
content_placeholder.value = props.content //TODO furher parse content
console.log(props.author)
const profile = await get_user_info(props.author)
console.log(profile)
author_placeholder.value = profile["name"]
author_image_placeholder.value = profile["picture"]
author_url_placeholder.value = "https://njump.me/" + PublicKey.fromHex(props.author).toBech32()
})
</script>
<template><div class="playeauthor-wrapper">
<img class="avatar" :src="author_image_placeholder" alt="" />
<a :href="author_url_placeholder" target="_blank">{{ author_placeholder}}</a> </div>
<p>{{ content_placeholder }}</p>
</template>
<style scoped>
.operation-wrapper .operation-icon {
width: 20px;
cursor: pointer;
}
.playeauthor-wrapper {
padding: 5px;
display: flex;
align-items: center;
justify-items: center;
}
.avatar {
margin-right: 10px;
display: inline-block;
width: 30px;
height: 30px;
border-radius: 50%;
object-fit: cover;
box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 10%);
}
</style>

View File

@ -2,11 +2,19 @@
<EasyDataTable v-if="store.state.results.length != 0" table-class-name="customize-table"
:headers="headers"
:items="store.state.results">
<template #item-content="{ content, author, authorurl}">
<a :href="authorurl" target="_blank">{{ author }}</a>
<template #item-content="{ content, author, authorurl, avatar}">
<div class="playeauthor-wrapper">
<img class="avatar" :src="avatar" alt="" />
<a :href="authorurl" target="_blank">{{ author }}</a> </div>
<p>{{content}}</p>
<!-- <NoteRender :content="content" :author="author"/> -->
</template>
<template #expand="item">
<div style="padding: 15px">
<a :href="item.links.njump" target="_blank">NJump</a>
<a :href="item.links.highlighter" target="_blank">Highlighter</a>
<a :href="item.links.nostrudel" target="_blank">Nostrudel</a>
</div>
</template>
</EasyDataTable>
</template>
@ -17,8 +25,6 @@
import type { Header, Item } from "vue3-easy-data-table";
import store from '../store';
import NoteRender from "@/components/NoteRender.vue";
import {EventId, Filter} from "@rust-nostr/nostr-sdk";
const headers: Header[] = [
@ -28,6 +34,25 @@ const headers: Header[] = [
</script>
<style>
.operation-wrapper .operation-icon {
width: 20px;
cursor: pointer;
}
.playeauthor-wrapper {
padding: 5px;
display: flex;
align-items: center;
justify-items: center;
}
.avatar {
margin-right: 10px;
display: inline-block;
width: 30px;
height: 30px;
border-radius: 50%;
object-fit: cover;
box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 10%);
}
.customize-table {
--easy-table-border: 1px solid #445269;
--easy-table-row-border: 1px solid #445269;

View File

@ -40,6 +40,19 @@ async function getEvents(eventids) {
return await client.getEventsOf([event_filter], 5)
}
async function get_user_infos(pubkeys){
let profiles = []
let client = store.state.client
const profile_filter = new Filter().kind(0).authors(pubkeys)
let evts = await client.getEventsOf([profile_filter], 10)
console.log("PROFILES:" + evts.length)
for (const entry of evts){
profiles.push({profile: JSON.parse(entry.content), author: entry.author.toHex(), createdAt: entry.createdAt});
}
return profiles
}
async function listen() {
listener = true
@ -80,10 +93,25 @@ async function listen() {
for (const evt of events){
authors.push(evt.author)
}
let profiles = await get_user_infos(authors)
for (const evt of events){
items.push({ content: evt.content, author: evt.author.toBech32(), authorurl: "https://njump.me/" + evt.author.toBech32(), indicator: {"time": evt.createdAt.toHumanDatetime()}})
console.log(evt.id.toHex())
let p = profiles.find( record => record.author === evt.author.toHex())
console.log(p)
let bech32id = evt.id.toBech32()
let picture = p["profile"]["picture"]
let highlighterurl = "https://highlighter.com/a/" + bech32id
let njumpurl = "https://njump.me/" + bech32id
let nostrudelurl = "https://nostrudel.ninja/#/n/" + evt.id.toBech32()
items.push({ content: evt.content, author: p["profile"]["name"], authorurl: "https://njump.me/" + evt.author.toBech32(), links: {"highlighter": highlighterurl, "njump": njumpurl, "nostrudel": nostrudelurl} , avatar: picture, indicator: {"time": evt.createdAt.toHumanDatetime()}})
}
store.commit('set_search_results', items)