From 8de3be1f6f00cd5e2fbba652c7a274d377debfe1 Mon Sep 17 00:00:00 2001 From: Roman Volosovskyi Date: Fri, 13 May 2016 19:03:14 +0300 Subject: [PATCH] replace to-datasource2 Former-commit-id: 85e05a451dcd87db0df35b25db6e3a23bbe7fcbe --- src/syng_im/chat/screen.cljs | 4 ++-- src/syng_im/chat/views/suggestions.cljs | 4 +--- src/syng_im/chats_list/screen.cljs | 4 ++-- src/syng_im/contacts/screen.cljs | 2 +- src/syng_im/discovery/tag.cljs | 4 ++-- src/syng_im/discovery/views/popular_list.cljs | 4 ++-- src/syng_im/discovery/views/recent.cljs | 4 ++-- src/syng_im/new_group/screen.cljs | 4 ++-- src/syng_im/participants/views/create.cljs | 4 ++-- src/syng_im/participants/views/remove.cljs | 4 ++-- src/syng_im/utils/listview.cljs | 11 ++++------- 11 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/syng_im/chat/screen.cljs b/src/syng_im/chat/screen.cljs index 8b40ce8cfc..3c7785ab78 100644 --- a/src/syng_im/chat/screen.cljs +++ b/src/syng_im/chat/screen.cljs @@ -10,7 +10,7 @@ list-item]] [syng-im.chat.styles.chat :as st] [syng-im.resources :as res] - [syng-im.utils.listview :refer [to-datasource2]] + [syng-im.utils.listview :refer [to-datasource]] [syng-im.components.invertible-scroll-view :refer [invertible-scroll-view]] [syng-im.chat.views.message :refer [chat-message]] [syng-im.chat.views.new-message :refer [chat-message-new]])) @@ -169,7 +169,7 @@ :renderScrollComponent #(invertible-scroll-view (js->clj %)) :onEndReached #(dispatch [:load-more-messages]) :enableEmptySections true - :dataSource (to-datasource2 @messages)}])))) + :dataSource (to-datasource @messages)}])))) (defn chat [] (let [is-active (subscribe [:chat :is-active]) diff --git a/src/syng_im/chat/views/suggestions.cljs b/src/syng_im/chat/views/suggestions.cljs index 97461c2741..64bc62b278 100644 --- a/src/syng_im/chat/views/suggestions.cljs +++ b/src/syng_im/chat/views/suggestions.cljs @@ -1,6 +1,4 @@ (ns syng-im.chat.views.suggestions - (:require-macros - [natal-shell.core :refer [with-error-view]]) (:require [re-frame.core :refer [subscribe dispatch]] [syng-im.components.react :refer [view text @@ -25,7 +23,7 @@ [text {:style st/suggestion-description} description]]]) (defn render-row [row _ _] - (list-item [suggestion-list-item (js->clj row :keywordize-keys true)])) + (list-item [suggestion-list-item row])) (defn suggestions-view [] (let [suggestions-atom (subscribe [:get-suggestions])] diff --git a/src/syng_im/chats_list/screen.cljs b/src/syng_im/chats_list/screen.cljs index 277e1fc022..5d0092fc98 100644 --- a/src/syng_im/chats_list/screen.cljs +++ b/src/syng_im/chats_list/screen.cljs @@ -6,7 +6,7 @@ text image touchable-highlight]] - [syng-im.utils.listview :refer [to-datasource2]] + [syng-im.utils.listview :refer [to-datasource]] [reagent.core :as r] [syng-im.chats-list.views.chat-list-item :refer [chat-list-item]] [syng-im.components.action-button :refer [action-button @@ -31,7 +31,7 @@ (fn [] [view st/chats-container [chats-list-toolbar] - [list-view {:dataSource (to-datasource2 (vals @chats)) + [list-view {:dataSource (to-datasource (vals @chats)) :renderRow (fn [row _ _] (list-item [chat-list-item row])) :style st/list-container}] diff --git a/src/syng_im/contacts/screen.cljs b/src/syng_im/contacts/screen.cljs index 73d3a4d610..9170c7b9cb 100644 --- a/src/syng_im/contacts/screen.cljs +++ b/src/syng_im/contacts/screen.cljs @@ -30,7 +30,7 @@ (defn contact-list [] (let [contacts (subscribe [:get :contacts])] (fn [] - (let [contacts-ds (lw/to-datasource2 @contacts)] + (let [contacts-ds (lw/to-datasource @contacts)] [view st/contacts-list-container [contact-list-toolbar] (when contacts-ds diff --git a/src/syng_im/discovery/tag.cljs b/src/syng_im/discovery/tag.cljs index ab04eb55c9..455adce8fc 100644 --- a/src/syng_im/discovery/tag.cljs +++ b/src/syng_im/discovery/tag.cljs @@ -2,7 +2,7 @@ (:require [re-frame.core :refer [subscribe dispatch]] [syng-im.utils.logging :as log] - [syng-im.utils.listview :refer [to-datasource2]] + [syng-im.utils.listview :refer [to-datasource]] [syng-im.components.react :refer [view text list-view list-item]] [syng-im.components.toolbar :refer [toolbar]] [syng-im.discovery.views.popular-list-item :refer [popular-list-item]] @@ -25,7 +25,7 @@ (log/debug "Got discoveries: " @discoveries) (fn [] (let [items @discoveries - datasource (to-datasource2 items)] + datasource (to-datasource items)] [view st/discovery-tag-container [toolbar {:nav-action {:image {:source {:uri :icon_back} :style st/icon-back} diff --git a/src/syng_im/discovery/views/popular_list.cljs b/src/syng_im/discovery/views/popular_list.cljs index 4a82a4573d..c56ac14206 100644 --- a/src/syng_im/discovery/views/popular_list.cljs +++ b/src/syng_im/discovery/views/popular_list.cljs @@ -7,7 +7,7 @@ touchable-highlight text]] [syng-im.discovery.styles :as st] - [syng-im.utils.listview :refer [to-datasource2]] + [syng-im.utils.listview :refer [to-datasource]] [syng-im.discovery.views.popular-list-item :refer [popular-list-item]])) (defn render-row [row _ _] @@ -27,7 +27,7 @@ [text {:style st/tag-name} (str " #" (name tag))]]] [view st/tag-count-container [text {:style st/tag-count} count]]] - [list-view {:dataSource (to-datasource2 @discoveries) + [list-view {:dataSource (to-datasource @discoveries) :enableEmptySections true :renderRow render-row :renderSeparator render-separator diff --git a/src/syng_im/discovery/views/recent.cljs b/src/syng_im/discovery/views/recent.cljs index 77792e55a7..6eb1dc4038 100644 --- a/src/syng_im/discovery/views/recent.cljs +++ b/src/syng_im/discovery/views/recent.cljs @@ -2,7 +2,7 @@ (:require [re-frame.core :refer [subscribe]] [syng-im.components.react :refer [view list-view list-item]] - [syng-im.utils.listview :refer [to-datasource2]] + [syng-im.utils.listview :refer [to-datasource]] [syng-im.discovery.styles :as st] [syng-im.discovery.views.popular-list-item :refer [popular-list-item]])) @@ -18,7 +18,7 @@ (let [discoveries (subscribe [:get :discoveries])] (fn [] ;; todo fetch more on :onEndReached - [list-view {:dataSource (to-datasource2 @discoveries) + [list-view {:dataSource (to-datasource @discoveries) :renderRow render-row :renderSeparator render-separator :style st/recent-list}]))) diff --git a/src/syng_im/new_group/screen.cljs b/src/syng_im/new_group/screen.cljs index 91fcd8c3ad..5e7843c86b 100644 --- a/src/syng_im/new_group/screen.cljs +++ b/src/syng_im/new_group/screen.cljs @@ -11,7 +11,7 @@ list-item]] [syng-im.components.styles :refer [color-purple]] [syng-im.components.toolbar :refer [toolbar]] - [syng-im.utils.listview :refer [to-datasource2]] + [syng-im.utils.listview :refer [to-datasource]] [syng-im.new-group.views.contact :refer [new-group-contact]] [syng-im.new-group.styles :as st])) @@ -40,7 +40,7 @@ (defn new-group [] (let [contacts (subscribe [:all-contacts])] (fn [] - (let [contacts-ds (to-datasource2 @contacts)] + (let [contacts-ds (to-datasource @contacts)] [view st/new-group-container [new-group-toolbar] [view st/chat-name-container diff --git a/src/syng_im/participants/views/create.cljs b/src/syng_im/participants/views/create.cljs index 296fb3089b..c059bfc785 100644 --- a/src/syng_im/participants/views/create.cljs +++ b/src/syng_im/participants/views/create.cljs @@ -3,7 +3,7 @@ [syng-im.resources :as res] [syng-im.components.react :refer [view list-view list-item]] [syng-im.components.toolbar :refer [toolbar]] - [syng-im.utils.listview :refer [to-datasource2]] + [syng-im.utils.listview :refer [to-datasource]] [syng-im.participants.views.contact :refer [participant-contact]] [reagent.core :as r] @@ -24,7 +24,7 @@ (defn new-participants [{:keys [navigator]}] (let [contacts (subscribe [:all-new-contacts])] (fn [] - (let [contacts-ds (to-datasource2 @contacts)] + (let [contacts-ds (to-datasource @contacts)] [view st/participants-container [new-participants-toolbar navigator] [list-view {:dataSource contacts-ds diff --git a/src/syng_im/participants/views/remove.cljs b/src/syng_im/participants/views/remove.cljs index aa938b86ac..40ff3528f7 100644 --- a/src/syng_im/participants/views/remove.cljs +++ b/src/syng_im/participants/views/remove.cljs @@ -5,7 +5,7 @@ touchable-highlight list-view list-item]] [syng-im.components.toolbar :refer [toolbar]] - [syng-im.utils.listview :refer [to-datasource2]] + [syng-im.utils.listview :refer [to-datasource]] [syng-im.participants.views.contact :refer [participant-contact]] [reagent.core :as r] @@ -25,7 +25,7 @@ (defn remove-participants [] (let [contacts (subscribe [:current-chat-contacts])] (fn [] - (let [contacts-ds (to-datasource2 @contacts)] + (let [contacts-ds (to-datasource @contacts)] [view st/participants-container [remove-participants-toolbar] [list-view {:dataSource contacts-ds diff --git a/src/syng_im/utils/listview.cljs b/src/syng_im/utils/listview.cljs index f2fa7371e4..ab7031662e 100644 --- a/src/syng_im/utils/listview.cljs +++ b/src/syng_im/utils/listview.cljs @@ -1,13 +1,10 @@ (ns syng-im.utils.listview - (:require-macros [natal-shell.data-source :refer [data-source clone-with-rows]]) + (:require-macros [natal-shell.data-source :refer [data-source]]) (:require [syng-im.components.realm])) -(defn to-datasource [items] - (clone-with-rows (data-source {:rowHasChanged not=}) items)) - -(defn clone-with-rows2 [ds rows] +(defn clone-with-rows [ds rows] (.cloneWithRows ds (reduce (fn [ac el] (.push ac el) ac) (clj->js []) rows))) -(defn to-datasource2 [items] - (clone-with-rows2 (data-source {:rowHasChanged not=}) items)) +(defn to-datasource [items] + (clone-with-rows (data-source {:rowHasChanged not=}) items))