Skip to content

Commit

Permalink
details
Browse files Browse the repository at this point in the history
  • Loading branch information
dskvr committed Apr 12, 2024
1 parent cd9f492 commit 7993f03
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
15 changes: 12 additions & 3 deletions src/lib/components/layout/Footer.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts">
import { onMount } from 'svelte';
import { browser } from '$app/environment';
onMount(async ()=>{
if(browser) {
Expand All @@ -11,12 +10,22 @@
})
</script>

<span class="block mt-5 mb-32 text-purple-950 dark:text-purple-50 font-bold text-sm ">
<span id="ohai" class="mt-5 mb-32 text-purple-950 dark:text-purple-50 font-bold text-sm transition-opacity duration-100">
powered by <a href="https://github.com/sandwichfarm/myrelay.page" target="_blank">myrelay.page</a>
<button
id="mrp-support"
data-npub="npub1uac67zc9er54ln0kl6e4qp2y6ta3enfcg7ywnayshvlw9r5w6ehsqq99rx"
class="px-1 rounded-xl">
⚡️
</button>
</span>
</span>

<style>
:global(body #ohai) {
opacity: 0;
}
:global(body.loaded #ohai) {
opacity: 1;
}
</style>
14 changes: 9 additions & 5 deletions src/lib/core/MRP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import type { DD } from './kinds/geocoded';
import { MRPFeed } from './MRPFeed';

import { EventEmitter } from 'tseep';
import { MRPStage, MRPStatus } from './MRPData';
import { MRPData, MRPStage, MRPStatus } from './MRPData';

export interface MRPState {
signal: EventEmitter<any>;
ndk?: NDK;
}

export class MyRelayPage {
export class MyRelayPage extends MRPData {
private readonly defaultRelays: Set<string> = new Set(['wss://purplepag.es', 'wss://user.kindpag.es', 'wss://history.nostr.watch'] as string[])
private _url: string;
private _nostr: MRPNostr;
Expand All @@ -28,12 +28,15 @@ export class MyRelayPage {
private _userFollowsOnRelay: NDKUser[] = []
private _promises: Promise<any>[] = []

public $: MRPState = { signal: new EventEmitter() }
public $: MRPState;

constructor(url?: string){
const signal = new EventEmitter()
super(signal, 'root')
this.begin()
this.$ = { signal }
this.url = url
if(!this.url) throw new Error(`No valid URL provided/detected: ${this.url}`)
this.$.signal.emit('sync:start', Date.now())
this._nostr = new MRPNostr(this.$.signal, this.defaultRelays, this.url)
this.$.ndk = this._nostr.ndk
this._editor = new MRPEditor()
Expand All @@ -46,7 +49,8 @@ export class MyRelayPage {
await this.config?.init()
await this.nostr?.init()
// await this.editor?.init()
this.$.signal.once('relay:completed', () => { this.$.signal.emit('sync:finish', Date.now()) })
this.$.signal.once('relay:completed', () => { this.complete() })

}

bindHandlers(){
Expand Down
10 changes: 8 additions & 2 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
mrp.set(_mrp);
});
_mrp.$.signal.on('sync:start', function(timestamp: number){
_mrp.$.signal.on('root:pending', function(timestamp: number){
document.body.classList.add('loading')
})
_mrp.$.signal.on('sync:finish', function(timestamp: number){
_mrp.$.signal.on('root:completed', function(timestamp: number){
document.body.classList.remove('loading')
document.body.classList.add('loaded')
console.log(`loaded in ${Date.now()-$start}ms`)
Expand All @@ -77,7 +77,13 @@
<div class="flex flex-col items-center justify-center">
<div id="mrp-wrapper" class="mrp-wrapper-bg mrp-wrapper-content transition-colors duration-200 ease-in-out">
<Header></Header>

<slot></slot>
{#if !$mrp?.nostr?.relay?.config?.isComplete}
<span class="mt-5 text-center block text-black/20 dark:text-white/20 italic text-lg">
loading operator config...
</span>
{/if}
</div>
<Footer></Footer>
</div>
Expand Down

0 comments on commit 7993f03

Please sign in to comment.