Skip to content

Commit

Permalink
save point
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Keating committed Jul 18, 2023
1 parent 7b2622e commit ac90d1a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
23 changes: 11 additions & 12 deletions src/lib/NoteDetail.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { onMount } from 'svelte';
import { RxDBUpdatePlugin } from 'rxdb/plugins/update';
import { db, selectedNote } from './store';
import { selectedNote, bodyText } from './store';
import { debounce } from '../utils/debounce';
import { isEmptyObject } from '../utils/isEmptyObject';
Expand All @@ -12,14 +12,17 @@
let innerHeight;
onMount(() => addRxPlugin(RxDBUpdatePlugin));
onMount(() => {
addRxPlugin(RxDBUpdatePlugin);
if ($selectedNote.body) $bodyText = $selectedNote.body;
});
const handleDebounceSave = debounce(() => !isEmptyObject($selectedNote) && updateNote(), 230);
const handleDebounceSave = debounce(() => !isEmptyObject($selectedNote) && updateNote(), 500);
const updateNote = async () => {
await $selectedNote.update({
$set: {
body: $selectedNote.body,
body: $bodyText,
updatedAt: new Date().getTime(),
},
});
Expand All @@ -31,31 +34,27 @@
<div class="relative overflow-hidden h-full">
{#if isEmptyObject($selectedNote)}
<div class="relative w-full h-full flex items-center justify-center">
<h2>No Note Selected</h2>
<h2 style="font-size: 18px; color: #525962">No Note Selected</h2>
</div>
{:else if $selectedNote.guid === '00000000-0000-0000-0000-000000000000'}
<Settings />
{:else}
<textarea
id="body-editor"
class="block w-full h-full relative no-resize border-0 outline-none border-box"
bind:value={$selectedNote.body}
bind:value={$bodyText}
on:keydown={handleDebounceSave}
/>
{/if}
</div>

<style>
h2 {
font-size: 18px;
color: #808080;
}
textarea {
padding: 0 1rem;
padding: 4px 15px;
background: #131313;
color: rgba(255, 255, 255, 0.831);
font-size: 14px;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif;
font-family: Arial, Helvetica, sans-serif;
line-height: 1.3;
border-radius: none;
height: 100%;
Expand Down
2 changes: 2 additions & 0 deletions src/lib/NoteList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@
overflow-y: auto;
overflow-x: hidden;
background-color: #1c1f21;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
}
li {
display: flex;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/OmniBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
<svelte:window on:keydown={clearSelection} />

<div
class="omnibar flex items-center border-box border-b"
style="border-color: #2e3338; background-color: #181a1c; height: 42px; padding-left: 10px;"
class="omnibar flex items-center border-box"
style="background-color: #181a1c; height: 42px; padding-left: 10px;"
>
<div class="input-wrapper flex-grow flex items-center">
<input
Expand Down
3 changes: 2 additions & 1 deletion src/lib/Settings.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
};
</script>

<div class="px-2 text-white">
<div class="text-white" style="padding: 0 15px;">
<h2 style="font-size: 20px; line-height: 0;">nvAux Settings</h2>
<div class="relative">
{#await db().notes.find().exec()}
Expand All @@ -30,4 +30,5 @@
style="background: #b41111;">Reset Database</button
>
</div>
<p>Hack on <a href="https://github.com/matterofabstract/nvaux" target="_blank" style="color: #ed0078; text-decoration: underline;">nvAux @ GitHub</a></p>
</div>
5 changes: 2 additions & 3 deletions src/lib/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ const _create = async () => {
const notes = await db.notes.find().exec();

if (notes.length === 0) {
const date = new Date().getTime();
await db.notes.insert({
guid: '00000000-0000-0000-0000-000000000000',
name: '⚙️ nvAux Settings...',
createdAt: date,
updatedAt: date
createdAt: new Date().getTime(),
updatedAt: new Date().getTime()
});

setTimeout (() => {
Expand Down

0 comments on commit ac90d1a

Please sign in to comment.