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";
const useStyles = makeStyles((theme: Theme) => ({
const useStyles = makeStyles<Theme>((theme: Theme) => ({
button: {
color: getSignatureAccentColour(),
width: theme.spacing(6),
@ -70,8 +70,8 @@ export default function HeaderButtons(props: Props) {
setHasNewChats(true);
return;
}
console.log(team.preferences.chatViewedTimestamp)
console.log(team.settings.lastChatTimestamp)
// console.log(team.preferences.chatViewedTimestamp)
// console.log(team.settings.lastChatTimestamp)
let viewMoment = moment(team.preferences.chatViewedTimestamp);
let chatMoment = moment(team.settings.lastChatTimestamp);
if (viewMoment.diff(chatMoment) < 0) {

View file

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

View file

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

View file

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