Skip to content

Commit

Permalink
temp: patch livequery no object id bug
Browse files Browse the repository at this point in the history
  • Loading branch information
sdjdd committed Nov 16, 2023
1 parent c4b9a02 commit 0eca4a7
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions next/web/src/App/Admin/Tickets/Ticket/timeline-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ import { ReplySchema } from '@/api/reply';
import { fetchTicketReplies, fetchTicketOpsLogs, OpsLog } from '@/api/ticket';
import { useCurrentRef } from '@/utils/useCurrentRef';

function patchQueryDecoder(query: any) {
const decoder = query._decoder;
query._decoder = (app: any, data: any, className: string) => {
if (!data.objectId) {
data.objectId = '__objectId__';
}
return decoder(app, data, className);
};
}

export function useTicketReplies(ticketId?: string) {
const { data, fetchNextPage, refetch } = useInfiniteQuery({
queryKey: ['TicketReplies', ticketId],
Expand Down Expand Up @@ -49,8 +59,9 @@ export function useTicketReplies(ticketId?: string) {
return;
}
let mounted = true;
const subscription = db
.query('Reply')
const query = db.query('Reply');
patchQueryDecoder(query);
const subscription = query
.where('ticket', '==', db.class('Ticket').object(ticketId))
.subscribe();
subscription.then((s) => {
Expand Down Expand Up @@ -109,8 +120,9 @@ export function useTicketOpsLogs(ticketId?: string) {
return;
}
let mounted = true;
const subscription = db
.query('OpsLog')
const query = db.query('OpsLog');
patchQueryDecoder(query);
const subscription = query
.where('ticket', '==', db.class('Ticket').object(ticketId))
.subscribe();
subscription.then((s) => {
Expand Down

0 comments on commit 0eca4a7

Please sign in to comment.