forked from coracle/flotilla
UI tweaks, fix some calendar stuff
This commit is contained in:
@@ -5,11 +5,16 @@
|
||||
import {pubkey, subscribe} from "@welshman/app"
|
||||
import {fly} from "@lib/transition"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import ChatItem from "@app/components/ChatItem.svelte"
|
||||
import ChatStart from "@app/components/ChatStart.svelte"
|
||||
import {chatSearch, pullConservatively} from "@app/state"
|
||||
import {pushModal} from "@app/modal"
|
||||
|
||||
let term = ""
|
||||
|
||||
const startChat = () => pushModal(ChatStart)
|
||||
|
||||
$: chats = $chatSearch.searchOptions(term).filter(c => c.pubkeys.length > 1)
|
||||
|
||||
onMount(() => {
|
||||
@@ -26,13 +31,26 @@
|
||||
</script>
|
||||
|
||||
<div class="content column gap-2">
|
||||
<label class="input input-bordered mb-2 flex items-center gap-2" in:fly={{delay: 250}}>
|
||||
<Icon icon="magnifer" />
|
||||
<input bind:value={term} class="grow" type="text" placeholder="Search for conversations..." />
|
||||
</label>
|
||||
<div class="row-2 min-w-0 items-center">
|
||||
<label class="input input-bordered flex flex-grow items-center gap-2" in:fly={{delay: 250}}>
|
||||
<Icon icon="magnifer" />
|
||||
<input bind:value={term} class="grow" type="text" placeholder="Search for conversations..." />
|
||||
</label>
|
||||
<Button class="btn btn-primary" on:click={startChat}>
|
||||
<Icon icon="add-circle" />
|
||||
</Button>
|
||||
</div>
|
||||
<div class="column gap-2 overflow-auto">
|
||||
{#each chats as { id, pubkeys, messages } (id)}
|
||||
<ChatItem {id} {pubkeys} {messages} />
|
||||
{:else}
|
||||
<div class="py-20 max-w-sm col-4 items-center m-auto text-center">
|
||||
<p>No chats found! Try starting one up.</p>
|
||||
<Button class="btn btn-primary" on:click={startChat}>
|
||||
<Icon icon="add-circle" />
|
||||
Start a Chat
|
||||
</Button>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import {page} from "$app/stores"
|
||||
import {sortBy, last, ago} from "@welshman/lib"
|
||||
import {sortBy, tryCatch, last, ago} from "@welshman/lib"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {EVENT_DATE, EVENT_TIME} from "@welshman/util"
|
||||
import {subscribe, formatTimestampAsDate} from "@welshman/app"
|
||||
@@ -21,9 +21,13 @@
|
||||
|
||||
const createEvent = () => pushModal(EventCreate, {url})
|
||||
|
||||
const getStart = (event: TrustedEvent) =>
|
||||
parseInt(event.tags.find(t => t[0] === "start")?.[1] || "0")
|
||||
const getEnd = (event: TrustedEvent) =>
|
||||
parseInt(event.tags.find(t => t[0] === "end")?.[1] || "")
|
||||
|
||||
const getStart = (event: TrustedEvent) =>
|
||||
parseInt(event.tags.find(t => t[0] === "start")?.[1] || "")
|
||||
|
||||
let limit = 5
|
||||
let loading = true
|
||||
|
||||
type Item = {
|
||||
@@ -31,14 +35,19 @@
|
||||
dateDisplay?: string
|
||||
}
|
||||
|
||||
$: items = sortBy(getStart, $events).reduce<Item[]>((r, event) => {
|
||||
$: items = sortBy(e => -getStart(e), $events).reduce<Item[]>((r, event) => {
|
||||
const end = getEnd(event)
|
||||
const start = getStart(event)
|
||||
|
||||
if (isNaN(start) || isNaN(end)) return r
|
||||
|
||||
const prevDateDisplay =
|
||||
r.length > 0 ? formatTimestampAsDate(getStart(last(r).event)) : undefined
|
||||
const newDateDisplay = formatTimestampAsDate(getStart(event))
|
||||
const newDateDisplay = formatTimestampAsDate(start)
|
||||
const dateDisplay = prevDateDisplay === newDateDisplay ? undefined : newDateDisplay
|
||||
|
||||
return [...r, {event, dateDisplay}]
|
||||
}, [])
|
||||
}, []).slice(0, limit)
|
||||
|
||||
onMount(() => {
|
||||
const sub = subscribe({filters: [{kinds, since: ago(30)}]})
|
||||
@@ -78,7 +87,7 @@
|
||||
</p>
|
||||
</div>
|
||||
<Button
|
||||
class="tooltip tooltip-left fixed bottom-16 right-2 z-feature p-1 sm:bottom-4 sm:right-4"
|
||||
class="tooltip tooltip-left fixed bottom-16 right-2 z-feature p-1 md:bottom-4 md:right-4"
|
||||
data-tip="Create an Event"
|
||||
on:click={createEvent}>
|
||||
<div class="btn btn-circle btn-primary flex h-12 w-12 items-center justify-center">
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
</p>
|
||||
</div>
|
||||
<Button
|
||||
class="tooltip tooltip-left fixed bottom-16 right-2 z-feature p-1 sm:bottom-4 sm:right-4"
|
||||
class="tooltip tooltip-left fixed bottom-16 right-2 z-feature p-1 md:bottom-4 md:right-4"
|
||||
data-tip="Create an Event"
|
||||
on:click={createThread}>
|
||||
<div class="btn btn-circle btn-primary flex h-12 w-12 items-center justify-center">
|
||||
|
||||
Reference in New Issue
Block a user