Skip to content

Commit

Permalink
Merge pull request #11 from sandwichfarm/feature/editor-flow
Browse files Browse the repository at this point in the history
editor flow
  • Loading branch information
dskvr authored Apr 14, 2024
2 parents 35c1a26 + 9a6b6f6 commit cfd5935
Show file tree
Hide file tree
Showing 12 changed files with 180 additions and 69 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"lucide-svelte": "0.363.0",
"mode-watcher": "0.3.0",
"nostr-zap": "0.22.0",
"object-hash": "3.0.0",
"paneforge": "0.0.2",
"promise-deferred": "2.0.4",
"svelte": "4.2.12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import SkeletonTheme from '$lib/components/ui/skeleton2/SkeletonTheme.svelte';
import Block from '$lib/components/wrappers/block.svelte';
export let key: string;
</script>
<Block headingClass="col-span-5">
<Block headingClass="col-span-5" {key}>
<svelte:fragment slot="title">
relay operator
</svelte:fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@
</script>
{#if browser}

{#if profile}
<Block headingClass="col-span-5" {key}>

<svelte:fragment slot="title">
relay operator
</svelte:fragment>
Expand Down Expand Up @@ -133,7 +135,7 @@
{/each}
</div>
{:else}
{#if owner?.feed?.isComplete }
{#if owner?.isComplete }
<div class="note min-h-max bg-white/90 dark:bg-black/90 px-5 py-3 pb-10 rounded-lg shadow transition-opacity duration-200 relative max-h-72 overflow-hidden text-3xl h-full mt-9 text-gray-300 italic flex items-center space-x-4 text-center">
seems the operator is quiet, no notes
</div>
Expand All @@ -146,7 +148,7 @@
</svelte:fragment>
</Block>
{:else}
<ProfileSkeleton />
<ProfileSkeleton {key} />
{/if} <!-- /!profile -->
{/if} <!-- /browser -->

Expand Down
17 changes: 13 additions & 4 deletions src/lib/components/partials/edit-button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,30 @@
const toggleEdit = async () => {
if(!mrp?.editor) return
mrp?.editor?.toggle()
if($MRP?.loader?.config?.event?.changed) $MRP.loader.config.event.discardChanges()
MRP.set(mrp)
}
const publish = async () => {
mrp?.editor?.toggle()
await mrp?.loader?.config?.publish()
}
$: text = $MRP?.editor?.enabled ? 'finish' : 'editor'
$: text = $MRP?.editor?.enabled
? $MRP?.loader?.config?.event?.changed
? 'discard edits'
: 'leave editor'
: 'edit'
</script>
{#if browser }
<!-- {#if $MRP?.loader?.config?.hasChanged() } -->
{#if $MRP?.loader?.config?.event.changed }
<Button variant="outline" on:click={publish}>
Publish Changes
publish edits
</Button>
<!-- {/if} -->
{/if}
<Button variant="outline" on:click={toggleEdit}>
{text}
</Button>
Expand Down
5 changes: 2 additions & 3 deletions src/lib/components/partials/editor.reorder.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
const up = () => {
$MRP.loader.config.event.shiftBlockUp(key)
console.log('block order after', $MRP?.loader?.sortedKeys)
MRP.set($MRP)
}
const down = () => {
Expand All @@ -20,14 +19,14 @@
</script>

{#if !$MRP?.loader?.config?.event?.blockIsFirst(key)}
<a href="#" on:click={up}>
<a href="{'#'}" on:click={up}>
</a>
{/if}


{#if !$MRP?.loader?.config?.event?.blockIsLast(key)}
<a href="#" on:click={down}>
<a href="{'#'}" on:click={down}>
</a>
{/if}
Expand Down
6 changes: 4 additions & 2 deletions src/lib/components/partials/login.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
let userIsOperator: boolean = false
const _isOperator = () => {
return $MRP?.nostr?.relay?.owner && $MRP?.nostr?.authed
? $MRP?.nostr?.relay?.owner?.pubkey === $MRP?.nostr?.user?.pubkey
const operator = $MRP?.nostr?.relay?.info?.pubkey || $MRP?.nostr?.relay?.owner?.pubkey
const currentUser = $MRP?.nostr?.user?.pubkey
return operator && $MRP?.nostr?.authed
? operator === currentUser
: false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/core/MRP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class MyRelayPage extends MRPData {
await this.nostr.user?.getFollows();
if (!this.nostr.user?.follows) return;

console.log(`you follow ${this.nostr.user?.follows} nostriches`)
console.log(`you follow ${this.nostr.user?.follows?.size} nostriches`)

const relay = new NDKRelaySet(new Set([new NDKRelay(this.url as string)]), new NDK({explicitRelayUrls:[this.url as string]}));

Expand Down Expand Up @@ -99,7 +99,7 @@ export class MyRelayPage extends MRPData {

pubkeyResults = Array.from(new Set(pubkeyResults))

console.log(`${this.nostr.user?.follows} of them are lurking on ${this.url}`)
console.log(`${pubkeyResults?.length} of them are lurking on ${this.url}`)

for (const follow of this.nostr.user.follows) {
if (!pubkeyResults.includes(follow.pubkey)) continue;
Expand Down
9 changes: 3 additions & 6 deletions src/lib/core/MRPConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { EventEmitter } from 'tseep';
import type { MRPState } from "./MRP";
import { MRPData } from "./MRPData";
import { MRPUser } from "./MRPUser";
import { TheaterIcon } from "lucide-svelte";
import { GalleryThumbnailsIcon, TheaterIcon } from "lucide-svelte";

export class MRPConfig extends MRPData {

Expand All @@ -16,6 +16,7 @@ export class MRPConfig extends MRPData {
private pubkey: string | undefined;
private relay: string | undefined
private _changed: boolean = false;
private _configHash: string | undefined;

public event: AppConfig;

Expand Down Expand Up @@ -59,10 +60,6 @@ export class MRPConfig extends MRPData {
return this.event
}

hasChanged(): boolean {
return this.event.changed
}

configKey(): string {
return `myrelay.page/${this?.relay}operator@${this.pubkey}`
}
Expand All @@ -76,7 +73,7 @@ export class MRPConfig extends MRPData {
await this.event?.publish(NDKRelaySet.fromRelayUrls(['wss://appdata.kindpag.es'], this.$.ndk as NDK)).catch((err) => { throw new Error(err) })
if(!error){
this.$.signal.emit(`config:published`, this.type, this.event)
this.event.changed = false
this.event.commitChanges()
}
return !error
}
Expand Down
Loading

0 comments on commit cfd5935

Please sign in to comment.