diff --git a/assets/js/app.js b/assets/js/app.js
index fd3b1cb..e245ae5 100644
--- a/assets/js/app.js
+++ b/assets/js/app.js
@@ -23,7 +23,7 @@ import { LiveSocket } from "phoenix_live_view"
import topbar from "../vendor/topbar"
import lolight from "../vendor/lolight"
import React from "react"
-import { createRoot } from 'react-dom'
+import { createRoot } from 'react-dom/client'
import KBar from "./kbar"
lolight("pre code")
diff --git a/assets/js/kbar.js b/assets/js/kbar.js
index 98c9844..d3e265c 100644
--- a/assets/js/kbar.js
+++ b/assets/js/kbar.js
@@ -44,7 +44,7 @@ function RenderResults() {
items={results}
onRender={({ item, active }) =>
typeof item === "string" ? (
-
{item}
+ {item}
) : (
=12"
},
"optionalDependencies": {
- "@esbuild/android-arm": "0.18.0",
- "@esbuild/android-arm64": "0.18.0",
- "@esbuild/android-x64": "0.18.0",
- "@esbuild/darwin-arm64": "0.18.0",
- "@esbuild/darwin-x64": "0.18.0",
- "@esbuild/freebsd-arm64": "0.18.0",
- "@esbuild/freebsd-x64": "0.18.0",
- "@esbuild/linux-arm": "0.18.0",
- "@esbuild/linux-arm64": "0.18.0",
- "@esbuild/linux-ia32": "0.18.0",
- "@esbuild/linux-loong64": "0.18.0",
- "@esbuild/linux-mips64el": "0.18.0",
- "@esbuild/linux-ppc64": "0.18.0",
- "@esbuild/linux-riscv64": "0.18.0",
- "@esbuild/linux-s390x": "0.18.0",
- "@esbuild/linux-x64": "0.18.0",
- "@esbuild/netbsd-x64": "0.18.0",
- "@esbuild/openbsd-x64": "0.18.0",
- "@esbuild/sunos-x64": "0.18.0",
- "@esbuild/win32-arm64": "0.18.0",
- "@esbuild/win32-ia32": "0.18.0",
- "@esbuild/win32-x64": "0.18.0"
+ "@esbuild/android-arm": "0.18.11",
+ "@esbuild/android-arm64": "0.18.11",
+ "@esbuild/android-x64": "0.18.11",
+ "@esbuild/darwin-arm64": "0.18.11",
+ "@esbuild/darwin-x64": "0.18.11",
+ "@esbuild/freebsd-arm64": "0.18.11",
+ "@esbuild/freebsd-x64": "0.18.11",
+ "@esbuild/linux-arm": "0.18.11",
+ "@esbuild/linux-arm64": "0.18.11",
+ "@esbuild/linux-ia32": "0.18.11",
+ "@esbuild/linux-loong64": "0.18.11",
+ "@esbuild/linux-mips64el": "0.18.11",
+ "@esbuild/linux-ppc64": "0.18.11",
+ "@esbuild/linux-riscv64": "0.18.11",
+ "@esbuild/linux-s390x": "0.18.11",
+ "@esbuild/linux-x64": "0.18.11",
+ "@esbuild/netbsd-x64": "0.18.11",
+ "@esbuild/openbsd-x64": "0.18.11",
+ "@esbuild/sunos-x64": "0.18.11",
+ "@esbuild/win32-arm64": "0.18.11",
+ "@esbuild/win32-ia32": "0.18.11",
+ "@esbuild/win32-x64": "0.18.11"
}
},
"node_modules/fast-equals": {
diff --git a/assets/package.json b/assets/package.json
index 05929c6..6d04eb6 100644
--- a/assets/package.json
+++ b/assets/package.json
@@ -11,7 +11,7 @@
"phoenix_live_view": "file:../deps/phoenix_live_view"
},
"peerDependencies": {
- "react": "^17.0.0",
- "react-dom": "^17.0.0"
+ "react": "^18.0",
+ "react-dom": "^18.0"
}
}
diff --git a/lib/chiya/tags/tag_updater.ex b/lib/chiya/tags/tag_updater.ex
index 60b8a99..89b6b06 100644
--- a/lib/chiya/tags/tag_updater.ex
+++ b/lib/chiya/tags/tag_updater.ex
@@ -43,7 +43,12 @@ defmodule Chiya.Tags.TagUpdater do
end
def update_tags(%{tags: tags} = schema, new_tags) when is_list(new_tags) do
- old_tags = Enum.map(tags, fn tag -> tag.name end)
+ old_tags = Enum.map(tags, fn tag -> String.downcase(tag.slug) end)
+ new_tags = Enum.map(new_tags, fn tag ->
+ tag
+ |> String.downcase()
+ |> Slugger.slugify()
+ end)
Logger.info("Adding tags #{inspect(new_tags -- old_tags)}")
Logger.info("Removing tags #{inspect(old_tags -- new_tags)}")
diff --git a/test/chiya/tag_updater_test.exs b/test/chiya/tag_updater_test.exs
new file mode 100644
index 0000000..5d995ec
--- /dev/null
+++ b/test/chiya/tag_updater_test.exs
@@ -0,0 +1,57 @@
+defmodule Chiya.TagUpdaterTest do
+ use Chiya.DataCase
+
+ import Chiya.NotesFixtures
+ alias Chiya.Tags.TagUpdater
+
+ describe "update_tags/2" do
+ test "with a single tag updates a note with the given tag" do
+ note = note_fixture()
+
+ assert note.tags == []
+ TagUpdater.update_tags(note, "foo")
+ note = Chiya.Notes.get_note_preloaded!(note.id)
+ assert Enum.count(note.tags) == 1
+ end
+
+ test "with a list of new tags replaces exisiting tags"do
+ note = note_fixture()
+
+ assert note.tags == []
+
+ TagUpdater.update_tags(note, "foo")
+ note = Chiya.Notes.get_note_preloaded!(note.id)
+ assert Enum.count(note.tags) == 1
+
+ TagUpdater.update_tags(note, ["bar", "baz"])
+ note = Chiya.Notes.get_note_preloaded!(note.id)
+ assert Enum.count(note.tags) == 2
+ end
+
+ test "with a map representing the attributes replaces existing tags" do
+ note = note_fixture()
+
+ assert note.tags == []
+
+ TagUpdater.update_tags(note, %{tags_string: "foo,bar,baz"})
+ note = Chiya.Notes.get_note_preloaded!(note.id)
+ assert Enum.count(note.tags) == 3
+ end
+
+ test "with the same tags in different capitalization replaces exisiting tags" do
+ note = note_fixture()
+ assert note.tags == []
+
+ TagUpdater.update_tags(note, "foo")
+ note = Chiya.Notes.get_note_preloaded!(note.id)
+ assert Enum.count(note.tags) == 1
+
+ TagUpdater.update_tags(note, ["Foo"])
+ note = Chiya.Notes.get_note_preloaded!(note.id)
+ assert Enum.count(note.tags) == 1
+
+ tag = List.first(note.tags)
+ assert tag.name == "Foo"
+ end
+ end
+end