onDoubleClick doesn't work in muon so I need to fix that somehow - maybe implement my own

master
Adam Veldhousen 2020-01-14 21:13:38 -06:00
parent cd7ce3b685
commit 5f41c5c5f4
Signed by: adam
GPG Key ID: 6DB29003C6DD1E4B
6 changed files with 78 additions and 42 deletions

Binary file not shown.

View File

@ -9,7 +9,7 @@ import { createNote, getNotes } from "./state";
import "./App.css"; import "./App.css";
class App extends PureComponent { class App extends PureComponent {
state = { notes: getNotes(), selectedNote: null }; state = { ...getNotes(), selectedNote: null };
handleSearch = text => { handleSearch = text => {
const { notes } = this.state; const { notes } = this.state;

View File

@ -19,7 +19,11 @@ export default function EditableNoteArea({ content = null, onSave = noop }) {
setNewContent(target.value || newContent); setNewContent(target.value || newContent);
return ( return (
<section className="EditableNoteArea" onDoubleClick={toggleEditMode}> <section
className="EditableNoteArea"
onClick={toggleEditMode}
// onDoubleClick={toggleEditMode}
>
{editMode ? ( {editMode ? (
<textarea <textarea
defaultValue={content} defaultValue={content}

View File

@ -1,5 +1,6 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { noop } from "../state.js"; import { noop } from "../state.js";
import "./Omnibar.css"; import "./Omnibar.css";
export default function Omnibar({ onSearch = noop, onEnter = noop }) { export default function Omnibar({ onSearch = noop, onEnter = noop }) {

View File

@ -16,7 +16,12 @@ export const createNote = ({ title = null, content = "", tags = [] }) => {
}; };
}; };
export const getNotes = () => [ export const getNotes = window.LoadNotes || (() => defaultNotes);
export const upsertNote = () => {};
const defaultNotes = {
error: null,
notes: [
createNote({ createNote({
title: "ass 1", title: "ass 1",
content: "this is an ass note", content: "this is an ass note",
@ -50,6 +55,5 @@ export const getNotes = () => [
content: "this is an ass note", content: "this is an ass note",
tags: ["not ass"] tags: ["not ass"]
}) })
]; ]
};
export const upsertNote = () => {};

35
main.go
View File

@ -2,6 +2,10 @@
package main package main
import ( import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time" "time"
"github.com/ImVexed/muon" "github.com/ImVexed/muon"
@ -26,7 +30,7 @@ func main() {
as := &AppState{ as := &AppState{
Settings: Settings{ Settings: Settings{
Directory: ".", Directory: "K:/private/aveldhousen/notes/posts",
Orientation: "vertical", Orientation: "vertical",
}, },
Notes: []Note{}, Notes: []Note{},
@ -62,13 +66,36 @@ type Settings struct {
} }
type LoadNoteResult struct { type LoadNoteResult struct {
Error error Error error `json:"error,omitempty"`
Notes []Note Notes []Note `json:"notes"`
} }
func (as *AppState) LoadNotes() LoadNoteResult { func (as *AppState) LoadNotes() LoadNoteResult {
notes := []Note{}
if err := filepath.Walk(as.Settings.Directory, func(path string, info os.FileInfo, err error) error {
fileExt := filepath.Ext(info.Name())
if fileExt == "md" || fileExt == "txt" || fileExt == "utf" || fileExt == "todo" {
content, err := ioutil.ReadFile(path)
if err != nil {
return nil
}
notes = append(notes, Note{
Title: info.Name(),
LastModified: info.ModTime(),
Created: info.ModTime(),
Content: string(content),
})
}
return nil
}); err != nil {
return LoadNoteResult{Error: fmt.Errorf("could not enumerate notes: %w", err)}
}
return LoadNoteResult{ return LoadNoteResult{
Notes: as.Notes, Notes: notes,
Error: nil, Error: nil,
} }
} }