fixing fixing bug changing the query data
This commit is contained in:
@@ -208,7 +208,7 @@ async function getUserLines(req: Request, res: Response) {
|
||||
|
||||
const resObj = new GetUserLinesResponse(masterLines);
|
||||
|
||||
res.json(new NirvanaResponse(resObj));
|
||||
res.json(new NirvanaResponse<GetUserLinesResponse>(resObj));
|
||||
} catch (error) {
|
||||
res.status(500).json(error);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export class LineMember {
|
||||
public lineId: ObjectId,
|
||||
public userId: ObjectId,
|
||||
|
||||
public state: LineMemberState = LineMemberState.INBOX,
|
||||
public state: LineMemberState,
|
||||
|
||||
public createdDate: Date = new Date(),
|
||||
public _id?: ObjectId
|
||||
|
||||
@@ -207,18 +207,18 @@ function useSocketHandler(linesData: MasterLineData[]) {
|
||||
// ?are prolly looking to do a full app refresh and connection refresh
|
||||
const newMap = { ...prevMappings };
|
||||
|
||||
linesData.map((masterLine) => {
|
||||
linesData.forEach((masterLine) => {
|
||||
const lineId = masterLine.lineDetails._id.toString();
|
||||
newMap[lineId] = masterLine;
|
||||
|
||||
console.log(masterLine);
|
||||
|
||||
handleConnectToLine(lineId);
|
||||
|
||||
// tune into lines that I should be
|
||||
if (masterLine.currentUserMember.state === LineMemberState.TUNED) {
|
||||
// don't need to turn toggle on, it's already on
|
||||
handleTuneToLine(lineId, false);
|
||||
// ! CHANGE PARADIGM TO NOT INCLUDING TOGGLING IN REQUESTS WITH THE SAME AS TUNING IN
|
||||
// right now, writing just because of later logic
|
||||
handleTuneToLine(lineId, true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -344,8 +344,6 @@ export function LineDataProvider({ children }) {
|
||||
// ?just do simple synchronous axios/fetch in useEffect and manage isLoading ourselves?
|
||||
const { data: basicUserLinesData } = useUserLines();
|
||||
|
||||
console.log(basicUserLinesData?.data?.masterLines);
|
||||
|
||||
const { linesMap, ...handlers } = useSocketHandler(
|
||||
basicUserLinesData?.data?.masterLines
|
||||
);
|
||||
@@ -355,7 +353,7 @@ export function LineDataProvider({ children }) {
|
||||
}
|
||||
|
||||
const value: ILineDataContext & ReturnType<typeof useSocketHandler> = {
|
||||
linesMap: {}, // TODO send the updated map instead of this array
|
||||
linesMap, // TODO send the updated map instead of this array
|
||||
relevantUsers: [],
|
||||
$ws,
|
||||
...handlers,
|
||||
|
||||
@@ -18,7 +18,7 @@ export default class NirvanaApi {
|
||||
// auth token from google that our backend will use
|
||||
static _jwtToken?: string;
|
||||
|
||||
static async fetch(
|
||||
static async fetch<T>(
|
||||
url: string,
|
||||
method: Method,
|
||||
privateRoute = false,
|
||||
@@ -88,7 +88,11 @@ async function userSearch(searchQuery: string): Promise<UserSearchResponse> {
|
||||
}
|
||||
|
||||
async function getUserLines(): Promise<NirvanaResponse<GetUserLinesResponse>> {
|
||||
return await NirvanaApi.fetch(`/lines`, "GET", true);
|
||||
return await NirvanaApi.fetch<NirvanaResponse<GetUserLinesResponse>>(
|
||||
`/lines`,
|
||||
"GET",
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
async function getDmByUserId(otherUserId: string): Promise<Line> {
|
||||
|
||||
Reference in New Issue
Block a user