Skip to content

Commit

Permalink
always return promise
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushgaud committed Nov 14, 2023
1 parent 6e1078b commit 4d410fe
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/wrike_ist/wrike.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,25 @@

(defn check-valid-task
[{:keys [permalink target-branch folder-names]}]
(.info js/console "check-valid-task: Start of the function")
(when (and target-branch (str/starts-with? target-branch "main"))
(let [folder-ids (get-folder-id folder-names)]
(if (seq folder-ids)
(do
(log-folder-ids folder-names folder-ids)
(if (is-wrike-task-in-folder? permalink (first folder-ids))
(do
(.info js/console "check-valid-task: Task is in the folder or an inherited folder: true")
(js/Promise.resolve permalink))
(do
(.error js/console "check-valid-task: Task not found")
(js/Promise.reject (js/Error. "Task not found")))))
(do
(.error js/console "check-valid-task: No matching folder found")
(js/Promise.reject (js/Error. "No matching folder found")))))))
(js/Promise.
(fn [resolve reject]
(.info js/console "check-valid-task: Start of the function")
(when (and target-branch (str/starts-with? target-branch "main"))
(let [folder-ids (get-folder-id folder-names)]
(if (seq folder-ids)
(do
(log-folder-ids folder-names folder-ids)
(if (is-wrike-task-in-folder? permalink (first folder-ids))
(do
(.info js/console "check-valid-task: Task is in the folder or an inherited folder: true")
(resolve permalink))
(do
(.error js/console "check-valid-task: Task not found")
(reject (js/Error. "Task not found")))))
(do
(.error js/console "check-valid-task: No matching folder found")
(reject (js/Error. "No matching folder found")))))))))




Expand Down

0 comments on commit 4d410fe

Please sign in to comment.