mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
fix(api): apply feedbacks
This commit is contained in:
parent
54e5a38661
commit
f9f764f3fe
@ -179,13 +179,13 @@ export class BlockRepository extends BaseRepository<
|
||||
): Promise<void> {
|
||||
for (const id of ids) {
|
||||
const oldState = await this.findOne(id);
|
||||
if (oldState?.category !== category) {
|
||||
const updatedNextBlocks = oldState?.nextBlocks?.filter((nextBlock) =>
|
||||
if (oldState && oldState.category !== category) {
|
||||
const updatedNextBlocks = oldState.nextBlocks?.filter((nextBlock) =>
|
||||
ids.includes(nextBlock),
|
||||
);
|
||||
|
||||
const updatedAttachedBlock = ids.includes(oldState?.attachedBlock || '')
|
||||
? oldState?.attachedBlock
|
||||
const updatedAttachedBlock = ids.includes(oldState.attachedBlock || '')
|
||||
? oldState.attachedBlock
|
||||
: null;
|
||||
|
||||
await this.updateOne(id, {
|
||||
@ -209,7 +209,7 @@ export class BlockRepository extends BaseRepository<
|
||||
ids: string[],
|
||||
): Promise<void> {
|
||||
for (const block of otherBlocks) {
|
||||
if (ids.includes(block.attachedBlock || '')) {
|
||||
if (block.attachedBlock && ids.includes(block.attachedBlock)) {
|
||||
await this.updateOne(block.id, { attachedBlock: null });
|
||||
}
|
||||
|
||||
|
||||
@ -240,7 +240,7 @@ export class BotService {
|
||||
event.getMessageType() === IncomingMessageType.message &&
|
||||
fallbackOptions.active &&
|
||||
convo.context?.attempt &&
|
||||
convo.context?.attempt < fallbackOptions.max_attempts
|
||||
convo.context.attempt < fallbackOptions.max_attempts
|
||||
) {
|
||||
// Trigger block fallback
|
||||
// NOTE : current is not populated, this may cause some anomaly
|
||||
|
||||
@ -59,7 +59,7 @@ export class MenuStub extends BaseSchema {
|
||||
@Schema({ timestamps: true })
|
||||
export class Menu extends MenuStub {
|
||||
@Transform(({ obj }) => obj.parent?.toString())
|
||||
parent?: string | undefined;
|
||||
parent?: string;
|
||||
}
|
||||
|
||||
@Schema({ timestamps: true })
|
||||
|
||||
@ -126,7 +126,9 @@ export class MenuService extends BaseService<Menu, MenuPopulate, MenuFull> {
|
||||
parent: string | symbol = this.RootSymbol,
|
||||
): MenuTree {
|
||||
const item = parents.get(parent);
|
||||
if (!item) return [];
|
||||
if (!item) {
|
||||
return [];
|
||||
}
|
||||
const children: MenuTree = item.map((menu) => {
|
||||
return {
|
||||
...menu,
|
||||
|
||||
6
api/src/utils/test/fixtures/menu.ts
vendored
6
api/src/utils/test/fixtures/menu.ts
vendored
@ -108,7 +108,7 @@ export const installMenuFixtures = async () => {
|
||||
const offerDocs = await Menu.insertMany(
|
||||
offersMenuFixtures.map((m) => ({
|
||||
...m,
|
||||
parent: m.parent && docs[parseInt(m.parent)].id,
|
||||
parent: m.parent ? docs[parseInt(m.parent)].id : undefined,
|
||||
})),
|
||||
);
|
||||
|
||||
@ -117,7 +117,7 @@ export const installMenuFixtures = async () => {
|
||||
await Menu.insertMany(
|
||||
devicesMenuFixtures.map((m) => ({
|
||||
...m,
|
||||
parent: m.parent && allDocs[parseInt(m.parent)].id,
|
||||
parent: m.parent ? allDocs[parseInt(m.parent)].id : undefined,
|
||||
})),
|
||||
);
|
||||
|
||||
@ -125,7 +125,7 @@ export const installMenuFixtures = async () => {
|
||||
accountMenuFixtures.map((m) => {
|
||||
return {
|
||||
...m,
|
||||
parent: m.parent && docs[parseInt(m.parent)].id,
|
||||
parent: m.parent ? docs[parseInt(m.parent)].id : undefined,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user