diff --git a/spec/more_speech/migrator_spec.clj b/spec/more_speech/migrator_spec.clj index 09ae4bd..6879b31 100644 --- a/spec/more_speech/migrator_spec.clj +++ b/spec/more_speech/migrator_spec.clj @@ -16,6 +16,7 @@ (reset! config/tabs-list-filename "tmp/tabs-list") (reset! config/messages-directory "tmp/messages") (reset! config/messages-filename "tmp/messages/message-file") + (reset! config/user-configuration-filename "tmp/user-configuration") (.mkdir (io/file "tmp")) (prn 'changed-to-tmp) ) @@ -45,7 +46,9 @@ (reset! config/tabs-filename "private/tabs") (reset! config/tabs-list-filename "private/tabs-list") (reset! config/messages-directory "private/messages") - (reset! config/messages-filename "private/messages/message-file")) + (reset! config/messages-filename "private/messages/message-file") + (reset! config/user-configuration-filename "private/user-configuration") + ) (describe "The Migrator" (with-stubs) @@ -205,4 +208,11 @@ (should= [{:id 1 :created-at 0}] (read-string (slurp (str @config/messages-directory "/0-01Jan70")))) (should= [{:id 2 :created-at 86400}] (read-string (slurp (str @config/messages-directory "/1-02Jan70")))) (should-not (file-exists? @config/messages-filename)))) + + (context "migration 8 user configuration" + (it "creates an empty user-configuration file" + (migration-8-user-configuration) + (should (file-exists? @config/user-configuration-filename)) + (should= {} (read-string (slurp @config/user-configuration-filename)))) + ) ) diff --git a/src/more_speech/config.clj b/src/more_speech/config.clj index 92e7fb9..e135be5 100644 --- a/src/more_speech/config.clj +++ b/src/more_speech/config.clj @@ -8,7 +8,7 @@ (def days-to-read 10) ;how many daily message files to read in. -(def migration-level 7) +(def migration-level 8) (def version "202207291135") (def test-run? false) @@ -24,6 +24,7 @@ (def tabs-list-filename (atom "private/tabs-list")) (def messages-directory (atom "private/messages")) (def messages-filename (atom "private/messages/message-file")) +(def user-configuration-filename (atom "private/user-configuration")) (def user-name-pattern #"\@[\w\-]+") (def user-name-chars #"[\w\-]+") diff --git a/src/more_speech/data_storage.clj b/src/more_speech/data_storage.clj index a792d88..f4b6727 100644 --- a/src/more_speech/data_storage.clj +++ b/src/more_speech/data_storage.clj @@ -4,6 +4,7 @@ [more-speech.nostr.events :as events] [more-speech.nostr.relays :as relays] [more-speech.ui.swing.tabs :as tabs] + [more-speech.user-configuration :as user-configuration] [clojure.string :as string]) (:import (java.util Date TimeZone) (java.text SimpleDateFormat))) @@ -23,7 +24,9 @@ (spit @config/tabs-list-filename (with-out-str (clojure.pprint/pprint (:tabs-list @event-context)))) - + (spit @config/user-configuration-filename + (with-out-str + (clojure.pprint/pprint (:user-configuration @event-context)))) )) (defn write-messages [] @@ -38,10 +41,14 @@ profiles (read-string (slurp @config/profiles-filename)) tabs-list (tabs/ensure-tab-list-has-all (read-string (slurp @config/tabs-list-filename))) + user-configuration (user-configuration/validate + (read-string (slurp @config/user-configuration-filename))) + event-context (events/make-event-context {:keys keys :profiles profiles :read-event-ids read-event-ids :tabs-list tabs-list + :user-configuration user-configuration })] (swap! ui-context assoc :event-context event-context) (relays/load-relays-from-file @config/relays-filename))) diff --git a/src/more_speech/migrator.clj b/src/more_speech/migrator.clj index 8d90cbe..7165f13 100644 --- a/src/more_speech/migrator.clj +++ b/src/more_speech/migrator.clj @@ -109,6 +109,12 @@ ) ) +;--- Migration 8 user-configuration file --- + +(defn migration-8-user-configuration [] + (spit @config/user-configuration-filename {}) + ) + ;---------- The Migrations List ------- (def migrations (atom {1 initial-migration @@ -118,6 +124,7 @@ 5 migration-5-remove-nicknames 6 migration-6-reformat-tabs 7 migration-7-break-messages-into-daily-files + 8 migration-8-user-configuration })) ;-------------------------------------- diff --git a/src/more_speech/user_configuration.clj b/src/more_speech/user_configuration.clj new file mode 100644 index 0000000..9c0719c --- /dev/null +++ b/src/more_speech/user_configuration.clj @@ -0,0 +1,4 @@ +(ns more-speech.user-configuration) + +(defn validate [user-configuration] + user-configuration)