Skip to content

Commit 56e3fc8

Browse files
committed
Modified logThis import
1 parent ad1528a commit 56e3fc8

8 files changed

Lines changed: 28 additions & 28 deletions

File tree

example/react-sqlitecloud-chat/src/App.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Alert from '@mui/material/Alert';
1212
import Stack from '@mui/material/Stack';
1313
//SqliteCloud
1414
const config = require('./config').config;
15-
const utils = require('./utils');
15+
import { logThis } from './utils'
1616
import { StateProvider } from './context/StateContext';
1717
//SqliteCloud components
1818
import ChannelsList from "./ChannelsList"
@@ -22,7 +22,7 @@ import Messages from "./Messages"
2222
import { Liter } from "js-sdk"
2323

2424
const App = () => {
25-
if (config.debug.renderingProcess) utils.logThis("App: ON RENDER");
25+
if (config.debug.renderingProcess) logThis("App: ON RENDER");
2626
//credentials to establish the websocket connection
2727
var projectId = config.credential.projectId;
2828
var apikey = config.credential.apikey;
@@ -72,13 +72,13 @@ const App = () => {
7272

7373
useEffect(() => {
7474
const onMountWrapper = async () => {
75-
if (config.debug.renderingProcess) utils.logThis("App: ON useEffect");
75+
if (config.debug.renderingProcess) logThis("App: ON useEffect");
7676
//init Liter instance using provided credentials
7777
let locaLiter = new Liter(projectId, apikey, onErrorCallback, onCloseCallback);
7878
//try to enstablish websocket connection
7979
const connectionResponse = await locaLiter.connect();
8080
setConnectionResponse(connectionResponse);
81-
if (config.debug.renderingProcess) utils.logThis(connectionResponse.message);
81+
if (config.debug.renderingProcess) logThis(connectionResponse.message);
8282
if (connectionResponse.status == "success") {
8383
setLiter(locaLiter)
8484
//based on query parameters select if retrieve tabales db or channels
@@ -92,7 +92,7 @@ const App = () => {
9292
}
9393
setChannelsListResponse(channelsListResponse);
9494
if (channelsListResponse.status == "success") {
95-
if (config.debug.renderingProcess) utils.logThis("Received channels list");
95+
if (config.debug.renderingProcess) logThis("Received channels list");
9696
var channels = [];
9797
if (queryDBName !== null) {
9898
channelsListResponse.data.rows.forEach(c => {
@@ -140,10 +140,10 @@ const App = () => {
140140
setOpenMobMsg(false);
141141
}
142142
} else {
143-
if (config.debug.renderingProcess) utils.logThis(channelsListResponse.data.message);
143+
if (config.debug.renderingProcess) logThis(channelsListResponse.data.message);
144144
}
145145
} else {
146-
if (config.debug.renderingProcess) utils.logThis(connectionResponse.data.message);
146+
if (config.debug.renderingProcess) logThis(connectionResponse.data.message);
147147
}
148148
}
149149
onMountWrapper();

example/react-sqlitecloud-chat/src/ChannelElement.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import React, { Fragment, useEffect, useState, useContext } from "react";
33
//react-router
44
import { useSearchParams } from 'react-router-dom';
5-
//moment
6-
const moment = require('moment');
5+
//date-fns
6+
import { format } from 'date-fns';
77
//mui
88
import { styled } from '@mui/material/styles';
99
import CircularProgress from '@mui/material/CircularProgress';
@@ -15,7 +15,7 @@ import Badge from '@mui/material/Badge';
1515
import { green } from '@mui/material/colors';
1616
//SqliteCloud
1717
const config = require('./config').config;
18-
const utils = require('./utils');
18+
import { logThis } from './utils'
1919
//SqliteCloud context
2020
import { StateContext } from "./context/StateContext"
2121

@@ -68,8 +68,8 @@ const ErrorBadge = styled(Badge)(({ theme }) => ({
6868
}));
6969

7070

71-
const ChannelElement = ({ liter, index, name, selectionState, setSelectedChannel, setSelectedChannelIndex, setOpenMobMsg }) => {
72-
if (config.debug.renderingProcess) utils.logThis("ChannelElement: ON RENDER");
71+
const ChannelElement = ({ liter, index, name, selectionState, setSelectedChannel, setSelectedChannelIndex, setOpenMobMsg }) => {
72+
if (config.debug.renderingProcess) logThis("ChannelElement: ON RENDER");
7373
//colors used to indicated if the channel is selected or no
7474
const accent = green[500];
7575
const white = "#FFF";
@@ -98,7 +98,7 @@ const ChannelElement = ({ liter, index, name, selectionState, setSelectedChannel
9898
console.log(message) //TOGLIMI
9999
let newChsMap = new Map(JSON.parse(JSON.stringify(Array.from(chsMapRef.current))));
100100
let newMessages = JSON.parse(JSON.stringify(newChsMap.get(name)));
101-
message.time = moment().format('MMMM Do YYYY, h:mm:ss a'); //TIZIANO MIGLIORARE FORMATO ORA DI RICEZIONE
101+
message.time = format(new Date(), "yyyy-MM-dd' | 'HH:mm:ss")
102102
setMsgTimestamp(message.time);
103103
newMessages.push(message);
104104
newChsMap.set(name, newMessages)

example/react-sqlitecloud-chat/src/ChannelsList.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import Paper from '@mui/material/Paper';
77
import Stack from '@mui/material/Stack';
88
//SqliteCloud
99
const config = require('./config').config;
10-
const utils = require('./utils');
10+
import { logThis } from './utils'
1111
//SqliteCloute Components
1212
import ChannelElement from './ChannelElement'
1313

1414
const ChannelsList = ({ liter, channelsList, setSelectedChannel, setOpenMobMsg, selectedChannelIndex, setSelectedChannelIndex }) => {
15-
if (config.debug.renderingProcess) utils.logThis("ChannelsList: ON RENDER");
15+
if (config.debug.renderingProcess) logThis("ChannelsList: ON RENDER");
1616
return (
1717
<Grid
1818
sx={{

example/react-sqlitecloud-chat/src/MessageEditor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import InputBase from '@mui/material/InputBase';
99
import IconButton from '@mui/material/IconButton';
1010
//SqliteCloud
1111
const config = require('./config').config;
12-
const utils = require('./utils');
12+
import { logThis } from './utils'
1313
//SqliteCloud context
1414

1515
const MessageEditor = ({ liter }) => {
16-
if (config.debug.renderingProcess) utils.logThis("MessageEditor: ON RENDER");
16+
if (config.debug.renderingProcess) logThis("MessageEditor: ON RENDER");
1717

1818
const editorRef = useRef(null)
1919
const formRef = useRef(null)

example/react-sqlitecloud-chat/src/Messages.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ import Grid from '@mui/material/Unstable_Grid2';
55
import Drawer from '@mui/material/Drawer';
66
//SqliteCloud
77
const config = require('./config').config;
8-
const utils = require('./utils');
8+
import { logThis } from './utils'
99
//SqliteCloud context
1010
import { StateContext } from "./context/StateContext"
1111
//SqliteCloud componets
1212
import MessagesBar from "./MessagesBar";
1313
import MessagesPresentation from "./MessagesPresentation";
1414

1515
const Messages = ({ liter, selectedChannel, show, showEditor, openMobMsg, setOpenMobMsg, setSelectedChannel, setSelectedChannelIndex }) => {
16-
if (config.debug.renderingProcess) utils.logThis("Messages: ON RENDER");
16+
if (config.debug.renderingProcess) logThis("Messages: ON RENDER");
1717
//read from context all channels registered
1818
const { chsMap } = useContext(StateContext);
1919

example/react-sqlitecloud-chat/src/MessagesBar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import ArrowBackIcon from '@mui/icons-material/ArrowBack';
1313
import { green } from '@mui/material/colors';
1414
//SqliteCloud
1515
const config = require('./config').config;
16-
const utils = require('./utils');
16+
import { logThis } from './utils'
1717
//SqliteCloud context
1818
import { StateContext } from "./context/StateContext"
1919
//SqliteCloud componets
2020

2121

2222
const MessagesBar = ({ channel, setOpenMobMsg, setSelectedChannel, setSelectedChannelIndex }) => {
23-
if (config.debug.renderingProcess) utils.logThis("MessagesBar: ON RENDER");
23+
if (config.debug.renderingProcess) logThis("MessagesBar: ON RENDER");
2424
const theme = useTheme();
2525
const accent = green[500];
2626
const white = "#FFF";

example/react-sqlitecloud-chat/src/MessagesPresentation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Grid from '@mui/material/Unstable_Grid2';
77
import { green } from '@mui/material/colors';
88
//SqliteCloud
99
const config = require('./config').config;
10-
const utils = require('./utils');
10+
import { logThis } from './utils'
1111
//SqliteCloud context
1212
import { StateContext } from "./context/StateContext"
1313
//SqliteCloud componets
@@ -16,7 +16,7 @@ import MessageEditor from "./MessageEditor";
1616

1717

1818
const MessagesPresentation = ({ messages, liter, showEditor }) => {
19-
if (config.debug.renderingProcess) utils.logThis("MessagesPresentation: ON RENDER");
19+
if (config.debug.renderingProcess) logThis("MessagesPresentation: ON RENDER");
2020

2121
const contRef = useRef(null);
2222

example/react-sqlitecloud-chat/src/SingleMessage.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Divider from '@mui/material/Divider';
1212
import { green, red, blue, cyan, teal } from '@mui/material/colors';
1313
//SqliteCloud
1414
const config = require('./config').config;
15-
const utils = require('./utils');
15+
import { logThis } from './utils'
1616
//SqliteCloud context
1717

1818
function NewlineText({ text }) {
@@ -35,11 +35,11 @@ function NewlineText({ text }) {
3535
}
3636

3737
const SingleMessage = ({ msg, showEditor }) => {
38-
if (config.debug.renderingProcess) utils.logThis("SingleMessage: ON RENDER");
38+
if (config.debug.renderingProcess) logThis("SingleMessage: ON RENDER");
3939
//colors used to indicated if the channel is selected or no
40-
const accent = green[500];
41-
const me = cyan[100];
42-
const other = teal[100];
40+
const accent = green[500];
41+
const me = cyan[100];
42+
const other = teal[100];
4343
const white = "#FFF";
4444

4545

0 commit comments

Comments
 (0)