diff --git a/jam-ui/package-lock.json b/jam-ui/package-lock.json
index 3244ddf71..75a8fc1ab 100644
--- a/jam-ui/package-lock.json
+++ b/jam-ui/package-lock.json
@@ -1736,6 +1736,24 @@
"resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz",
"integrity": "sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw=="
},
+ "@reduxjs/toolkit": {
+ "version": "1.6.1",
+ "resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-1.6.1.tgz",
+ "integrity": "sha512-pa3nqclCJaZPAyBhruQtiRwtTjottRrVJqziVZcWzI73i6L3miLTtUyWfauwv08HWtiXLx1xGyGt+yLFfW/d0A==",
+ "requires": {
+ "immer": "^9.0.1",
+ "redux": "^4.1.0",
+ "redux-thunk": "^2.3.0",
+ "reselect": "^4.0.0"
+ },
+ "dependencies": {
+ "immer": {
+ "version": "9.0.6",
+ "resolved": "https://registry.npmjs.org/immer/-/immer-9.0.6.tgz",
+ "integrity": "sha512-G95ivKpy+EvVAnAab4fVa4YGYn24J1SpEktnJX7JJ45Bd7xqME/SCplFzYFmTbrkwZbQ4xJK1xMTUYBkN6pWsQ=="
+ }
+ }
+ },
"@svgr/babel-plugin-add-jsx-attribute": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-4.2.0.tgz",
@@ -15328,6 +15346,11 @@
"@babel/runtime": "^7.9.2"
}
},
+ "redux-thunk": {
+ "version": "2.3.0",
+ "resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.3.0.tgz",
+ "integrity": "sha512-km6dclyFnmcvxhAcrQV2AkZmPQjzPDjgVlQtR0EQjxZPyJ0BnMf3in1ryuR8A2qU0HldVRfxYXbFSKlI3N7Slw=="
+ },
"regenerate": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz",
@@ -15631,6 +15654,11 @@
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
"integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8="
},
+ "reselect": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/reselect/-/reselect-4.0.0.tgz",
+ "integrity": "sha512-qUgANli03jjAyGlnbYVAV5vvnOmJnODyABz51RdBN7M4WaVu8mecZWgyQNkG8Yqe3KRGRt0l4K4B3XVEULC4CA=="
+ },
"resize-observer-polyfill": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz",
diff --git a/jam-ui/package.json b/jam-ui/package.json
index 020bf7ddb..92d75d58c 100644
--- a/jam-ui/package.json
+++ b/jam-ui/package.json
@@ -17,6 +17,7 @@
"@fullcalendar/react": "^5.3.1",
"@fullcalendar/timegrid": "^5.3.1",
"@loadable/component": "^5.13.2",
+ "@reduxjs/toolkit": "^1.6.1",
"attr-accept": "^2.2.2",
"bootstrap": "^4.5.3",
"chart.js": "^2.9.3",
diff --git a/jam-ui/src/App.js b/jam-ui/src/App.js
index c89603aa9..a928319b9 100644
--- a/jam-ui/src/App.js
+++ b/jam-ui/src/App.js
@@ -1,63 +1,16 @@
import React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
-import Layout from './layouts/Layout';
+import JKLayout from './layouts/JKLayout';
import 'react-toastify/dist/ReactToastify.min.css';
import 'react-datetime/css/react-datetime.css';
import 'react-image-lightbox/style.css';
-import useScript from './hooks/useScript';
-
-import { useDispatch } from "react-redux";
-//import { addMessage } from "./store/features/textMessagesSlice"
-
const App = () => {
-
- function initJKScripts() {
- const app = window.JK.JamKazam();
- const jamServer = new window.JK.JamServer(app, function(event_type) {
- console.log('---EVENT_TYPE---', event_type);
- //return app.activeElementEvent(event_type)
- });
- jamServer.initialize();
- window.JK.initJamClient(app);
-
- const clientInit = new window.JK.ClientInit();
- clientInit.init();
-
- window.JK.JamServer.connect() // singleton here defined in JamServer.js
- .done(function() {
- console.log('Jamserver connected');
- //_initAfterConnect(true);
- })
- .fail(function() {
- console.log('Jamserver connection error');
- //_initAfterConnect(false);
- });
-
- registerTextMessageCallback();
-
- }
-
- function registerTextMessageCallback(){
- window.JK.JamServer.registerMessageCallback(window.JK.MessageType.TEXT_MESSAGE, function(header, payload) {
- console.log('Handling TEXT_MESSAGE ' + JSON.stringify(payload));
- // chatMessageReceived(payload);
- // context.ChatActions.msgReceived(payload);
- // handledNotification(payload);
-
- //dispatch(addMessage())
-
- });
- }
-
- const dispatch = useDispatch()
-
- useScript(`${process.env.REACT_APP_LEGACY_BASE_URL}/client_scripts`, initJKScripts);
return (
-
+
);
};
diff --git a/jam-ui/src/components/auth/JKLoginRequest.js b/jam-ui/src/components/auth/JKLoginRequest.js
new file mode 100644
index 000000000..285b35fa4
--- /dev/null
+++ b/jam-ui/src/components/auth/JKLoginRequest.js
@@ -0,0 +1,29 @@
+import React from 'react'
+import { Card, CardBody, Row, Col } from 'reactstrap';
+import Logo from '../navbar/Logo';
+import Section from '../common/Section';
+
+function JKLoginRequest() {
+ return (
+
+
+
+
+
+
+
+ Signin to begin
+ Please login to your jamkazam account before accessing this interface.
+
+ Signin
+
+
+
+
+
+
+
+ )
+}
+
+export default JKLoginRequest
diff --git a/jam-ui/src/components/dashboard/JKDashboardLoadingIndicator.js b/jam-ui/src/components/dashboard/JKDashboardLoadingIndicator.js
new file mode 100644
index 000000000..ffb2eea35
--- /dev/null
+++ b/jam-ui/src/components/dashboard/JKDashboardLoadingIndicator.js
@@ -0,0 +1,11 @@
+import React from 'react'
+
+function JKDashboardLoadingIndicator() {
+ return (
+
+ Loading...
+
+ )
+}
+
+export default JKDashboardLoadingIndicator
diff --git a/jam-ui/src/components/dashboard/JkDashboard.js b/jam-ui/src/components/dashboard/JkDashboard.js
index fa0adb4b2..15bb2f33d 100644
--- a/jam-ui/src/components/dashboard/JkDashboard.js
+++ b/jam-ui/src/components/dashboard/JkDashboard.js
@@ -1,10 +1,93 @@
-import React from "react";
+import React, { useContext, useEffect } from 'react';
-const JKDashboard = () => {
+import { Route, Switch } from 'react-router-dom';
- return(
- Dashboard
- )
+import NavbarTop from '../navbar/NavbarTop';
+import NavbarVertical from '../navbar/NavbarVertical';
+import JKFooter from '../footer/JKFooter';
+
+import AppContext from '../../context/Context';
+import { getPageName } from '../../helpers/utils';
+
+import useScript from '../../hooks/useScript';
+import { useDispatch } from "react-redux";
+import { addMessage } from "../../store/features/textMessagesSlice"
+
+import JKHome from './JkHome';
+import loadable from '@loadable/component';
+const JKDashboardRoutes = loadable(() => import('../../layouts/JKDashboardRoutes'));
+
+function JKDashboard() {
+ const { isFluid, isVertical, navbarStyle } = useContext(AppContext);
+ const isKanban = getPageName('kanban');
+
+ useEffect(() => {
+ JKDashboardRoutes.preload();
+ }, []);
+
+ const dispatch = useDispatch()
+
+ const initJKScripts = () => {
+ const app = window.JK.JamKazam();
+ const jamServer = new window.JK.JamServer(app, function(event_type) {
+ console.log('EVENT_TYPE', event_type);
+ });
+ jamServer.initialize();
+ window.JK.initJamClient(app);
+ const clientInit = new window.JK.ClientInit();
+ clientInit.init();
+
+ window.JK.JamServer.connect() // singleton here defined in JamServer.js
+ .done(function() {
+ console.log('Jamserver connected');
+ //_initAfterConnect(true);
+ })
+ .fail(function() {
+ console.log('Jamserver connection error');
+ //_initAfterConnect(false);
+ });
+
+ registerTextMessageCallback();
+
+ }
+
+ const registerTextMessageCallback = () => {
+ window.JK.JamServer.registerMessageCallback(window.JK.MessageType.TEXT_MESSAGE, function(header, payload) {
+ const json = payload
+ const receivedMsg = {
+ id: json.text_message_id,
+ message: json.msg,
+ senderId: json.sender_id,
+ senderName: json.sender_name,
+ receiverId: window.currentUser.id,
+ receiverName: window.currentUser.first_name,
+ createdAt: json.created_at,
+ sent: true
+ }
+
+ dispatch(addMessage(receivedMsg))
+
+ });
+ }
+
+ useScript(`${process.env.REACT_APP_LEGACY_BASE_URL}/client_scripts`, initJKScripts);
+
+ return (
+
+ {isVertical &&
}
+
+
+
+
+
+
+
+ {!isKanban && }
+
+ {/*
*/}
+
+
+ );
}
-export default JKDashboard;
\ No newline at end of file
+export default JKDashboard;
diff --git a/jam-ui/src/components/dashboard/JkHome.js b/jam-ui/src/components/dashboard/JkHome.js
new file mode 100644
index 000000000..c117e97dc
--- /dev/null
+++ b/jam-ui/src/components/dashboard/JkHome.js
@@ -0,0 +1,10 @@
+import React from "react";
+
+const JKHome = () => {
+
+ return(
+ Dashboard - Home
+ )
+}
+
+export default JKHome;
\ No newline at end of file
diff --git a/jam-ui/src/components/footer/JKFooter.js b/jam-ui/src/components/footer/JKFooter.js
new file mode 100644
index 000000000..3f14c9ecb
--- /dev/null
+++ b/jam-ui/src/components/footer/JKFooter.js
@@ -0,0 +1,20 @@
+import React from 'react';
+import { Col, Row } from 'reactstrap';
+import { version } from '../../config';
+
+const JKFooter = () => (
+
+);
+
+export default JKFooter;
diff --git a/jam-ui/src/components/profile/JKMessageModal.js b/jam-ui/src/components/profile/JKMessageModal.js
index 418c6303d..aba024824 100644
--- a/jam-ui/src/components/profile/JKMessageModal.js
+++ b/jam-ui/src/components/profile/JKMessageModal.js
@@ -1,5 +1,5 @@
import React, { useEffect, useState, useRef } from 'react';
-import { Modal, ModalHeader, ModalBody, Row, Col, Button, ModalFooter } from 'reactstrap';
+import { Modal, ModalHeader, ModalBody, Row, Col, Button, ModalFooter, Badge } from 'reactstrap';
import { Scrollbar } from 'react-scrollbars-custom';
import TimeAgo from 'react-timeago';
import JKProfileAvatar from './JKProfileAvatar';
@@ -11,31 +11,40 @@ const JKMessageModal = props => {
const { show, setShow, user } = props;
const LIMIT = 20;
+ const [fetching, setFetching] = useState(false);
const [offset, setOffset] = useState(0);
const [newMessage, setNewMessage] = useState('');
+ const [messagesArrived, setMessagesArrived] = useState(false);
const toggle = () => setShow(!show);
const { currentUser } = useAuth();
const dispatch = useDispatch();
const scrollbar = useRef();
+ const messageTextBox = useRef();
+ const scrolledToBottom = useRef(false);
const messages = useSelector(state =>
state.textMessage.messages
.filter(
message =>
- (message.senderId === user.id && message.receiverId === currentUser.id) ||
- (message.senderId === currentUser.id && message.receiverId === user.id)
+ (message.senderId === user.id && message.receiverId === window.currentUser.id) ||
+ (message.senderId === window.currentUser.id && message.receiverId === user.id)
)
- .reverse()
+ .sort((a, b) => {
+ return new Date(a.createdAt) - new Date(b.createdAt);
+ })
);
const fetchMessages = async () => {
try {
- await dispatch(fetchMessagesByReceiverId(user.id)).unwrap();
- scrollbar.current.scrollToBottom();
+ const options = { userId: user.id, offset: offset, limit: LIMIT };
+ setFetching(true);
+ await dispatch(fetchMessagesByReceiverId(options)).unwrap();
} catch (err) {
console.log('ERROR', err);
+ } finally {
+ setFetching(false);
}
};
@@ -48,37 +57,102 @@ const JKMessageModal = props => {
};
setNewMessage('');
await dispatch(postNewMessage(msgData)).unwrap();
- fetchMessages();
} catch (err) {
console.log('addNewMessage error', err);
} finally {
}
};
- const handleOnKeyPress = (event) => {
- //console.log('event', event.key);
- if(event.key === 'Enter' || event.key === "NumpadEnter"){
- sendMessage()
+ const handleOnKeyPress = event => {
+ if (event.key === 'Enter' || event.key === 'NumpadEnter') {
+ event.preventDefault();
+ sendMessage();
+ event.target.value = '';
}
- }
+ };
+
+ const scrollAtTop = () => {
+ return scrollbar.current.scrollTop === 0;
+ };
+
+ const scrollAtMiddle = () => {
+ return scrollbar.current.scrollHeight - scrollbar.current.clientHeight > scrollbar.current.scrollTop;
+ };
+
+ const scrollAtBottom = () => {
+ return scrollbar.current.scrollHeight - scrollbar.current.clientHeight === scrollbar.current.scrollTop;
+ };
+
+ const goToBottom = () => {
+ if (scrollbar && scrollbar.current) {
+ scrollbar.current.scrollToBottom();
+ }
+ };
useEffect(() => {
- if (show) {
- //console.log('JKMessageModal User', user.id);
+ if (show && messages.length === 0) {
fetchMessages();
}
- }, [show, dispatch]);
+ }, [show]);
+
+
+ useEffect(() => {
+ if (scrollbar && scrollbar.current) {
+ if (!fetching && !scrollAtTop()) {
+ if (messages[messages.length - 1]['senderId'] !== currentUser.id) {
+ if (!scrolledToBottom.current) {
+ setMessagesArrived(true);
+ } else {
+ goToBottom();
+ }
+ } else {
+ goToBottom();
+ }
+ }
+ }
+ }, [messages]);
+
+ useEffect(() => {
+ if (!messagesArrived) {
+ setMessagesArrived(false);
+ goToBottom();
+ }
+ }, [messagesArrived]);
+
+ const handleScrollStop = scrollValues => {
+ scrolledToBottom.current = false;
+ if (scrollValues.scrollTop === 0) {
+ setOffset(prev => prev + 1);
+ } else if (scrollValues.scrollTop === scrollValues.scrollHeight - scrollValues.clientHeight) {
+ scrolledToBottom.current = true;
+ setMessagesArrived(false);
+ }
+ };
+
+ useEffect(() => {
+ if (offset !== 0) {
+ fetchMessages();
+ }
+ }, [offset]);
return (
<>
Conversation with {user.name}
-
+
{messages.map((message, index) => (
-
+
@@ -93,6 +167,9 @@ const JKMessageModal = props => {
if (unit === 'minute') return `${value} ${value === 1 ? 'minute' : 'minutes'} ago`;
if (unit === 'hour') return `${value} ${value === 1 ? 'hour' : 'hours'} ago`;
if (unit === 'day') return `${value} ${value === 1 ? 'day' : 'days'} ago`;
+ if (unit === 'week') return `${value} ${value === 1 ? 'week' : 'weeks'} ago`;
+ if (unit === 'month') return `${value} ${value === 1 ? 'month' : 'months'} ago`;
+ if (unit === 'year') return `${value} ${value === 1 ? 'year' : 'years'} ago`;
}}
/>
@@ -103,9 +180,24 @@ const JKMessageModal = props => {
))}
+ {messagesArrived && (
+
+
+
+
+
+ )}
-
diff --git a/jam-ui/src/components/profile/JKProfileSidePanel.js b/jam-ui/src/components/profile/JKProfileSidePanel.js
index c06b6659b..c905a847d 100644
--- a/jam-ui/src/components/profile/JKProfileSidePanel.js
+++ b/jam-ui/src/components/profile/JKProfileSidePanel.js
@@ -13,6 +13,7 @@ import JKProfileGenres from './JKProfileGenres';
import JKProfilePerformanceSamples from './JKProfilePerformanceSamples';
import { useAuth } from '../../context/AuthContext';
import JKConnectButton from './JKConnectButton';
+import JKMessageButton from './JKMessageButton';
import JKLatencyBadge from './JKLatencyBadge';
import JKLastActiveAgo from './JKLastActiveAgo';
import JKProfileSkillLevel from './JKProfileSkillLevel';
@@ -139,9 +140,13 @@ const JKProfileSidePanel = props => {
>
}
/>{' '}
-
*/}
+
+
+ Send Message
+
)}
diff --git a/jam-ui/src/hooks/useScript.js b/jam-ui/src/hooks/useScript.js
index 2d17b5ab9..350450622 100644
--- a/jam-ui/src/hooks/useScript.js
+++ b/jam-ui/src/hooks/useScript.js
@@ -1,5 +1,5 @@
import { useEffect } from 'react';
-const useScript = (src, onloadHandler) => {
+const useScript = (src, onloadHandler = () => {}) => {
useEffect(() => {
const script = document.createElement('script');
script.src = src;
diff --git a/jam-ui/src/layouts/DashboardLayout.js b/jam-ui/src/layouts/DashboardLayout.js
index a75acf751..d546f28ac 100644
--- a/jam-ui/src/layouts/DashboardLayout.js
+++ b/jam-ui/src/layouts/DashboardLayout.js
@@ -1,61 +1,23 @@
-import React, { useState, useContext, useEffect } from 'react';
+import React, { useContext, useEffect } from 'react';
import PropTypes from 'prop-types';
-import { Route, Switch, Redirect, NavLink } from 'react-router-dom';
-import { Card, CardBody, Row, Col, Button } from 'reactstrap';
-import Logo from '../components/navbar/Logo';
-import Section from '../components/common/Section';
-//import Dashboard from '../components/dashboard/Dashboard';
-import JKDashboard from '../components/dashboard/JkDashboard';
-//import DashboardAlt from '../components/dashboard-alt/DashboardAlt';
-
+import { Route, Switch } from 'react-router-dom';
+import Dashboard from '../components/dashboard/Dashboard';
+import DashboardAlt from '../components/dashboard-alt/DashboardAlt';
import NavbarTop from '../components/navbar/NavbarTop';
import NavbarVertical from '../components/navbar/NavbarVertical';
import Footer from '../components/footer/Footer';
import loadable from '@loadable/component';
import AppContext from '../context/Context';
import ProductProvider from '../components/e-commerce/ProductProvider';
-// import SidePanelModal from '../components/side-panel/SidePanelModal';
+import SidePanelModal from '../components/side-panel/SidePanelModal';
import { getPageName } from '../helpers/utils';
-import { useAuth } from '../context/AuthContext';
-import { getCurrentUser } from '../helpers/rest';
-
-
-const AUTH_STAGES = {
- loading: 1,
- authenticated: 2,
- unauthenticated: 3
-};
-
const DashboardRoutes = loadable(() => import('./DashboardRoutes'));
const DashboardLayout = ({ location }) => {
+ const { isFluid, isVertical, navbarStyle } = useContext(AppContext);
- const { currentUser, setCurrentUser } = useAuth();
-
- const [stage, setStage] = useState(AUTH_STAGES['loading']);
-
- const fetchCurrentUser = () => {
- getCurrentUser()
- .then(resp => {
- if (resp.ok) {
- return resp.json();
- }
- })
- .then(data => {
- console.log('layout CURRENT_USER', data);
- setCurrentUser(data);
- setStage(AUTH_STAGES['authenticated']);
- })
- .catch(error => {
- setStage(AUTH_STAGES['unauthenticated']);
- console.log(error);
- });
- };
-
- useEffect(() => {
- fetchCurrentUser();
- }, []);
+ const isKanban = getPageName('kanban');
useEffect(() => {
DashboardRoutes.preload();
@@ -65,84 +27,22 @@ const DashboardLayout = ({ location }) => {
window.scrollTo(0, 0);
}, [location.pathname]);
- switch (stage) {
- case AUTH_STAGES['authenticated']:
- return ;
- case AUTH_STAGES['unauthenticated']:
- return ;
- default:
- return ;
- }
-};
-
-const DashboardLoadingIndicator = () => {
return (
-
- Loading...
-
- );
-};
-
-const LoginRequestSection = () => {
- return (
-
-
-
-
-
-
-
- Signin to begin
- Please login to your jamkazam account before accessing this interface.
-
- Signin
-
-
-
-
-
-
-
- );
-};
-
-const DashboardSection = () => {
- const { isFluid, isVertical, navbarStyle } = useContext(AppContext);
- const isKanban = getPageName('kanban');
-
- return (
-
{isVertical &&
}
- {/* */}
- {/* */}
-
+
+
{!isKanban && }
- {/* */}
+
-
- );
-};
-
-const ProtectedRoute = ({ component: Component, ...rest }) => {
- const { currentUser } = useAuth();
- return (
- // Show the component only when the user is logged in
- // Otherwise, redirect the user to /login page
-
- currentUser ? :
- }
- />
);
};
diff --git a/jam-ui/src/layouts/DashboardRoutes.js b/jam-ui/src/layouts/DashboardRoutes.js
index 3abf79e40..6b565c3e9 100644
--- a/jam-ui/src/layouts/DashboardRoutes.js
+++ b/jam-ui/src/layouts/DashboardRoutes.js
@@ -1,153 +1,148 @@
-import { fn } from 'moment';
import React from 'react';
import { Redirect, Route, Switch } from 'react-router-dom';
-// import Alerts from '../components/bootstrap-components/Alerts';
-// import Avatar from '../components/bootstrap-components/Avatar';
-// import AutocompleteExample from '../components/bootstrap-components/AutocompleteExample';
-// import Backgrounds from '../components/bootstrap-components/Backgrounds';
-// import Badges from '../components/bootstrap-components/Badges';
-// import Breadcrumbs from '../components/bootstrap-components/Breadcrumb';
-// import Buttons from '../components/bootstrap-components/Buttons';
-// import Cards from '../components/bootstrap-components/Cards';
-// import Carousel from '../components/bootstrap-components/Carousel';
-// import Collapses from '../components/bootstrap-components/Collapses';
-// import Combo from '../components/bootstrap-components/Combo';
-// import CookieNotice from '../components/bootstrap-components/CookieNotice';
-// import Dropdowns from '../components/bootstrap-components/Dropdowns';
-// import FalconAccordions from '../components/bootstrap-components/FalconAccordions';
-// import Forms from '../components/bootstrap-components/Forms';
-// import ListGroups from '../components/bootstrap-components/ListGroups';
-// import Modals from '../components/bootstrap-components/Modals';
-// import Navbars from '../components/bootstrap-components/Navbars';
-// import NavBarTop from '../components/bootstrap-components/NavBarTop';
-// import Navs from '../components/bootstrap-components/Navs';
-// import PageHeaders from '../components/bootstrap-components/PageHeaders';
-// import Paginations from '../components/bootstrap-components/Paginations';
-// import Popovers from '../components/bootstrap-components/Popovers';
-// import ProgressBar from '../components/bootstrap-components/ProgressBar';
-// import Sidepanel from '../components/bootstrap-components/Sidepanel';
-// import Spinners from '../components/bootstrap-components/Spinners';
-// import Tables from '../components/bootstrap-components/Tables';
-// import Tabs from '../components/bootstrap-components/Tabs';
-// import Tooltips from '../components/bootstrap-components/Tooltips';
-// import VerticalNavbar from '../components/bootstrap-components/VerticalNavbar';
-// import Calendar from '../components/calendar/Calendar';
-// import ChangeLog from '../components/changelog/ChangeLog';
-// import Chat from '../components/chat/Chat';
-// import GettingStarted from '../components/documentation/GettingStarted';
-// import Checkout from '../components/e-commerce/Checkout';
-// import Customers from '../components/e-commerce/Customers';
-// import FavouriteItems from '../components/e-commerce/FavouriteItems';
-// import OrderDetails from '../components/e-commerce/OrderDetails';
-// import Orders from '../components/e-commerce/Orders';
-// import ProductDetails from '../components/e-commerce/ProductDetails';
-// import Products from '../components/e-commerce/Products';
-// import ShoppingCart from '../components/e-commerce/ShoppingCart';
-// import Compose from '../components/email/Compose';
-// import EmailDetail from '../components/email/EmailDetail';
-// import Inbox from '../components/email/Inbox';
-// import InboxProvider from '../components/email/inbox/InboxProvider';
-// import Starter from '../components/extra/Starter';
-// import Feed from '../components/feed/Feed';
-// import Kanban from '../components/kanban/Kanban';
-// import Activity from '../components/page/Activity';
-// import Associations from '../components/page/Associations';
-// import Billing from '../components/page/Billing';
-// import CustomerDetails from '../components/page/CustomerDetails';
-// import EventCreate from '../components/page/EventCreate';
-// import EventDetail from '../components/page/EventDetail';
-// import Events from '../components/page/Events';
-// import Faq from '../components/page/Faq';
-// import InvitePeople from '../components/page/InvitePeople';
-// import Invoice from '../components/page/Invoice';
-// import Notifications from '../components/page/Notifications';
-// import People from '../components/page/People';
-// import Settings from '../components/page/Settings';
-// import BulkSelect from '../components/plugins/BulkSelect';
-// import CalendarExample from '../components/plugins/CalendarExample';
-// import Chart from '../components/plugins/Chart';
-// import CodeHighlightDoc from '../components/plugins/CodeHighlightDoc';
-// import CountUpExample from '../components/plugins/Countup';
-// import DatetimeExample from '../components/plugins/Datetime';
-// import Dropzone from '../components/plugins/Dropzone';
-// import EchartMap from '../components/plugins/EchartMap';
-// import Echarts from '../components/plugins/Echarts';
-// import EmojiMart from '../components/plugins/EmojiMart';
-// import FontAwesome from '../components/plugins/FontAwesome';
-// import GoogleMapExample from '../components/plugins/GoogleMap';
-// import ImageLightbox from '../components/plugins/ImageLightbox';
-// import Leaflet from '../components/plugins/Leaflet';
-// import Lottie from '../components/plugins/Lottie';
-// import Plyr from '../components/plugins/Plyr';
-// import ProgressBarJs from '../components/plugins/ProgressBarJs';
-// import QuillEditorExample from '../components/plugins/Quill';
-// import ReactBeautifulDnD from '../components/plugins/ReactBeautifulDnD';
-// import ReactBootstrapTable2 from '../components/plugins/ReactBootstrapTable2';
-// import ReactHookFrom from '../components/plugins/ReactHookFrom';
-// import Scrollbar from '../components/plugins/Scrollbar';
-// import Select from '../components/plugins/Select';
-// import SlickCarousel from '../components/plugins/SlickCarousel';
-// import Toastify from '../components/plugins/Toastify';
-// import Typed from '../components/plugins/Typed';
-// import Pricing from '../components/pricing/Pricing';
-// import PricingAlt from '../components/pricing/PricingAlt';
-// import Profile from '../components/profile/Profile';
-// import Borders from '../components/utilities/Borders';
-// import Clearfix from '../components/utilities/Clearfix';
-// import CloseIcon from '../components/utilities/CloseIcon';
-// import Colors from '../components/utilities/Colors';
-// import Display from '../components/utilities/Display';
-// import Embed from '../components/utilities/Embed';
-// import Figures from '../components/utilities/Figures';
-// import Flex from '../components/utilities/Flex';
-// import Grid from '../components/utilities/Grid';
-// import Sizing from '../components/utilities/Sizing';
-// import Spacing from '../components/utilities/Spacing';
-// import StretchedLink from '../components/utilities/StretchedLink';
-// import Typography from '../components/utilities/Typography';
-// import VerticalAlign from '../components/utilities/VerticalAlign';
-// import Visibility from '../components/utilities/Visibility';
-// import Widgets from '../components/widgets/Widgets';
-import JKPeople from '../components/page/JKPeople';
+import Alerts from '../components/bootstrap-components/Alerts';
+import Avatar from '../components/bootstrap-components/Avatar';
+import AutocompleteExample from '../components/bootstrap-components/AutocompleteExample';
+import Backgrounds from '../components/bootstrap-components/Backgrounds';
+import Badges from '../components/bootstrap-components/Badges';
+import Breadcrumbs from '../components/bootstrap-components/Breadcrumb';
+import Buttons from '../components/bootstrap-components/Buttons';
+import Cards from '../components/bootstrap-components/Cards';
+import Carousel from '../components/bootstrap-components/Carousel';
+import Collapses from '../components/bootstrap-components/Collapses';
+import Combo from '../components/bootstrap-components/Combo';
+import CookieNotice from '../components/bootstrap-components/CookieNotice';
+import Dropdowns from '../components/bootstrap-components/Dropdowns';
+import FalconAccordions from '../components/bootstrap-components/FalconAccordions';
+import Forms from '../components/bootstrap-components/Forms';
+import ListGroups from '../components/bootstrap-components/ListGroups';
+import Modals from '../components/bootstrap-components/Modals';
+import Navbars from '../components/bootstrap-components/Navbars';
+import NavBarTop from '../components/bootstrap-components/NavBarTop';
+import Navs from '../components/bootstrap-components/Navs';
+import PageHeaders from '../components/bootstrap-components/PageHeaders';
+import Paginations from '../components/bootstrap-components/Paginations';
+import Popovers from '../components/bootstrap-components/Popovers';
+import ProgressBar from '../components/bootstrap-components/ProgressBar';
+import Sidepanel from '../components/bootstrap-components/Sidepanel';
+import Spinners from '../components/bootstrap-components/Spinners';
+import Tables from '../components/bootstrap-components/Tables';
+import Tabs from '../components/bootstrap-components/Tabs';
+import Tooltips from '../components/bootstrap-components/Tooltips';
+import VerticalNavbar from '../components/bootstrap-components/VerticalNavbar';
+import Calendar from '../components/calendar/Calendar';
+import ChangeLog from '../components/changelog/ChangeLog';
+import Chat from '../components/chat/Chat';
+import GettingStarted from '../components/documentation/GettingStarted';
+import Checkout from '../components/e-commerce/Checkout';
+import Customers from '../components/e-commerce/Customers';
+import FavouriteItems from '../components/e-commerce/FavouriteItems';
+import OrderDetails from '../components/e-commerce/OrderDetails';
+import Orders from '../components/e-commerce/Orders';
+import ProductDetails from '../components/e-commerce/ProductDetails';
+import Products from '../components/e-commerce/Products';
+import ShoppingCart from '../components/e-commerce/ShoppingCart';
+import Compose from '../components/email/Compose';
+import EmailDetail from '../components/email/EmailDetail';
+import Inbox from '../components/email/Inbox';
+import InboxProvider from '../components/email/inbox/InboxProvider';
+import Starter from '../components/extra/Starter';
+import Feed from '../components/feed/Feed';
+import Kanban from '../components/kanban/Kanban';
+import Activity from '../components/page/Activity';
+import Associations from '../components/page/Associations';
+import Billing from '../components/page/Billing';
+import CustomerDetails from '../components/page/CustomerDetails';
+import EventCreate from '../components/page/EventCreate';
+import EventDetail from '../components/page/EventDetail';
+import Events from '../components/page/Events';
+import Faq from '../components/page/Faq';
+import InvitePeople from '../components/page/InvitePeople';
+import Invoice from '../components/page/Invoice';
+import Notifications from '../components/page/Notifications';
+import People from '../components/page/People';
+import Settings from '../components/page/Settings';
+import BulkSelect from '../components/plugins/BulkSelect';
+import CalendarExample from '../components/plugins/CalendarExample';
+import Chart from '../components/plugins/Chart';
+import CodeHighlightDoc from '../components/plugins/CodeHighlightDoc';
+import CountUpExample from '../components/plugins/Countup';
+import DatetimeExample from '../components/plugins/Datetime';
+import Dropzone from '../components/plugins/Dropzone';
+import EchartMap from '../components/plugins/EchartMap';
+import Echarts from '../components/plugins/Echarts';
+import EmojiMart from '../components/plugins/EmojiMart';
+import FontAwesome from '../components/plugins/FontAwesome';
+import GoogleMapExample from '../components/plugins/GoogleMap';
+import ImageLightbox from '../components/plugins/ImageLightbox';
+import Leaflet from '../components/plugins/Leaflet';
+import Lottie from '../components/plugins/Lottie';
+import Plyr from '../components/plugins/Plyr';
+import ProgressBarJs from '../components/plugins/ProgressBarJs';
+import QuillEditorExample from '../components/plugins/Quill';
+import ReactBeautifulDnD from '../components/plugins/ReactBeautifulDnD';
+import ReactBootstrapTable2 from '../components/plugins/ReactBootstrapTable2';
+import ReactHookFrom from '../components/plugins/ReactHookFrom';
+import Scrollbar from '../components/plugins/Scrollbar';
+import Select from '../components/plugins/Select';
+import SlickCarousel from '../components/plugins/SlickCarousel';
+import Toastify from '../components/plugins/Toastify';
+import Typed from '../components/plugins/Typed';
+import Pricing from '../components/pricing/Pricing';
+import PricingAlt from '../components/pricing/PricingAlt';
+import Profile from '../components/profile/Profile';
+import Borders from '../components/utilities/Borders';
+import Clearfix from '../components/utilities/Clearfix';
+import CloseIcon from '../components/utilities/CloseIcon';
+import Colors from '../components/utilities/Colors';
+import Display from '../components/utilities/Display';
+import Embed from '../components/utilities/Embed';
+import Figures from '../components/utilities/Figures';
+import Flex from '../components/utilities/Flex';
+import Grid from '../components/utilities/Grid';
+import Sizing from '../components/utilities/Sizing';
+import Spacing from '../components/utilities/Spacing';
+import StretchedLink from '../components/utilities/StretchedLink';
+import Typography from '../components/utilities/Typography';
+import VerticalAlign from '../components/utilities/VerticalAlign';
+import Visibility from '../components/utilities/Visibility';
+import Widgets from '../components/widgets/Widgets';
-// const InboxRoutes = ({ match: { url } }) => (
-//
-//
-//
-//
-//
+const InboxRoutes = ({ match: { url } }) => (
+
+
+
+
+
-// {/*Redirect*/}
-//
-//
-//
-// );
+ {/*Redirect*/}
+
+
+
+);
-// const ProductRoutes = ({ match: { url } }) => (
-//
-//
-//
-//
-//
-//
-//
-//
-//
-//
+const ProductRoutes = ({ match: { url } }) => (
+
+
+
+
+
+
+
+
+
+
-// {/*Redirect*/}
-//
-//
-// );
+ {/*Redirect*/}
+
+
+);
const DashboardRoutes = () => (
-
-
-
- {/* */}
+
{/*Pages*/}
- {/*
+
@@ -163,30 +158,30 @@ const DashboardRoutes = () => (
- */}
+
{/*chat*/}
- {/* */}
+
{/*calendar*/}
- {/* */}
+
{/*kanban*/}
- {/* */}
+
{/*E commerce*/}
- {/* */}
+
{/*Email*/}
- {/* */}
+
{/*widgets*/}
- {/* */}
+
{/*Documentation*/}
- {/* */}
+
{/*Changelog*/}
- {/* */}
+
{/*Components*/}
- {/*
+
@@ -215,10 +210,10 @@ const DashboardRoutes = () => (
- */}
+
{/*Utilities*/}
- {/*
+
@@ -232,10 +227,10 @@ const DashboardRoutes = () => (
- */}
+
{/*Plugins*/}
- {/*
+
@@ -260,12 +255,11 @@ const DashboardRoutes = () => (
- */}
+
{/*Redirect*/}
);
-
export default DashboardRoutes;
diff --git a/jam-ui/src/layouts/JKDashboardLayout.js b/jam-ui/src/layouts/JKDashboardLayout.js
new file mode 100644
index 000000000..d86c38188
--- /dev/null
+++ b/jam-ui/src/layouts/JKDashboardLayout.js
@@ -0,0 +1,76 @@
+import React, { useState, useEffect } from 'react';
+import PropTypes from 'prop-types';
+import { Route, Redirect } from 'react-router-dom';
+
+import JKDashboardLoadingIndicator from '../components/dashboard/JKDashboardLoadingIndicator';
+import JKLoginRequest from '../components/auth/JKLoginRequest';
+import JKDashboard from '../components/dashboard/JKDashboard';
+
+import { useAuth } from '../context/AuthContext';
+import { getCurrentUser } from '../helpers/rest';
+
+const AUTH_STAGES = {
+ loading: 1,
+ authenticated: 2,
+ unauthenticated: 3
+};
+
+const JKDashboardLayout = ({ location }) => {
+
+ const { setCurrentUser } = useAuth();
+ const [stage, setStage] = useState(AUTH_STAGES['loading']);
+
+ const fetchCurrentUser = () => {
+ getCurrentUser()
+ .then(resp => {
+ if (resp.ok) {
+ return resp.json();
+ }
+ })
+ .then(user => {
+ setCurrentUser(user);
+ window.currentUser = user;
+ setStage(AUTH_STAGES['authenticated']);
+ })
+ .catch(error => {
+ setStage(AUTH_STAGES['unauthenticated']);
+ console.log(error);
+ });
+ };
+
+ useEffect(() => {
+ fetchCurrentUser();
+ }, []);
+
+ useEffect(() => {
+ window.scrollTo(0, 0);
+ }, [location.pathname]);
+
+ switch (stage) {
+ case AUTH_STAGES['authenticated']:
+ return ;
+ case AUTH_STAGES['unauthenticated']:
+ return ;
+ default:
+ return ;
+ }
+};
+
+
+const ProtectedRoute = ({ component: Component, ...rest }) => {
+ const { currentUser } = useAuth();
+ return (
+ // Show the component only when the user is logged in
+ // Otherwise, redirect the user to /login page
+
+ currentUser ? :
+ }
+ />
+ );
+};
+
+JKDashboardLayout.propTypes = { location: PropTypes.object.isRequired };
+
+export default JKDashboardLayout;
diff --git a/jam-ui/src/layouts/JKDashboardRoutes.js b/jam-ui/src/layouts/JKDashboardRoutes.js
new file mode 100644
index 000000000..96f1b1bca
--- /dev/null
+++ b/jam-ui/src/layouts/JKDashboardRoutes.js
@@ -0,0 +1,15 @@
+import React from 'react';
+import { Redirect, Route, Switch } from 'react-router-dom';
+import JKPeople from '../components/page/JKPeople';
+
+const JKDashboardRoutes = () => (
+
+
+
+ {/*Redirect*/}
+
+
+);
+
+
+export default JKDashboardRoutes;
diff --git a/jam-ui/src/layouts/JKLayout.js b/jam-ui/src/layouts/JKLayout.js
new file mode 100644
index 000000000..57dbdc679
--- /dev/null
+++ b/jam-ui/src/layouts/JKLayout.js
@@ -0,0 +1,22 @@
+import React from 'react';
+import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
+import { toast, ToastContainer } from 'react-toastify';
+import { CloseButton, Fade } from '../components/common/Toast';
+
+import JKDashboardLayout from './JKDashboardLayout';
+import ErrorLayout from './ErrorLayout';
+
+
+const JKLayout = () => {
+ return (
+ }>
+
+
+
+
+ } position={toast.POSITION.BOTTOM_LEFT} />
+
+ );
+};
+
+export default JKLayout;
diff --git a/jam-ui/src/layouts/Layout.js b/jam-ui/src/layouts/Layout.js
index cf4590604..32234a223 100644
--- a/jam-ui/src/layouts/Layout.js
+++ b/jam-ui/src/layouts/Layout.js
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from 'react';
+import React, { useEffect } from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import { toast, ToastContainer } from 'react-toastify';
import { CloseButton, Fade } from '../components/common/Toast';
@@ -6,42 +6,33 @@ import { CloseButton, Fade } from '../components/common/Toast';
import DashboardLayout from './DashboardLayout';
import ErrorLayout from './ErrorLayout';
-
-
-// import loadable from '@loadable/component';
-
-//const AuthBasicLayout = loadable(() => import('./AuthBasicLayout'));
-//const Landing = loadable(() => import('../components/landing/Landing'));
-//const WizardLayout = loadable(() => import('../components/auth/wizard/WizardLayout'));
-//const AuthCardRoutes = loadable(() => import('../components/auth/card/AuthCardRoutes'));
-//const AuthSplitRoutes = loadable(() => import('../components/auth/split/AuthSplitRoutes'));
+import loadable from '@loadable/component';
+const AuthBasicLayout = loadable(() => import('./AuthBasicLayout'));
+const Landing = loadable(() => import('../components/landing/Landing'));
+const WizardLayout = loadable(() => import('../components/auth/wizard/WizardLayout'));
+const AuthCardRoutes = loadable(() => import('../components/auth/card/AuthCardRoutes'));
+const AuthSplitRoutes = loadable(() => import('../components/auth/split/AuthSplitRoutes'));
const Layout = () => {
-
-
-
useEffect(() => {
- //AuthBasicLayout.preload();
- //Landing.preload();
- //WizardLayout.preload();
- //AuthCardRoutes.preload();
- //AuthSplitRoutes.preload();
+ AuthBasicLayout.preload();
+ Landing.preload();
+ WizardLayout.preload();
+ AuthCardRoutes.preload();
+ AuthSplitRoutes.preload();
}, []);
return (
}>
- {/* */}
- {/* */}
- {/*
-
- */}
+
+
+
+
- {/* */}
-
+
-
} position={toast.POSITION.BOTTOM_LEFT} />
);
diff --git a/jam-ui/src/store/features/textMessagesSlice.js b/jam-ui/src/store/features/textMessagesSlice.js
index 70a3fcfd5..be17abd3f 100644
--- a/jam-ui/src/store/features/textMessagesSlice.js
+++ b/jam-ui/src/store/features/textMessagesSlice.js
@@ -4,37 +4,33 @@ import { getTextMessages, createTextMessage } from '../../helpers/rest';
const initialState = {
messages: [],
status: 'idel',
- error: null,
- offset: 0
+ error: null
}
-// const [offset, setOffset] = useState(0);
-// const LIMIT = 20;
-
export const fetchMessagesByReceiverId = createAsyncThunk(
'textMessage/fetchMessagesByReceiverId',
- async (userId, thunkAPI) => {
+ async (options, thunkAPI) => {
+ const { userId, offset, limit } = options
const response = await getTextMessages({
- target_user_id: userId
- // offset: offset,
- // limit: LIMIT
+ target_user_id: userId,
+ offset: offset,
+ limit: limit
})
return response.json()
}
)
export const resturectureTextMessage = (args) => {
- const { payload, sent } = args
- //console.log(payload);
- const messageId = payload.id ? payload.id : nanoid()
- const createdAt = payload.created_at ? payload.created_at : new Date().toISOString()
+ const { message, sent } = args
+ const messageId = message.id ? message.id : nanoid()
+ const createdAt = message.created_at ? message.created_at : new Date().toISOString()
return {
id: messageId,
- message: payload.message,
- senderId: payload.source_user_id,
- senderName: payload.source_user['first_name'],
- receiverId: payload.target_user_id,
- receiverName: payload.target_user['first_name'],
+ message: message.message,
+ senderId: message.source_user_id,
+ senderName: message.source_user['name'],
+ receiverId: message.target_user_id,
+ receiverName: message.target_user['name'],
createdAt: createdAt,
sent: sent
}
@@ -44,7 +40,7 @@ export const postNewMessage = createAsyncThunk(
'textMessage/postNewMessage',
async (message, thunkAPI) => {
const response = await createTextMessage(message)
- return { status: response.status, payload: message }
+ return response.json()
}
)
@@ -65,8 +61,11 @@ export const textMessageSlice = createSlice({
})
.addCase(fetchMessagesByReceiverId.fulfilled, (state, action) => {
state.status = 'succeeded'
- console.log(action.payload);
- state.messages = action.payload.map(message => resturectureTextMessage({ payload: message, sent: true }))
+ const msgs = action.payload.map(message => resturectureTextMessage({ message, sent: true }))
+ const mergedMsgs = [...state.messages, ...msgs]
+ const unique = [];
+ mergedMsgs.map(x => unique.filter(a => a.id == x.id).length > 0 ? null : unique.push(x));
+ state.messages = unique
})
.addCase(fetchMessagesByReceiverId.rejected, (state, action) => {
state.status = 'failed'
@@ -74,6 +73,7 @@ export const textMessageSlice = createSlice({
})
.addCase(postNewMessage.fulfilled, (state, action) => {
console.log("postNewMessage fullfilled", action.payload);
+ state.messages.push(resturectureTextMessage({ message: action.payload, sent: true }))
})
}
})
diff --git a/pb/.gitignore b/pb/.gitignore
index 1caad971e..b5119adee 100644
--- a/pb/.gitignore
+++ b/pb/.gitignore
@@ -3,3 +3,4 @@ target
*~
bin
.bundle
+.ruby-version
diff --git a/pb/src/client_container.proto b/pb/src/client_container.proto
index 5107744ae..b59f24f83 100644
--- a/pb/src/client_container.proto
+++ b/pb/src/client_container.proto
@@ -631,6 +631,7 @@ message TextMessage {
optional string notification_id = 5;
optional string created_at = 6;
optional bool clipped_msg = 7;
+ optional string text_message_id = 8;
}
message ChatMessage {
diff --git a/ruby/lib/jam_ruby/message_factory.rb b/ruby/lib/jam_ruby/message_factory.rb
index 91fe095a6..ce99e57bc 100644
--- a/ruby/lib/jam_ruby/message_factory.rb
+++ b/ruby/lib/jam_ruby/message_factory.rb
@@ -985,7 +985,7 @@ module JamRuby
end
# creates the general purpose text message
- def text_message(receiver_id, sender_photo_url, sender_name, sender_id, msg, clipped_msg, notification_id, created_at)
+ def text_message(receiver_id, sender_photo_url, sender_name, sender_id, msg, clipped_msg, notification_id, created_at, text_message_id)
text_message = Jampb::TextMessage.new(
:photo_url => sender_photo_url,
:sender_name => sender_name,
@@ -993,7 +993,8 @@ module JamRuby
:msg => msg,
:clipped_msg => clipped_msg,
:notification_id => notification_id,
- :created_at => created_at
+ :created_at => created_at,
+ text_message_id: text_message_id
)
Jampb::ClientMessage.new(
diff --git a/ruby/lib/jam_ruby/models/notification.rb b/ruby/lib/jam_ruby/models/notification.rb
index e937b19d5..834ea28cd 100644
--- a/ruby/lib/jam_ruby/models/notification.rb
+++ b/ruby/lib/jam_ruby/models/notification.rb
@@ -1522,7 +1522,7 @@ module JamRuby
end
end
- def send_text_message(message, sender, receiver)
+ def send_text_message(message, sender, receiver, text_message_id)
notification = Notification.new
notification.description = NotificationTypes::TEXT_MESSAGE
@@ -1542,7 +1542,9 @@ module JamRuby
truncated_msg,
msg_is_clipped,
notification.id,
- notification.created_date)
+ notification.created_date,
+ text_message_id
+ )
logger.debug('-' * 30)
logger.debug(msg)
logger.debug('-' * 30)
diff --git a/ruby/lib/jam_ruby/models/text_message.rb b/ruby/lib/jam_ruby/models/text_message.rb
index 549182751..09e3f7486 100644
--- a/ruby/lib/jam_ruby/models/text_message.rb
+++ b/ruby/lib/jam_ruby/models/text_message.rb
@@ -55,7 +55,7 @@ module JamRuby
tm.save
# send notification
- @notification = Notification.send_text_message(sanitized_text, User.find(source_user_id), User.find(target_user_id))
+ @notification = Notification.send_text_message(sanitized_text, User.find(source_user_id), User.find(target_user_id), tm.id)
tm
end
diff --git a/web/app/controllers/api_text_messages_controller.rb b/web/app/controllers/api_text_messages_controller.rb
index 2cf919690..b8aa155f7 100644
--- a/web/app/controllers/api_text_messages_controller.rb
+++ b/web/app/controllers/api_text_messages_controller.rb
@@ -12,7 +12,8 @@ class ApiTextMessagesController < ApiController
def create
@text_message = TextMessage.create(params[:message], params[:target_user_id], current_user.id)
- respond_with_model(@text_message, new: true)
+ #respond_with_model(@text_message, new: true)
+ respond_with @text_message
end
end
\ No newline at end of file
diff --git a/web/app/views/api_text_messages/create.rabl b/web/app/views/api_text_messages/create.rabl
new file mode 100644
index 000000000..c3925a103
--- /dev/null
+++ b/web/app/views/api_text_messages/create.rabl
@@ -0,0 +1,11 @@
+object @text_message
+
+attributes :id, :source_user_id, :target_user_id, :message, :created_at
+
+child :source_user => :source_user do |msg|
+ attributes :id, :name
+end
+
+child :target_user => :target_user do |msg|
+ attributes :id, :name
+end
\ No newline at end of file
diff --git a/web/app/views/api_text_messages/index.rabl b/web/app/views/api_text_messages/index.rabl
index cb6570229..34d203fd9 100644
--- a/web/app/views/api_text_messages/index.rabl
+++ b/web/app/views/api_text_messages/index.rabl
@@ -3,9 +3,9 @@ collection @text_messages
attributes :id, :source_user_id, :target_user_id, :message, :created_at
child :source_user => :source_user do |msg|
- attributes :id, :name, :first_name
+ attributes :id, :name
end
child :target_user => :target_user do |msg|
- attributes :id, :name, :first_name
+ attributes :id, :name
end
\ No newline at end of file