request full content when viewing feedback
All checks were successful
delpoy / build-and-deploy (push) Successful in 51s
All checks were successful
delpoy / build-and-deploy (push) Successful in 51s
This commit is contained in:
parent
1ea07f7666
commit
7ec1d8ab1d
@ -20,6 +20,7 @@
|
|||||||
limit?: number;
|
limit?: number;
|
||||||
from?: number;
|
from?: number;
|
||||||
hash?: string;
|
hash?: string;
|
||||||
|
preview?: boolean;
|
||||||
}): Promise<Feedback[]> {
|
}): Promise<Feedback[]> {
|
||||||
if (!browser) return [];
|
if (!browser) return [];
|
||||||
|
|
||||||
@ -27,6 +28,8 @@
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
...feedbackFilter,
|
...feedbackFilter,
|
||||||
|
preview: extendedFilter?.preview ?? true,
|
||||||
|
hash: extendedFilter?.hash ?? undefined,
|
||||||
limit: extendedFilter?.limit ?? feedbacksPerRequest,
|
limit: extendedFilter?.limit ?? feedbacksPerRequest,
|
||||||
from: extendedFilter?.from ?? feedbacks.length
|
from: extendedFilter?.from ?? feedbacks.length
|
||||||
})
|
})
|
||||||
@ -38,19 +41,14 @@
|
|||||||
if (!window.location.hash) return;
|
if (!window.location.hash) return;
|
||||||
|
|
||||||
const requestedHash = window.location.hash.substring(1);
|
const requestedHash = window.location.hash.substring(1);
|
||||||
let feedback = feedbacks.find((r) => r.url_hash === requestedHash);
|
|
||||||
if (!feedback) {
|
const hashFeedback = await fetchFeedback({ hash: requestedHash, preview: false });
|
||||||
const hashFeedback = (await fetchFeedback({ hash: requestedHash }))[0];
|
if (!hashFeedback) {
|
||||||
if (hashFeedback) {
|
await goto(window.location.href.split('#')[0], { replaceState: true });
|
||||||
feedback = [hashFeedback, ...feedback];
|
return;
|
||||||
feedback = hashFeedback;
|
|
||||||
} else {
|
|
||||||
await goto(window.location.href.split('#')[0], { replaceState: true });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
activeFeedback = feedback;
|
activeFeedback = hashFeedback[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
@ -84,11 +82,11 @@
|
|||||||
<tr
|
<tr
|
||||||
class="hover [&>*]:text-sm cursor-pointer"
|
class="hover [&>*]:text-sm cursor-pointer"
|
||||||
class:bg-base-200={activeFeedback?.url_hash === feedback.url_hash}
|
class:bg-base-200={activeFeedback?.url_hash === feedback.url_hash}
|
||||||
on:click={() => {
|
on:click={async () => {
|
||||||
goto(`${window.location.href.split('#')[0]}#${feedback.url_hash}`, {
|
await goto(`${window.location.href.split('#')[0]}#${feedback.url_hash}`, {
|
||||||
replaceState: true
|
replaceState: true
|
||||||
});
|
});
|
||||||
activeFeedback = feedback;
|
await openHashReport();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<td title={feedback.event}>{feedback.event}</td>
|
<td title={feedback.event}>{feedback.event}</td>
|
||||||
|
@ -33,19 +33,21 @@ export const POST = (async ({ request, cookies }) => {
|
|||||||
where: { username: { [Op.like]: `%${data.username}%` } }
|
where: { username: { [Op.like]: `%${data.username}%` } }
|
||||||
}).then((users) => users.map((user) => user.id))
|
}).then((users) => users.map((user) => user.id))
|
||||||
});
|
});
|
||||||
if (data.hash) Object.assign(feedbackFindOptions, { url_hash: data.hash, from: 0, limit: 1 });
|
if (data.hash) Object.assign(feedbackFindOptions, { url_hash: data.hash });
|
||||||
|
|
||||||
let feedback = await Feedback.findAll({
|
let feedback = await Feedback.findAll({
|
||||||
where: feedbackFindOptions,
|
where: feedbackFindOptions,
|
||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
attributes: {
|
attributes: data.preview
|
||||||
exclude: ['content'],
|
? {
|
||||||
include: [[sequelize.literal('SUBSTR(content, 1, 50)'), 'content']]
|
exclude: ['content'],
|
||||||
},
|
include: [[sequelize.literal('SUBSTR(content, 1, 50)'), 'content']]
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
include: { model: User, as: 'user' },
|
include: { model: User, as: 'user' },
|
||||||
offset: data.from || 0,
|
offset: data.hash ? 0 : data.from || 0,
|
||||||
limit: data.limit || 100
|
limit: data.hash ? 1 : data.limit || 100
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Response(JSON.stringify(feedback));
|
return new Response(JSON.stringify(feedback));
|
||||||
|
@ -9,5 +9,7 @@ export const FeedbackListSchema = z.object({
|
|||||||
|
|
||||||
hash: z.string().nullish(),
|
hash: z.string().nullish(),
|
||||||
|
|
||||||
username: z.string().nullish()
|
username: z.string().nullish(),
|
||||||
|
|
||||||
|
preview: z.boolean().nullish()
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user