Skip to content

Commit

Permalink
šŸ› Fix Group Chat Rendering Problem: Do Not Return Null Group Chat Namā€¦
Browse files Browse the repository at this point in the history
ā€¦es (#392)
  • Loading branch information
alexdanilowicz authored Sep 22, 2022
1 parent 7f54f8b commit 590b614
Show file tree
Hide file tree
Showing 15 changed files with 143 additions and 130 deletions.
3 changes: 2 additions & 1 deletion app/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ npm-debug.log.*

# chat.db files
*.db-shm
*.db-wal
*.db-wal
*.db
Binary file removed app/src/__tests__/chat.db
Binary file not shown.
8 changes: 5 additions & 3 deletions app/src/analysis/tables/GroupChatCoreTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export class GroupChatCoreTable extends Table {
group by
c."ROWID"
having
count(distinct coalesced_contact_name) > 1)
count(distinct coalesced_contact_name) > 1),
SELECT
GC_CORE_TABLE AS (SELECT
text,
display_name,
human_readable_date,
Expand All @@ -32,7 +32,9 @@ export class GroupChatCoreTable extends Table {
REPLACE(REPLACE(associated_message_guid, "p:0/", ""), "p:1/", "")as associated_guid
FROM core_main_table cm
JOIN GROUP_CHAT_NAMES gcm
on cm.chat_id = gcm.chat_id
on cm.chat_id = gcm.chat_id)
SELECT * FROM GC_CORE_TABLE WHERE group_chat_name IS NOT NULL AND contact_name IS NOT NULL
`;

await sqlite3Wrapper.runP(this.db, q);
Expand Down
8 changes: 5 additions & 3 deletions app/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function App() {

useEffect(() => {
Chart.register({
id: 'lor-chartjs-no-data-to-display message',
id: 'lor-chartjs-no-data-to-display-message',
afterDraw(chart) {
const { datasets } = chart.data;
const hasData = datasets.find(
Expand Down Expand Up @@ -93,12 +93,14 @@ export function App() {
const { yAxis } = scales;
ctx.font = '13px montserrat';
ctx.fillStyle = 'gray';

const bottom = yAxis && yAxis.bottom ? yAxis.bottom : 0;
ctx.fillText(
'leftonread.me/download',
chartArea.right - 155,
yAxis.bottom + options.yPaddingText
bottom + options.yPaddingText
);
ctx.drawImage(image, 45, yAxis.bottom + options.yPaddingLogo);
ctx.drawImage(image, 45, bottom + options.yPaddingLogo);
ctx.save(); // not sure if this .save() is even needed
} else {
image.onload = () => chart.draw();
Expand Down
9 changes: 7 additions & 2 deletions app/src/components/Dashboard/GroupChatTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,17 @@ export function GroupChatTab({ filters }: { filters: SharedQueryFilters }) {
try {
const groupChatByFriendsDataList: GroupChatByFriends[] =
await ipcRenderer.invoke('query-group-chat-by-friends', filters);

console.log(groupChatByFriendsDataList);
setData(groupChatByFriendsDataList);

const setGct = [
...new Set(
groupChatByFriendsDataList.map((obj) => obj.group_chat_name)
groupChatByFriendsDataList.map((obj) => {
if (!obj.group_chat_name) {
console.log(obj);
}
return obj.group_chat_name;
})
),
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,17 @@ function GroupChatActivityOverTimeBody({
const body = (
<>
{error ? (
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<div style={{ position: 'absolute' }}>
<Text color="red.400">Uh oh! Something went wrong... </Text>
</div>
<Line data={{ labels: [], datasets: [] }} options={options} />
</div>
// <div
// style={{
// display: 'flex',
// justifyContent: 'center',
// alignItems: 'center',
// }}
// >
// <div style={{ position: 'absolute' }}>
// <Text color="red.400">Uh oh! Something went wrong... </Text>
// </div>
<Line data={{ labels: [], datasets: [] }} options={options} />
) : (
<>
{isLoading && (
Expand Down
23 changes: 11 additions & 12 deletions app/src/components/Graphs/GroupChats/GroupChatByFriendsChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,17 @@ function GroupChatByFriendsBody({
const body = (
<>
{isError ? (
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<div style={{ position: 'absolute' }}>
<Text color="red.400">Uh oh! Something went wrong... </Text>
</div>
<Bar data={{ labels: [], datasets: [] }} />
</div>
// <div
// style={{
// display: 'flex',
// justifyContent: 'center',
// alignItems: 'center',
// }}
// >
// <div style={{ position: 'absolute' }}>
// <Text color="red.400">Uh oh! Something went wrong... </Text>
// </div>
<Bar data={{ labels: [], datasets: [] }} />
) : (
<>
{isLoading && (
Expand Down
27 changes: 13 additions & 14 deletions app/src/components/Graphs/GroupChats/GroupChatReactionsChart.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/naming-convention */
import { Spinner, Text } from '@chakra-ui/react';
import { Spinner } from '@chakra-ui/react';
import { Context } from 'chartjs-plugin-datalabels';
import { ipcRenderer } from 'electron';
import log from 'electron-log';
Expand Down Expand Up @@ -259,19 +259,18 @@ function GroupChatReactionsBody({
const body = (
<>
{error ? (
<div
style={{
position: 'relative',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<div style={{ position: 'absolute' }}>
<Text color="red.400">Uh oh! Something went wrong... </Text>
</div>
<Bar data={{ labels: [], datasets: [] }} />
</div>
// <div
// style={{
// position: 'relative',
// display: 'flex',
// justifyContent: 'center',
// alignItems: 'center',
// }}
// >
// <div style={{ position: 'absolute' }}>
// <Text color="red.400">Uh oh! Something went wrong... </Text>
// </div>
<Bar data={{ labels: [], datasets: [] }} />
) : (
<>
{showLoading && (
Expand Down
24 changes: 12 additions & 12 deletions app/src/components/Graphs/SentimentOverTimeChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ function SentimentOverTimeBody({
yPaddingLogo: 110,
}
: false,
'lor-chartjs-no-data-to-display-message': !error,
};

const chartStyle: React.CSSProperties = isSharingVersion
Expand Down Expand Up @@ -201,18 +202,17 @@ function SentimentOverTimeBody({
const body = (
<>
{error ? (
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<div style={{ position: 'absolute' }}>
<Text color="red.400">Uh oh! Something went wrong... </Text>
</div>
<Line data={{ labels: [], datasets: [] }} options={options} />
</div>
// <div
// style={{
// display: 'flex',
// justifyContent: 'center',
// alignItems: 'center',
// }}
// >
// <div style={{ position: 'absolute' }}>
// <Text color="red.400">Uh oh! Something went wrong... </Text>
// </div>
<Line data={{ labels: [], datasets: [] }} options={options} />
) : (
<>
{isLoading && (
Expand Down
23 changes: 11 additions & 12 deletions app/src/components/Graphs/TextsOverTimeChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,17 @@ function TextsOverTimeBody({
const body = (
<>
{error ? (
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<div style={{ position: 'absolute' }}>
<Text color="red.400">Uh oh! Something went wrong... </Text>
</div>
<Line data={{ labels: [], datasets: [] }} options={options} />
</div>
// <div
// style={{
// display: 'flex',
// justifyContent: 'center',
// alignItems: 'center',
// }}
// >
// <div style={{ position: 'absolute' }}>
// <Text color="red.400">Uh oh! Something went wrong... </Text>
// </div>
<Line data={{ labels: [], datasets: [] }} options={options} />
) : (
<>
{isLoading && (
Expand Down
24 changes: 12 additions & 12 deletions app/src/components/Graphs/TopFriendsChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,19 +199,19 @@ function TopFriendsBody({
const body = (
<>
{error ? (
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<div style={{ position: 'absolute' }}>
<Text color="red.400">Uh oh! Something went wrong... </Text>
</div>
<Bar data={{ labels: [], datasets: [] }} />
</div>
// <div
// style={{
// display: 'flex',
// justifyContent: 'center',
// alignItems: 'center',
// }}
// >
// <div style={{ position: 'absolute' }}>
// <Text color="red.400">Uh oh! Something went wrong... </Text>
// </div>
<Bar data={{ labels: [], datasets: [] }} />
) : (
// </div>
<>
{showLoading && (
<div
Expand Down
23 changes: 11 additions & 12 deletions app/src/components/Graphs/TopSentimentFriendsChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,17 @@ function TopSentimentFriendsBody({
const body = (
<>
{error ? (
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<div style={{ position: 'absolute' }}>
<Text color="red.400">Uh oh! Something went wrong... </Text>
</div>
<Bar data={{ labels: [], datasets: [] }} />
</div>
// <div
// style={{
// display: 'flex',
// justifyContent: 'center',
// alignItems: 'center',
// }}
// >
// <div style={{ position: 'absolute' }}>
// <Text color="red.400">Uh oh! Something went wrong... </Text>
// </div>
<Bar data={{ labels: [], datasets: [] }} />
) : (
<>
{isLoading && (
Expand Down
23 changes: 11 additions & 12 deletions app/src/components/Graphs/WordOrEmojiCountChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,18 +183,17 @@ function WordOrEmojiCountBody({
const body = (
<>
{error ? (
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<div style={{ position: 'absolute' }}>
<Text color="red.400">Uh oh! Something went wrong... </Text>
</div>
<Bar data={{ labels: [], datasets: [] }} />
</div>
// <div
// style={{
// display: 'flex',
// justifyContent: 'center',
// alignItems: 'center',
// }}
// >
// <div style={{ position: 'absolute' }}>
// <Text color="red.400">Uh oh! Something went wrong... </Text>
// </div>
<Bar data={{ labels: [], datasets: [] }} />
) : (
<>
{isLoading && (
Expand Down
8 changes: 4 additions & 4 deletions app/src/components/Sharing/ShareModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,25 +149,25 @@ export function ShareModal({
return (
<Modal isOpen={isOpen} onClose={onClose} isCentered>
<ModalOverlay />
<ModalContent style={{ minWidth: '550px' }}>
<ModalContent minWidth="550px">
<ModalHeader>
<Box
style={{
padding: '15px',
}}
>
{/* <Box display="flex" justifyContent="center" alignItems="center"> */}
<Text textAlign="center" fontSize={24} color="gray.800">
{/* <Text textAlign="center" fontSize={24} color="gray.800">
Share this graph
</Text>
</Text> */}
{/* <Icon as={FiShare} /> */}
{/* </Box> */}
<Box
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
marginTop: '20px',
// marginTop: '20px',
marginBottom: '20px',
}}
>
Expand Down
Loading

0 comments on commit 590b614

Please sign in to comment.