fixed chats not loading

This commit is contained in:
Carter 2026-02-25 11:05:52 -06:00
parent 98d87ed8f7
commit c33ce3d03a
4 changed files with 19 additions and 21 deletions

View file

@ -12,7 +12,7 @@ import { useTeamAPI } from "providers";
import { cloneDeep } from "lodash"; import { cloneDeep } from "lodash";
const useStyles = makeStyles((theme: Theme) => ({ const useStyles = makeStyles<Theme>((theme: Theme) => ({
button: { button: {
color: getSignatureAccentColour(), color: getSignatureAccentColour(),
width: theme.spacing(6), width: theme.spacing(6),
@ -70,8 +70,8 @@ export default function HeaderButtons(props: Props) {
setHasNewChats(true); setHasNewChats(true);
return; return;
} }
console.log(team.preferences.chatViewedTimestamp) // console.log(team.preferences.chatViewedTimestamp)
console.log(team.settings.lastChatTimestamp) // 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) {

View file

@ -37,6 +37,7 @@ export default function Chat(props: Props) {
const loadChats = () => { const loadChats = () => {
setLoading(true) setLoading(true)
// console.log("listing chats?")
noteAPI.listChats(10, chats.length, "desc", "timestamp", objectKey).then(resp => { noteAPI.listChats(10, chats.length, "desc", "timestamp", objectKey).then(resp => {
setChats(resp.data.chats ? resp.data.chats.reverse().concat(chats) : []) setChats(resp.data.chats ? resp.data.chats.reverse().concat(chats) : [])
setTotalMessages(resp.data.total) setTotalMessages(resp.data.total)

View file

@ -46,7 +46,7 @@ export function ChatDrawer(props: Props) {
const isMobile = useMobile(); const isMobile = useMobile();
const classes = useStyles() const classes = useStyles()
console.log(team.settings.avatar) // console.log(team.settings.avatar)
return ( return (
<Drawer <Drawer
@ -72,14 +72,9 @@ export function ChatDrawer(props: Props) {
borderRight: `1px solid ${theme.palette.divider}`, borderRight: `1px solid ${theme.palette.divider}`,
})} })}
> >
{/* Add your icons here */}
<IconButton > <IconButton >
{/* <SomeIcon /> */}
<Avatar src={team.settings.avatar} /> <Avatar src={team.settings.avatar} />
</IconButton> </IconButton>
<IconButton>
{/* <AnotherIcon /> */}
</IconButton>
</Box> </Box>
{/* Main chat area */} {/* Main chat area */}

View file

@ -1,7 +1,7 @@
import { AxiosResponse } from "axios"; import { AxiosResponse } from "axios";
import { useHTTP } from "hooks"; import { useHTTP } from "hooks";
import { pond } from "protobuf-ts/pond"; import { pond } from "protobuf-ts/pond";
import { useGlobalState } from "providers"; // import { useGlobalState } from "providers";
import { createContext, PropsWithChildren, useContext } from "react"; import { createContext, PropsWithChildren, useContext } from "react";
import { pondURL } from "./pond"; import { pondURL } from "./pond";
@ -37,7 +37,7 @@ interface Props {}
export default function NoteProvider(props: PropsWithChildren<Props>) { export default function NoteProvider(props: PropsWithChildren<Props>) {
const { children } = props; const { children } = props;
const { get, del, post, put } = useHTTP(); const { get, del, post, put } = useHTTP();
const [{as}] = useGlobalState() // const [{as}] = useGlobalState()
const addNote = (note: pond.NoteSettings, attachments?: string[]) => { const addNote = (note: pond.NoteSettings, attachments?: string[]) => {
let url = pondURL("/notes" + (attachments ? "?attachments=" + attachments.toString() : "")) let url = pondURL("/notes" + (attachments ? "?attachments=" + attachments.toString() : ""))
@ -88,9 +88,9 @@ export default function NoteProvider(props: PropsWithChildren<Props>) {
orderBy?: string, orderBy?: string,
search?: string, search?: string,
asRoot?: boolean, asRoot?: boolean,
otherTeam?: string // otherTeam?: string
) => { ) => {
const view = otherTeam ? otherTeam : as // const view = otherTeam ? otherTeam : as
let url = pondURL( let url = pondURL(
"/notes" + "/notes" +
"?limit=" + "?limit=" +
@ -100,9 +100,10 @@ export default function NoteProvider(props: PropsWithChildren<Props>) {
("&order=" + (order ? order : "asc")) + ("&order=" + (order ? order : "asc")) +
("&by=" + (orderBy ? orderBy : "key")) + ("&by=" + (orderBy ? orderBy : "key")) +
(search ? "&search=" + search : "") + (search ? "&search=" + search : "") +
(asRoot ? "&asRoot=" + asRoot.toString() : "") + (asRoot ? "&asRoot=" + asRoot.toString() : ""),
(view ? "&as=" + view : "") // (view ? "&as=" + "" : "")
) )
// console.log(url)
return new Promise<AxiosResponse<pond.ListNotesResponse>>((resolve, reject) => { return new Promise<AxiosResponse<pond.ListNotesResponse>>((resolve, reject) => {
get<pond.ListNotesResponse>(url).then(resp => { get<pond.ListNotesResponse>(url).then(resp => {
resp.data = pond.ListNotesResponse.fromObject(resp.data) resp.data = pond.ListNotesResponse.fromObject(resp.data)
@ -119,10 +120,10 @@ export default function NoteProvider(props: PropsWithChildren<Props>) {
order?: "asc" | "desc", order?: "asc" | "desc",
orderBy?: string, orderBy?: string,
search?: string, search?: string,
asRoot?: boolean, // asRoot?: boolean,
otherTeam?: string // otherTeam?: string
) => { ) => {
const view = otherTeam ? otherTeam : as // const view = otherTeam ? otherTeam : as
let url = pondURL( let url = pondURL(
"/chats" + "/chats" +
"?limit=" + "?limit=" +
@ -131,10 +132,11 @@ export default function NoteProvider(props: PropsWithChildren<Props>) {
offset + offset +
("&order=" + (order ? order : "asc")) + ("&order=" + (order ? order : "asc")) +
("&by=" + (orderBy ? orderBy : "key")) + ("&by=" + (orderBy ? orderBy : "key")) +
(search ? "&search=" + search : "") + (search ? "&search=" + search : ""),
(asRoot ? "&asRoot=" + asRoot.toString() : "") + // (asRoot ? "&asRoot=" + asRoot.toString() : ""),
(view ? "&as=" + view : "") // (view ? "&as=" + view : "")
) )
// console.log(asRoot)
return new Promise<AxiosResponse<pond.ListChatsResponse>>((resolve, reject) => { return new Promise<AxiosResponse<pond.ListChatsResponse>>((resolve, reject) => {
get<pond.ListChatsResponse>(url).then(resp => { get<pond.ListChatsResponse>(url).then(resp => {
resp.data = pond.ListChatsResponse.fromObject(resp.data) resp.data = pond.ListChatsResponse.fromObject(resp.data)