diff --git a/src/status_im/utils/handlers.clj b/src/status_im/utils/handlers.clj index 04a52f3c9d..de6515fd6f 100644 --- a/src/status_im/utils/handlers.clj +++ b/src/status_im/utils/handlers.clj @@ -5,8 +5,14 @@ All functions are expected to accept [db event] as parameters. If one handler returns a modified db it will be used as parameters for subsequent handlers." [& forms] - (let [db (gensym "db") - event (gensym "event")] + (let [db (gensym "db") + event (gensym "event") + new-db (gensym "new-db")] `(fn [~db ~event] - (let [~@(interleave (repeat db) (map #(list 'or (list % db event) db) forms))] - ~db)))) \ No newline at end of file + (let [~@(interleave (repeat db) + (map (fn [form] + `(let [~new-db (~form ~db ~event)] + (if (map? ~new-db) + ~new-db + ~db))) forms))] + ~db))))