Browse Source

some cleanup, comment out console

develop
dskvr 2 years ago
parent
commit
9df1d47274
  1. 4
      onion.js
  2. 6
      scripts/geo.js
  3. 10
      scripts/relays.js
  4. 12
      src/components/layout/HeaderComponent.vue
  5. 6
      src/components/relays/blocks/MapSingle.vue
  6. 54
      src/components/relays/blocks/MapSummary.vue
  7. 10
      src/components/relays/blocks/RelaysResultTable.vue
  8. 2
      src/components/relays/nav/RelaysFindNav.vue
  9. 4
      src/components/relays/nav/RelaysNav.vue
  10. 6
      src/components/relays/pages/RelaysFind.vue
  11. 2
      src/components/relays/pages/RelaysHome.vue
  12. 12
      src/components/relays/pages/RelaysMap.vue
  13. 16
      src/components/relays/pages/RelaysSingle.vue
  14. 6
      src/components/relays/pages/RelaysStatistics.vue
  15. 24
      src/components/relays/tasks/HistoryTask.vue
  16. 53
      src/components/relays/tasks/RefreshTask.vue
  17. 18
      src/components/user/AuthComponent.vue
  18. 4
      src/shared/events.js
  19. 14
      src/shared/hash-router.js
  20. 18
      src/shared/history.js
  21. 2
      src/shared/pool.js
  22. 2
      src/shared/relays-lib.js
  23. 2
      src/store/relays.js

4
onion.js

@ -5,10 +5,10 @@ const SocksProxyAgent = require('socks-proxy-agent');
// Use the SOCKS_PROXY env var if using a custom bind address or port for your TOR proxy:
const proxy = process.env.SOCKS_PROXY || 'socks5h://127.0.0.1:9050';
console.log('Using proxy server %j', proxy);
//console.log('Using proxy server %j', proxy);
// The default HTTP endpoint here is DuckDuckGo's v3 onion address:
const endpoint = process.argv[2] || 'https://duckduckgogg42xjoc72x3sjasowoarfbgcmvfimaftt6twagswzczad.onion';
console.log('Attempting to GET %j', endpoint);
//console.log('Attempting to GET %j', endpoint);
// Prepare options for the http/s module by parsing the endpoint URL:
let options = url.parse(endpoint);
const agent = new SocksProxyAgent(proxy);

6
scripts/geo.js

@ -16,7 +16,7 @@ const getDns = async function(relay){
await fetch(`https://1.1.1.1/dns-query?name=${relay.replace('wss://', '')}`, { headers: { 'accept': 'application/dns-json' } })
.then(response => response.json())
.then((data) => { dns = data.Answer ? data.Answer : false })
.catch(err => console.log('./scripts/geo.js', err))
.catch(err => //console.log('./scripts/geo.js', err))
return dns
}
@ -58,7 +58,7 @@ const query = async function(){
for (const relay of relays) {
await delay(1000).then(async () => {
console.log('getting relay geo', relay)
//console.log('getting relay geo', relay)
let dns, ip, geo
@ -90,7 +90,7 @@ const run = async function(){
object = { geo: result }
yaml = new YAML.Document()
yaml.contents = object
// console.log(object)
// //console.log(object)
fs.writeFile(outFile, yaml.toString(), (err) => {
if (err) return console.error('./scripts/geo.js', err);
});

10
scripts/relays.js

@ -53,7 +53,7 @@ async function getRelays(){
// .then(json => relaysKnown = json.relays)
const relaysObj = yaml.load(fs.readFileSync('./relays.yaml', 'utf8'))
relaysKnown = relaysObj.relays
console.log(relaysKnown)
//console.log(relaysKnown)
return
}
@ -65,11 +65,11 @@ async function discover(){
const pool = RelayPool(['wss://nostr.sandwich.farm'])
pool
.on('open', relay => {
// console.log('open')
// //console.log('open')
relay.subscribe(subid, {limit: 1000, kinds:[3]})
})
.on('close', () => {
// console.log('close')
// //console.log('close')
})
.on('event', (relay, _subid, event) => {
if(subid == _subid) {
@ -119,11 +119,11 @@ const sanitizeRelay = function(relay) {
const checkRemoteRelays = async function(){
for(let i=0;i<relaysRemote.length;i++) {
// console.log('check for connect', remoteMerged[i])
// //console.log('check for connect', remoteMerged[i])
await checkRelay(relaysRemote[i])
.catch( () => {
remove.push(relaysRemote[i])
console.log('removals:', remove.length, relaysRemote[i])
//console.log('removals:', remove.length, relaysRemote[i])
})
}
}

12
src/components/layout/HeaderComponent.vue

@ -20,11 +20,21 @@
</div> -->
<div class="hidden sm:ml-6 sm:block">
<div class="flex space-x-4">
<router-link
to="/relays/find"
:class="[false ? 'bg-gray-900 text-white' : 'text-gray-300 hover:bg-gray-700 hover:text-white', 'px-3 py-2 rounded-md text-sm font-medium']" >
:active-class="`bg-white/25`"
class="text-white hover:bg-white/25 px-3 py-2 rounded-md text-sm font-medium"
>
Relays
</router-link>
<a
href="https://github.com/dskvr/nostr-watch"
target="_blank"
class="text-white hover:bg-white/25 px-3 py-2 rounded-md text-sm font-medium"
>
Source
</a>
<!-- <router-link to="/about">about</router-link>
<a
href="/"

6
src/components/relays/blocks/MapSingle.vue

@ -54,7 +54,7 @@ export default {
const ll = [this.geo?.lat, this.geo?.lon]
this.center = ll
console.log('lat long', this.relay, ll)
//console.log('lat long', this.relay, ll)
return ll
},
@ -62,7 +62,7 @@ export default {
const relay = this.relay
//console.log(this.geo?.lat, this.geo?.lon)
////console.log(this.geo?.lat, this.geo?.lon)
if(!this.geo?.lat || !this.geo?.lon)
return 'transparent'
@ -82,7 +82,7 @@ export default {
}
},
async beforeMount() {
console.log(this.geo)
//console.log(this.geo)
this.center = this.getLatLng()
this.markerColor = this.getCircleColor()
},

54
src/components/relays/blocks/MapSummary.vue

@ -89,14 +89,14 @@ export default defineComponent({
},
data() {
console.log(this.store.layout.mapIsExpanded, {
zoom: this.store.layout.mapIsExpanded ? 4 : 2,
minZoom: this.store.layout.mapIsExpanded ? 4 : 2,
maxZoom: this.store.layout.mapIsExpanded ? 7 : 2,
// center: this.store.layout.mapIsExpanded ? [40.41322, -1.219482] : [70.41322, -1.219482],
expanded: false,
relays: []
})
// console.log(this.store.layout.mapIsExpanded, {
// zoom: this.store.layout.mapIsExpanded ? 4 : 2,
// minZoom: this.store.layout.mapIsExpanded ? 4 : 2,
// maxZoom: this.store.layout.mapIsExpanded ? 7 : 2,
// // center: this.store.layout.mapIsExpanded ? [40.41322, -1.219482] : [70.41322, -1.219482],
// expanded: false,
// relays: []
// })
return {
zoom: this.store.layout.mapIsExpanded ? 4 : 2,
minZoom: 2,
@ -112,11 +112,11 @@ export default defineComponent({
async mounted() {
this.geo = this.store.relays.geo
this.store.layout.$subscribe( mutation => {
console.log('mutation.key', mutation.events.key)
// if(mutation.events.key == "mapExpanded")
// this.refreshMap()
})
// this.store.layout.$subscribe( mutation => {
// //console.log('mutation.key', mutation.events.key)
// // if(mutation.events.key == "mapExpanded")
// // this.refreshMap()
// })
setTimeout(async () => {
await this.$refs.map.leafletObject
@ -125,7 +125,7 @@ export default defineComponent({
this.store.layout.mapIsExpanded ? 4 : 2
)
}, 500)
console.log(this.$refs.map.leafletObject)
//console.log(this.$refs.map.leafletObject)
// this.$refs.map.leafletObject.setView(
// this.store.layout.mapIsExpanded ? [40.41322, -1.219482] : [35.41322, -1.219482],
// 4
@ -135,10 +135,10 @@ export default defineComponent({
// this.refreshMap()
},
beforeUnmount(){
console.log('beforeUnmount', '$refs', this.$refs)
//console.log('beforeUnmount', '$refs', this.$refs)
},
unmounted(){
console.log('unmounted', '$refs', this.$refs)
//console.log('unmounted', '$refs', this.$refs)
delete this.$refs.map
},
updated(){},
@ -179,8 +179,8 @@ export default defineComponent({
nipLink(){
return (key) => `https://github.com/nostr-protocol/nips/blob/master/${this.nipSignature(key)}.md`
},
getCircleClass(relay){
console.log('the relay', relay)
getCircleClass(){
//console.log('the relay', relay)
return (relay) => {
return {
visible: this.isRelayInActiveSubsection(relay),
@ -214,11 +214,11 @@ export default defineComponent({
}
},
showCircles(){
console.log('map is collapsed', !this.store.layout.mapIsExpanded)
//console.log('map is collapsed', !this.store.layout.mapIsExpanded)
return !this.store.layout.mapIsExpanded
},
showMarkers(){
console.log('map is expanded', this.store.layout.mapIsExpanded)
//console.log('map is expanded', this.store.layout.mapIsExpanded)
return this.store.layout.mapIsExpanded
},
getLat(){
@ -238,14 +238,14 @@ export default defineComponent({
try {
await navigator.clipboard.writeText(text);
} catch($e) {
//console.log('Cannot copy');
////console.log('Cannot copy');
}
},
getLatLng(relay){
return [this.getLat(relay), this.getLon(relay)]
},
async handleToggleMap(){
console.log('toggle state', this.store.layout.mapIsExpanded, this.$refs.map.leafletObject)
//console.log('toggle state', this.store.layout.mapIsExpanded, this.$refs.map.leafletObject)
this.store.layout.toggleMap()
if(this.store.layout.mapIsExpanded)
@ -272,7 +272,7 @@ export default defineComponent({
this.refreshMap()
// .panTo(this.store.layout.mapIsExpanded ? [40.41322, -1.219482] : [70.41322, -1.219482])
// this.shiftMap()
console.log('toggle state', this.store.layout.mapIsExpanded)
//console.log('toggle state', this.store.layout.mapIsExpanded)
},
resetMapSize(){
console.dir('reset map size?', this.$refs.map.leafletObject)
@ -486,10 +486,10 @@ export default defineComponent({
this.geo = this.store.relays.geo
},
beforeUnmount(){
console.log('beforeUnmount', '$refs', this.$refs)
//console.log('beforeUnmount', '$refs', this.$refs)
},
unmounted(){
console.log('unmounted', '$refs', this.$refs)
//console.log('unmounted', '$refs', this.$refs)
delete this.$refs.map
},
updated(){},
@ -509,7 +509,7 @@ export default defineComponent({
},
computed: {
getCircleClass(relay){
console.log('the relay', relay)
//console.log('the relay', relay)
return (relay) => {
return {
visible: this.isRelayInActiveSubsection(relay),
@ -519,7 +519,7 @@ export default defineComponent({
}
},
getMarkerClass(relay){
console.log('the relay', relay)
//console.log('the relay', relay)
return (relay) => {
return {
visible: this.isRelayInActiveSubsection(relay),

10
src/components/relays/blocks/RelaysResultTable.vue

@ -162,18 +162,18 @@
},
mounted(){
console.log('navdata', this.navData, this.navData.filter( item => item.slug == this.subsection )[0], this.navData.filter( item => item.slug == this.subsection ))
//console.log('navdata', this.navData, this.navData.filter( item => item.slug == this.subsection )[0], this.navData.filter( item => item.slug == this.subsection ))
this.activePageData = this.navData.filter( item => item.slug == this.subsection )[0]
},
updated(){
// console.log('state, updated')
// //console.log('state, updated')
},
beforeUnmount(){
console.log('relays list', 'beforeUnmount()', this.subsection)
//console.log('relays list', 'beforeUnmount()', this.subsection)
},
unmounted(){
console.log('relays list unmounted', this.subsection)
//console.log('relays list unmounted', this.subsection)
delete this.results
},
props: {
@ -223,7 +223,7 @@
},
getResultClass() {
return (relay, index) => {
console.log(this.store.prefs.getTheme)
//console.log(this.store.prefs.getTheme)
return {
loaded: this.results[relay]?.state == 'complete',
'bg-slate-100': index % 2,

2
src/components/relays/nav/RelaysFindNav.vue

@ -100,7 +100,7 @@ computed: {
parseHash,
getNavButtonClass(){
return (slug) => {
// console.log('active?', this.contentIsActive(slug), this.isActive(slug), this.store.layout.getActive('relays/find'), this.store.layout.getActiveItem == slug)
// //console.log('active?', this.contentIsActive(slug), this.isActive(slug), this.store.layout.getActive('relays/find'), this.store.layout.getActiveItem == slug)
return {
'py-1 px-2': this.store.prefs.getTheme === 'compact',
'text-lg py-2 px-3': this.store.prefs.getTheme === 'comfortable',

4
src/components/relays/nav/RelaysNav.vue

@ -65,12 +65,12 @@ export default defineComponent({
},
beforeMount(){
console.log('rightt now', this.store.layout)
//console.log('rightt now', this.store.layout)
// this.mountNav('section', this.store.layout.getNavGroup('relays'))
},
mounted(){
console.log('mounted in relays find nav')
//console.log('mounted in relays find nav')
},
methods: Object.assign(RelaysLib, setupNavData, mountNav, setActiveContent, loadNavContent, routeValid, parseHash, contentIsActive),
computed: {

6
src/components/relays/pages/RelaysFind.vue

@ -108,7 +108,7 @@ export default defineComponent({
watch: {
results: function(){
console.log('results changed.')
//console.log('results changed.')
}
},
@ -128,13 +128,13 @@ export default defineComponent({
},
async mounted() {
console.log("findrelays mounted", this.results)
//console.log("findrelays mounted", this.results)
this.navSubsection.forEach( item => this.relaysCount[item.slug] = 0 ) //move this
// this.relays.forEach(relay => {
// this.results[relay] = this.getCache(relay)
// })
console.log('RESULTS!', this.navSubsection, this.relays, this.results)
//console.log('RESULTS!', this.navSubsection, this.relays, this.results)
// this.relaysMountNav()
},

2
src/components/relays/pages/RelaysHome.vue

@ -103,7 +103,7 @@ export default defineComponent({
updated(){},
unmounted(){
console.log('findrelays', 'unmounted()')
//console.log('findrelays', 'unmounted()')
delete this.results
},

12
src/components/relays/pages/RelaysMap.vue

@ -78,12 +78,12 @@ export default defineComponent({
}
},
mounted() {
console.log('results', this.results)
//console.log('results', this.results)
this.geo = this.store.relays.geo
},
updated(){},
unmounted(){
console.log('unmounted', '$refs', this.$refs)
//console.log('unmounted', '$refs', this.$refs)
delete this.$refs.map
},
props: {
@ -101,8 +101,8 @@ export default defineComponent({
},
},
computed: {
getCircleClass(relay){
console.log('the relay', relay)
getCircleClass(){
//console.log('the relay', relay)
return (relay) => {
return {
visible: this.isRelayInActiveSubsection(relay),
@ -120,7 +120,7 @@ export default defineComponent({
return this.expanded ? "500px" : "250px"
},
getLatLng(relay){
// console.log('geo', relay, [this.geo.lat, this.geo.lon])
// //console.log('geo', relay, [this.geo.lat, this.geo.lon])
return [this.geo[relay].lat, this.geo[relay].lon]
},
getCircleColor(relay){
@ -139,7 +139,7 @@ export default defineComponent({
},
isRelayInActiveSubsection(relay){
// console.log(this.store.relays.getRelays(this.activePageItem).length, this.activePageItem, relay, this.store.relays.getRelays(this.activePageItem).includes(relay))
// //console.log(this.store.relays.getRelays(this.activePageItem).length, this.activePageItem, relay, this.store.relays.getRelays(this.activePageItem).includes(relay))
return this.store.relays.getRelays(this.activePageItem, this.results).includes(relay)
},
toggleMap(){

16
src/components/relays/pages/RelaysSingle.vue

@ -446,7 +446,7 @@ const localMethods = {
try {
await navigator.clipboard.writeText(text);
} catch($e) {
//console.log('Cannot copy');
////console.log('Cannot copy');
}
},
getAdminNotes(){
@ -455,7 +455,7 @@ const localMethods = {
const relays = this.store.relays.getAggregateCache('public')
console.log('public relays', this.store.relays.getAggregateCache('public').length)
//console.log('public relays', this.store.relays.getAggregateCache('public').length)
const pool = new RelayPool(relays)
const subid = crypto.randomBytes(40).toString('hex')
@ -494,8 +494,8 @@ const localMethods = {
u.add(event.id)
if(parseInt(event.kind) === 0)
this.store.profile.set(JSON.parse(event.content))
console.log(`kind: ${event.kind} found`, '... total', u.size, Object.keys(this.events[event.kind]).length)
console.log( 'event!', event.content )
//console.log(`kind: ${event.kind} found`, '... total', u.size, Object.keys(this.events[event.kind]).length)
//console.log( 'event!', event.content )
})
.on('eose', relay => {
relay.close()
@ -525,7 +525,7 @@ const localMethods = {
content = event.content
}
console.log('all about the event')
//console.log('all about the event')
return {
id: event,
type: this.setEventType(event),
@ -657,7 +657,7 @@ export default defineComponent({
}
},
getGeoClass(){
console.log('ok', !this.result?.info && !this.log)
//console.log('ok', !this.result?.info && !this.log)
return {
'col-span-2': !this.result?.info && !this.log,
}
@ -692,10 +692,10 @@ export default defineComponent({
this.lastUpdate = this.store.relays.getLastUpdate
this.result = this.getCache(this.relay) || false
//
console.log('single result', this.relayFromUrl, this.result, this.getCache(this.relay))
//console.log('single result', this.relayFromUrl, this.result, this.getCache(this.relay))
this.geo = this.store.relays.getGeo(this.relay)
console.log(this.relay, this.lastUpdate, this.result, this.geo)
//console.log(this.relay, this.lastUpdate, this.result, this.geo)
}
}),

6
src/components/relays/pages/RelaysStatistics.vue

@ -149,7 +149,7 @@ export default defineComponent({
nips[nip].add(result.uri)
})
})
console.log('supported nips', nips)
//console.log('supported nips', nips)
return nips
},
collateContinents(){
@ -166,7 +166,7 @@ export default defineComponent({
byCont[cont] = new Set()
byCont[cont].add(relay)
})
console.log('continents', byCont)
//console.log('continents', byCont)
return byCont;
},
collateCountries(){
@ -183,7 +183,7 @@ export default defineComponent({
byCountry[cont] = new Set()
byCountry[cont].add(relay)
})
console.log('countries', byCountry)
//console.log('countries', byCountry)
return byCountry;
},
},

24
src/components/relays/tasks/HistoryTask.vue

@ -64,7 +64,7 @@ export default defineComponent({
nips[nip].add(result.uri)
})
})
console.log('supported nips', nips)
//console.log('supported nips', nips)
return nips
},
collateContinents(){
@ -81,7 +81,7 @@ export default defineComponent({
byCont[cont] = new Set()
byCont[cont].add(relay)
})
console.log('continents', byCont)
//console.log('continents', byCont)
return byCont;
},
collateCountries(){
@ -98,7 +98,7 @@ export default defineComponent({
byCountry[cont] = new Set()
byCountry[cont].add(relay)
})
console.log('countries', byCountry)
//console.log('countries', byCountry)
return byCountry;
},
import { RelayPool } from 'nostr'
@ -133,7 +133,7 @@ export default defineComponent({
//set uniques
uniques = new Set(relays)
console.log(uniques, uniques.size)
//console.log(uniques, uniques.size)
const final = []
@ -144,11 +144,11 @@ export default defineComponent({
final.push( [relay, relayTimeCodes[relay][0] ] )
})
console.log('before sort', final[0])
//console.log('before sort', final[0])
final.sort( (a, b) => a[1]-b[1] )
console.log('afdter sort', final[0])
//console.log('afdter sort', final[0])
return final
}
@ -166,19 +166,19 @@ export default defineComponent({
const pool = RelayPool(this.store.relays.getAll.filter( (relay) => this.results?.[relay]?.aggregate == 'public').filter( relay => this.results?.[relay]?.info?.supported_nips.includes(15)))
pool
.on('open', relay => {
// console.log('open')
// //console.log('open')
relay.subscribe(subid, {since: 1609829, limit: 10000, kinds:[3]})
})
.on('eose', (relay) => {
console.log('closing', relay.url)
//console.log('closing', relay.url)
relay.close()
resolve(true)
})
.on('event', (relay, _subid, event) => {
if(subid == _subid) {
console.log(total++)
//console.log(total++)
try {
// console.log(event)
// //console.log(event)
const parsed = JSON.parse(event.content)
relaysRemote = Object.assign(relaysRemote, parsed)
Object.keys(parsed).forEach( key => {
@ -231,11 +231,11 @@ export default defineComponent({
// const checkRemoteRelays = async function(){
// for(let i=0;i<relaysRemote.length;i++) {
// // console.log('check for connect', remoteMerged[i])
// // //console.log('check for connect', remoteMerged[i])
// await checkRelay(relaysRemote[i])
// .catch( () => {
// remove.push(relaysRemote[i])
// console.log('removals:', remove.length, relaysRemote[i])
// //console.log('removals:', remove.length, relaysRemote[i])
// })
// }
// }

53
src/components/relays/tasks/RefreshTask.vue

@ -42,6 +42,26 @@ import { geo } from '../../../../cache/geo.yaml'
const localMethods = {
migrateLegacy(){
let hit = false
for(let i=0;i<relays.length;i++) {
const cache = localStorage.getItem(`nostrwatch_${relays[i]}`)
if(!cache)
continue
hit = true
break;
}
if(hit){
relays.forEach( relay => {
const oldKey = `nostrwatch_${relay}`
const oldCache = localStorage.getItem(oldKey)
if(oldCache instanceof Object)
this.setCache(oldCache)
localStorage.removeItem(oldKey)
})
}
},
addToQueue: function(id, fn){
this.store.tasks.addJob({
id: id,
@ -82,7 +102,7 @@ const localMethods = {
// this.addToQueue('relays/single', () => this.invalidate(false, relayUrl))
// },
invalidate: async function(force, single){
console.log('invalidate()', this.relays.length, force || this.isExpired )
//console.log('invalidate()', this.relays.length, force || this.isExpired )
if( (!this.isExpired && !force) )
return
@ -93,7 +113,7 @@ const localMethods = {
const relays = this.relays.filter( relay => !this.store.tasks.isProcessed('relays', relay) )
console.log('filtered relays', relays)
//console.log('filtered relays', relays)
// if(this.pageOpen > 4*60*1000)
// this.store.tasks.setRate('relays/find', 0)
@ -101,29 +121,29 @@ const localMethods = {
// this.store.tasks.setRate('relays/find', 2000)
if(single) {
console.log('single relay', single)
//console.log('single relay', single)
await this.check(single)
}
else {
console.log('multiple relays', single)
//console.log('multiple relays', single)
// const processed = new Set()
for(let index = 0; index < relays.length; index++) {
const relay = relays[index]
console.log('checking relay', relay)
//console.log('checking relay', relay)
this.check(relay)
.then((result) => {
console.log('check completed', relay)
//console.log('check completed', relay)
if(this.store.tasks.isProcessed('relays', relay))
return
console.log('unique check', relay)
//console.log('unique check', relay)
this.store.tasks.addProcessed('relays', result.uri)
this.results[result.uri] = result
this.setCache(result)
console.log('cache set', result.uri, result)
//console.log('cache set', result.uri, result)
if(this.store.tasks.getProcessed('relays').length >= this.relays.length)
this.completeAll()
@ -139,18 +159,18 @@ const localMethods = {
},
completeAll: function(){
console.log('completed')
//console.log('completed')
this.store.tasks.finishProcessing('relays')
this.store.relays.updateNow()
this.store.relays.setAggregateCache('public', Object.keys(this.results).filter( result => this.results[result].aggregate === 'public' ))
this.store.relays.setAggregateCache('restricted', Object.keys(this.results).filter( result => this.results[result].aggregate === 'restricted' ))
this.store.relays.setAggregateCache('offline', Object.keys(this.results).filter( result => this.results[result].aggregate === 'offline' ))
console.log('all are complete?', !this.store.tasks.isProcessing)
//console.log('all are complete?', !this.store.tasks.isProcessing)
this.setAverageLatency()
},
check: async function(relay){
console.log('this.averageLatency', this.averageLatency)
//console.log('this.averageLatency', this.averageLatency)
await this.delay(this.averageLatency)
return new Promise( (resolve, reject) => {
@ -176,8 +196,8 @@ const localMethods = {
instance.result.log = instance.log
resolve(instance.result)
})
.on('close', (relay) => {
console.log(`${relay.url} has closed`)
.on('close', () => {
//console.log(`${relay.url} has closed`)
})
.on('error', () => {
reject()
@ -230,7 +250,7 @@ export default defineComponent({
// });
document.body.onfocus = () => {
// alert('tab focused')
console.log(`tab #${this.$tabId} is active`)
//console.log(`tab #${this.$tabId} is active`)
}
document.addEventListener('visibilitychange', this.handleVisibility, false)
@ -249,15 +269,16 @@ export default defineComponent({
this.relays = relays
this.lastUpdate = this.store.relays.lastUpdate
console.log('total relays', this.relays, this.relays.length)
//console.log('total relays', this.relays, this.relays.length)
for(let ri=0;ri-this.relays.length;ri++){
const relay = this.relays[ri],
cache = this.getCache(relay)
this.results[relay] = cache
// console.log('result', 'from result', this.results[relay], 'from cache', cache)
// //console.log('result', 'from result', this.results[relay], 'from cache', cache)
}
},
mounted(){
this.migrateLegacy()
if(this.store.tasks.isProcessing(`relays`))
this.invalidate(true)
else

18
src/components/user/AuthComponent.vue

@ -30,14 +30,14 @@ export default defineComponent({
}
},
mounted(){
console.log('store?', this.store.user)
//console.log('store?', this.store.user)
this.showAuth()
if(this.isLoggedIn())
this.getData()
// this.store.user.$subscribe( mutation => {
// if(mutation.key != 'pubKey')
// return
// console.log('there was amutation!!!!')
// //console.log('there was amutation!!!!')
// this.getData()
// })
},
@ -141,10 +141,10 @@ export default defineComponent({
// },
// console.log('pukey', this.user.pubkey)
// console.log('relays', await window.nostr.getRelays().catch(err => console.warn(err)))
// //console.log('pukey', this.user.pubkey)
// //console.log('relays', await window.nostr.getRelays().catch(err => console.warn(err)))
// console.log(window.nostr)
// //console.log(window.nostr)
// const event = {
// tags: [],
@ -156,19 +156,19 @@ export default defineComponent({
// event.id = getEventHash(event)
// console.log('unsigned event', event)
// //console.log('unsigned event', event)
// const signedEvent = await window.nostr.signEvent(event)
// .catch( function(error){
// console.log('there was an error', error)
// //console.log('there was an error', error)
// })
// console.log('signed event', signedEvent)
// //console.log('signed event', signedEvent)
// let ok = validateEvent(signedEvent)
// let veryOk = await verifySignature(signedEvent)
// console.log('valid event?', ok, veryOk)
// //console.log('valid event?', ok, veryOk)
</script>
<style>

4
src/shared/events.js

@ -11,11 +11,11 @@ events.discoverRelays = async function(){
const pool = RelayPool(['wss://nostr.sandwich.farm'])
pool
.on('open', relay => {
// console.log('open')
// //console.log('open')
relay.subscribe(subid, {limit: 1000, kinds:[3]})
})
.on('close', () => {
// console.log('close')
// //console.log('close')
})
.on('event', (relay, _subid, event) => {
if(subid == _subid) {

14
src/shared/hash-router.js

@ -14,28 +14,28 @@ const mountNav = function(navType, navItems){
this.navItems = navItems
this.store.layout.setNavItems(this.navSlug, this.navItems)
this.navActiveContent = this.store.layout.getActive(this.navSlug) || this.navItems[0].slug
console.log('route', 'setting active content', this.navType, this.navActiveContent)
//console.log('route', 'setting active content', this.navType, this.navActiveContent)
this.setActiveContent(this.navActiveContent)
this.loadNavContent()
console.log('route', 'mount', this.navType, this.navSlug, this.navActiveContent, this.navItems, this.navSlug)
//console.log('route', 'mount', this.navType, this.navSlug, this.navActiveContent, this.navItems, this.navSlug)
}
const setActiveContent = function(slug){
this.navActiveContent = slug
this.store.layout.setActive(this.navSlug, slug)
console.log('set active content', this.navActiveContent)
// console.log('route', 'setActiveContent', this.navType, this.navSlug, this.navActiveContent, this.navItems, this.navSlug)
//console.log('set active content', this.navActiveContent)
// //console.log('route', 'setActiveContent', this.navType, this.navSlug, this.navActiveContent, this.navItems, this.navSlug)
}
const loadNavContent = function(){
console.log('route', 'loadNavContent', this.navType, this.navSlug, this.navActiveContent, this.navItems, this.navSlug)
//console.log('route', 'loadNavContent', this.navType, this.navSlug, this.navActiveContent, this.navItems, this.navSlug)
const route = this.parseHash
if(!this.routeValid(route[this.navType]))
return
console.log(`route from ${this.navType} in ${this.navSlug}`, route[this.navType])
//console.log(`route from ${this.navType} in ${this.navSlug}`, route[this.navType])
if(route[this.navType])
this.setActiveContent(route[this.navType])
@ -46,7 +46,7 @@ const loadNavContent = function(){
//Computed
const routeValid = function(){
return (slug) => {
console.log('route', 'routeValid', this.navType, this.navSlug, this.navActiveContent, this.navItems)
//console.log('route', 'routeValid', this.navType, this.navSlug, this.navActiveContent, this.navItems)
if( !(this.navItems instanceof Array) )
return false

18
src/shared/history.js

@ -32,7 +32,7 @@ const History = async function(){
//set uniques
uniques = new Set(relays)
console.log(uniques, uniques.size)
//console.log(uniques, uniques.size)
const final = []
@ -43,11 +43,11 @@ const History = async function(){
final.push( [relay, relayTimeCodes[relay][0] ] )
})
console.log('before sort', final[0])
//console.log('before sort', final[0])
final.sort( (a, b) => a[1]-b[1] )
console.log('afdter sort', final[0])
//console.log('afdter sort', final[0])
return final
}
@ -65,19 +65,19 @@ const History = async function(){
const pool = RelayPool(this.store.relays.getAll.filter( (relay) => this.results?.[relay]?.aggregate == 'public').filter( relay => this.results?.[relay]?.info?.supported_nips.includes(15)))
pool
.on('open', relay => {
// console.log('open')
// //console.log('open')
relay.subscribe(subid, {since: 1609829, limit: 10000, kinds:[3]})
})
.on('eose', (relay) => {
console.log('closing', relay.url)
//console.log('closing', relay.url)
relay.close()
resolve(true)
})
.on('event', (relay, _subid, event) => {
if(subid == _subid) {
console.log(total++)
//console.log(total++)
try {
// console.log(event)
// //console.log(event)
const parsed = JSON.parse(event.content)
relaysRemote = Object.assign(relaysRemote, parsed)
Object.keys(parsed).forEach( key => {
@ -130,11 +130,11 @@ const History = async function(){
// const checkRemoteRelays = async function(){
// for(let i=0;i<relaysRemote.length;i++) {
// // console.log('check for connect', remoteMerged[i])
// // //console.log('check for connect', remoteMerged[i])
// await checkRelay(relaysRemote[i])
// .catch( () => {
// remove.push(relaysRemote[i])
// console.log('removals:', remove.length, relaysRemote[i])
// //console.log('removals:', remove.length, relaysRemote[i])
// })
// }
// }

2
src/shared/pool.js

@ -40,7 +40,7 @@ Pool.prototype.addHandler = function(which, key, fn){
this.handlers[which] = new Object()
if( typeof this.handlers[which][key] !== 'undefined') {
console.log(`${which}:${key} is already defined. Cannot set.`)
//console.log(`${which}:${key} is already defined. Cannot set.`)
return
}
this.handlers[which][key] = fn

2
src/shared/relays-lib.js

@ -65,7 +65,7 @@ export default {
aggregateTally += result?.check.read ? 1 : 0
aggregateTally += result?.check.write ? 1 : 0
// console.log(result.uri, result?.check.connect, result?.check.read, result?.check.write, aggregateTally)
// //console.log(result.uri, result?.check.connect, result?.check.read, result?.check.write, aggregateTally)
if (aggregateTally == 3) {
return 'public'

2
src/store/relays.js

@ -84,7 +84,7 @@ export const useRelaysStore = defineStore('relays', {
},
toggleFavorite(relayUrl){
//console.log('toggle favorite', relayUrl)
////console.log('toggle favorite', relayUrl)
if( this.isFavorite(relayUrl) )
this.unsetFavorite(relayUrl)
else

Loading…
Cancel
Save