Merge branch 'chat_timestamp' into dev_environment
This commit is contained in:
commit
b458dea3b1
2 changed files with 24 additions and 2 deletions
|
|
@ -8,6 +8,8 @@ import { pond } from "protobuf-ts/pond";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { getSignatureAccentColour } from "services/whiteLabel";
|
import { getSignatureAccentColour } from "services/whiteLabel";
|
||||||
import NotificationDrawer from "./NotificationDrawer";
|
import NotificationDrawer from "./NotificationDrawer";
|
||||||
|
import { useTeamAPI } from "providers";
|
||||||
|
import { cloneDeep } from "lodash";
|
||||||
|
|
||||||
|
|
||||||
const useStyles = makeStyles((theme: Theme) => ({
|
const useStyles = makeStyles((theme: Theme) => ({
|
||||||
|
|
@ -55,7 +57,9 @@ export default function HeaderButtons(props: Props) {
|
||||||
const [hasNewNotifications, setHasNewNotifications] = useState(false);
|
const [hasNewNotifications, setHasNewNotifications] = useState(false);
|
||||||
const [chatDrawerOpen, setChatDrawerOpen] = useState(false);
|
const [chatDrawerOpen, setChatDrawerOpen] = useState(false);
|
||||||
const [notificationDrawerOpen, setNotificationDrawerOpen] = useState<boolean>(false);
|
const [notificationDrawerOpen, setNotificationDrawerOpen] = useState<boolean>(false);
|
||||||
|
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
const teamAPI = useTeamAPI();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!team) return;
|
if (!team) return;
|
||||||
|
|
@ -66,6 +70,8 @@ export default function HeaderButtons(props: Props) {
|
||||||
setHasNewChats(true);
|
setHasNewChats(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.log(team.preferences.chatViewedTimestamp)
|
||||||
|
console.log(team.settings.lastChatTimestamp)
|
||||||
let viewMoment = moment(team.preferences.chatViewedTimestamp);
|
let viewMoment = moment(team.preferences.chatViewedTimestamp);
|
||||||
let chatMoment = moment(team.settings.lastChatTimestamp);
|
let chatMoment = moment(team.settings.lastChatTimestamp);
|
||||||
if (viewMoment.diff(chatMoment) < 0) {
|
if (viewMoment.diff(chatMoment) < 0) {
|
||||||
|
|
@ -154,13 +160,29 @@ export default function HeaderButtons(props: Props) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onChatClose = () => {
|
||||||
|
setChatDrawerOpen(false)
|
||||||
|
let newTeamPrefs = cloneDeep(team.preferences)
|
||||||
|
newTeamPrefs.chatViewedTimestamp = new Date().toISOString();
|
||||||
|
teamAPI
|
||||||
|
.updatePreferences(
|
||||||
|
team.key(),
|
||||||
|
newTeamPrefs,
|
||||||
|
// getContextKeys(),
|
||||||
|
// getContextTypes()
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
// setTeamPrefs(newTeamPrefs);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{chatButton()}
|
{chatButton()}
|
||||||
{team && team.settings && team.settings.key && (
|
{team && team.settings && team.settings.key && (
|
||||||
<ChatDrawer
|
<ChatDrawer
|
||||||
open={chatDrawerOpen}
|
open={chatDrawerOpen}
|
||||||
onClose={() => setChatDrawerOpen(false)}
|
onClose={onChatClose}
|
||||||
team={team}
|
team={team}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ export default function ChatMessage(props: Props) {
|
||||||
return mappedPerm; // Return null for invalid keys
|
return mappedPerm; // Return null for invalid keys
|
||||||
}).filter(Boolean); // Optionally filter out any null values
|
}).filter(Boolean); // Optionally filter out any null values
|
||||||
} else {
|
} else {
|
||||||
console.error("data.permissions is not an array or does not exist");
|
// console.error("data.permissions is not an array or does not exist");
|
||||||
perms = [];
|
perms = [];
|
||||||
}
|
}
|
||||||
return perms
|
return perms
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue