replace to-datasource2

Former-commit-id: 85e05a451d
This commit is contained in:
Roman Volosovskyi 2016-05-13 19:03:14 +03:00
parent 96821edf6b
commit 8de3be1f6f
11 changed files with 22 additions and 27 deletions

View File

@ -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])

View File

@ -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])]

View File

@ -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}]

View File

@ -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

View File

@ -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}

View File

@ -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

View File

@ -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}])))

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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))