diff --git a/package.json b/package.json
index 4e6690f..8ddb6e2 100644
--- a/package.json
+++ b/package.json
@@ -16,11 +16,6 @@
"url": "https://github.com/ForceDotComLabs/react.force.datacontainer/issues"
},
"homepage": "https://github.com/ForceDotComLabs/react.force.datacontainer#readme",
- "peerDependencies": {
- "react-native": ">=0.20.0",
- "react.force": "git+ssh://git@github.com/ForceDotComLabs/react.force.git",
- "react.force.data": "git+ssh://git@github.com/ForceDotComLabs/react.force.data.git"
- },
"dependencies": {
"lodash.findindex": "^4.4.0",
"lodash.keys": "^4.0.7",
diff --git a/src/ChatterUserContainer/index.js b/src/ChatterUserContainer/index.js
new file mode 100644
index 0000000..30f9ca3
--- /dev/null
+++ b/src/ChatterUserContainer/index.js
@@ -0,0 +1,139 @@
+'use strict';
+
+import React from 'react';
+
+import ReactNative, {
+ Text,
+ View
+} from 'react-native';
+
+import shallowEqual from 'shallowequal';
+import findIndex from 'lodash.findindex';
+
+import {
+ chatterQuery,
+ getByChatterUserId
+} from 'react.force.data';
+
+const subscribers = [];
+
+const subscribe = (comp)=>{
+ subscribers.push(comp)
+};
+
+const unsubscribe = (comp) => {
+ const i = subscribers.indexOf(comp);
+ if(i != -1) {
+ subscribers.splice(i, 1);
+ }
+};
+
+const notify = (ids, records) => {
+ if(subscribers && subscribers.length){
+ subscribers.forEach((subscriber)=>{
+ if(subscriber && subscriber.props && subscriber.props.id){
+ const searchId = subscriber.props.id;
+ const index = findIndex(ids, (id) => {
+ return id.indexOf(searchId)>-1;
+ });
+ if(index>-1){
+ const record = records[index];
+ subscriber.updateChatterData(record);
+ }
+ }
+ });
+ }
+};
+
+chatterQuery.addListener(notify);
+
+
+module.exports = React.createClass ({
+ getDefaultProps(){
+ return {
+ type:null,
+ id:null,
+ refreshDate:new Date(),
+ update:true,
+ style:{}
+ };
+ },
+ childContextTypes: {
+ chatterData: React.PropTypes.object,
+ doRefresh: React.PropTypes.func
+ },
+ getInitialState(){
+ return {
+ chatterData:this.props.chatterData?this.props.chatterData:{Name:' ',attributes:{}},
+ loading:false
+ };
+ },
+ getChildContext() {
+ return {
+ chatterData: this.state.chatterData,
+ doRefresh: this.handleRefresh
+ };
+ },
+ componentDidMount(){
+ this.getInfo();
+ subscribe(this);
+ },
+ componentWillUnmount(){
+ unsubscribe(this);
+ },
+ handleRefresh(){
+ console.log('>>> REFRESH !!!');
+ this.getInfo();
+ },
+ updateChatterData(chatterData){
+ this.setState({
+ chatterData:chatterData,
+ });
+ },
+ handleDataLoad(){
+ if(this.props.onData){
+ this.props.onData({
+ chatterData:this.state.chatterData
+ });
+ }
+ },
+ getInfo() {
+ this.setState({loading:true});
+ if(!this.props.type || !this.props.id){
+ return;
+ }
+ getByChatterUserId(this.props.id)
+ .then((opts)=>{
+ if(opts.cachedChatterData){
+ this.setState({
+ chatterData: opts.cachedChatterData
+ });
+ }
+ });
+ },
+
+ render() {
+ return (
+
+ {this.props.children}
+
+ )
+ },
+ componentWillReceiveProps(newProps){
+ if(this.props.refreshDate !== newProps.refreshDate){
+ this.getInfo();
+ }
+ },
+ shouldComponentUpdate(nextProps, nextState){
+ if(!this.props.update){
+ return false;
+ }
+ if(this.props.id !== nextProps.id){
+ return true;
+ }
+ if(!shallowEqual(this.state.chatterData, nextState.chatterData)){
+ return true;
+ }
+ return false;
+ }
+});
diff --git a/src/List/index.js b/src/List/index.js
index 17ca854..508f3ce 100644
--- a/src/List/index.js
+++ b/src/List/index.js
@@ -26,7 +26,9 @@
'use strict';
-import React, {
+import React from 'react';
+
+import ReactNative, {
Text,
View,
ListView
diff --git a/src/RelevantItems/index.js b/src/RelevantItems/index.js
index 17fe1ab..443fae8 100644
--- a/src/RelevantItems/index.js
+++ b/src/RelevantItems/index.js
@@ -26,7 +26,9 @@
'use strict';
-import React, {
+import React from 'react';
+
+import ReactNative, {
View,
ListView
} from 'react-native';
diff --git a/src/ReportContainer/index.js b/src/ReportContainer/index.js
new file mode 100755
index 0000000..06591bc
--- /dev/null
+++ b/src/ReportContainer/index.js
@@ -0,0 +1,145 @@
+'use strict';
+
+import React from 'react';
+
+import ReactNative, {
+ Text,
+ View,
+ ListView
+} from 'react-native';
+
+import shallowEqual from 'shallowequal';
+import findIndex from 'lodash.findindex';
+import {forceClient} from 'react.force';
+
+import {
+ reportQuery,
+ getByReportId
+} from 'react.force.data';
+
+const subscribers = [];
+
+const subscribe = (comp)=>{
+ subscribers.push(comp)
+};
+
+const unsubscribe = (comp) => {
+ const i = subscribers.indexOf(comp);
+ if(i != -1) {
+ subscribers.splice(i, 1);
+ }
+};
+
+const notify = (id, record) => {
+ if(subscribers && subscribers.length){
+ subscribers.forEach((subscriber)=>{
+ if(subscriber && subscriber.props && subscriber.props.id){
+ const searchId = subscriber.props.id;
+ /*const index = findIndex(ids, (id) => {
+ return id.indexOf(searchId)>-1;
+ });*/
+ const index = id.indexOf(searchId)>-1;
+ if(index>-1){
+ //const record = records[index];
+ subscriber.updateReportData(record);
+ }
+ }
+ });
+ }
+};
+
+reportQuery.addListener(notify);
+
+module.exports = React.createClass ({
+ getDefaultProps(){
+ return {
+ type:null,
+ id:null,
+ refreshDate:new Date(),
+ update:true,
+ style:{},
+ refreshPeriod: 600000 // default refresh period of 10 minutes, passed in as seconds
+ };
+ },
+ childContextTypes: {
+ reportData: React.PropTypes.object,
+ doRefresh: React.PropTypes.func
+ },
+ getInitialState(){
+ return {
+ reportData:this.props.reportData?this.props.reportData:{Name:' ',attributes:{}},
+ loading:false
+ };
+ },
+ getChildContext() {
+ return {
+ reportData: this.state.reportData,
+ doRefresh: this.handleRefresh
+ };
+ },
+ componentDidMount(){
+ this.getInfo();
+ subscribe(this);
+ },
+ componentWillUnmount(){
+ unsubscribe(this);
+ },
+ handleRefresh(){
+ console.log('>>> REFRESH !!!');
+ this.getInfo();
+ },
+ updateReportData(reportData){
+ this.setState({
+ reportData:reportData,
+ });
+ },
+ handleDataLoad(){
+ if(this.props.onData){
+ this.props.onData({
+ reportData:this.state.reportData
+ });
+ }
+ },
+ getInfo() {
+ this.setState({loading:true});
+ if(!this.props.id){
+ return;
+ }
+ getByReportId(this.props.id)
+ .then((opts)=>{
+ if(opts.cachedReportData){
+ this.setState({
+ reportData: opts.cachedReportData
+ });
+ }
+ });
+ },
+ render() {
+ return (
+
+ {this.props.children}
+
+ )
+ },
+ componentWillReceiveProps(newProps){
+ if(this.props.refreshDate.getTime() <= newProps.refreshDate.getTime()-(this.props.refreshPeriod*1000)){
+ this.getInfo();
+ }
+ },
+ shouldComponentUpdate(nextProps, nextState){
+ //update if change in reportId, entityId, or reportData
+ if(!this.props.update){
+ return false;
+ }
+ if(this.props.id !== nextProps.id){
+ return true;
+ }
+ if(this.props.entityId !== nextProps.entityId) {
+ return true;
+ }
+ if(!shallowEqual(this.state.reportData, nextState.reportData)){
+ return true;
+ }
+ return false;
+ }
+});
diff --git a/src/ScrollRefresh/index.js b/src/ScrollRefresh/index.js
index 959210c..9f5ed15 100644
--- a/src/ScrollRefresh/index.js
+++ b/src/ScrollRefresh/index.js
@@ -26,7 +26,9 @@
'use strict';
-import React, {
+import React from 'react';
+
+import ReactNative, {
View,
ScrollView,
RefreshControl
@@ -68,7 +70,9 @@ module.exports = React.createClass ({
/>
}
>
+
{this.props.children}
+
)
},
diff --git a/src/SobjContainer/index.js b/src/SobjContainer/index.js
index b54dd5b..cc883fe 100644
--- a/src/SobjContainer/index.js
+++ b/src/SobjContainer/index.js
@@ -26,7 +26,9 @@
'use strict';
-import React, {
+import React from 'react';
+
+import ReactNative, {
Text,
View
} from 'react-native';
diff --git a/src/index.js b/src/index.js
index cd2f440..a8eb7d9 100644
--- a/src/index.js
+++ b/src/index.js
@@ -23,8 +23,10 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-
+
import SobjContainer from './SobjContainer';
+import ChatterUserContainer from './ChatterUserContainer';
+import ReportContainer from './ReportContainer';
import List from './List';
import RelevantItems from './RelevantItems';
import ScrollRefresh from './ScrollRefresh';
@@ -32,10 +34,12 @@ import {utils} from 'react.force.data';
module.exports = {
SobjContainer: SobjContainer,
+ ChatterUserContainer: ChatterUserContainer,
Sobj: SobjContainer,
ListContainer: List,
List: List,
RelevantItems: RelevantItems,
ScrollRefresh: ScrollRefresh,
- utils: utils
-};
\ No newline at end of file
+ utils: utils,
+ ReportContainer: ReportContainer
+};