Skip to content

Commit

Permalink
format fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RiXelanya committed Nov 15, 2023
1 parent 107fa8f commit 9b63b4c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/controllers/user/experience.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ export class UserExperienceController {
experience: Partial<Experience>,
@param.array('editors', 'query', {type: 'string'}) editors?: string[],
): Promise<Count> {
return this.userService.updateExperience(id, experience,editors);
return this.userService.updateExperience(id, experience, editors);
}
}
26 changes: 14 additions & 12 deletions src/services/post.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -753,22 +753,24 @@ export class PostService {
createdBy: userId,
},
});
const editable = this.experienceEditorRepository.find({
where: {
experienceId: {inq: timelineIds},
userId,
},
}).then(res => {
const query = res.map(res => res.userId)
return this.experienceRepository.find({
const editable = this.experienceEditorRepository
.find({
where: {
id: {inq: query},
experienceId: {inq: timelineIds},
userId,
},
})
.then(res => {
const query = res.map(res => res.userId);

Check failure on line 764 in src/services/post.service.ts

View workflow job for this annotation

GitHub Actions / Test on Node.js 16 ( lint:check )

'res' is already declared in the upper scope on line 763 column 13
return this.experienceRepository.find({
where: {
id: {inq: query},
},
});
});
const timelines = await Promise.all([timeline, editable]).then(res => {
return [...res[0], ...res[1]];
});
const timelines = await Promise.all([timeline,editable]).then(res => {
return [...res[0],...res[1]]
})

if (timelines.length <= 0) {
throw new HttpErrors.UnprocessableEntity('TimelineNotFound');
Expand Down
51 changes: 27 additions & 24 deletions src/services/user-experience.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,23 +257,20 @@ export class UserExperienceService {

if (editors) {
if (editors.includes(userId)) {
jobs.push(this.experienceRepository.editors(id).unlinkAll())
}
else {
await this.experienceRepository.editors(id).unlinkAll();
editors.map(editor => {
const link = this.experienceRepository
.editors(id)
.link(editor);
const creation = this.userExperienceRepository.create({
userId: editor,
experienceId: id,
jobs.push(this.experienceRepository.editors(id).unlinkAll());
} else {
await this.experienceRepository.editors(id).unlinkAll();
editors.map(editor => {
const link = this.experienceRepository.editors(id).link(editor);
const creation = this.userExperienceRepository.create({
userId: editor,
experienceId: id,
});
jobs.push(link);
jobs.push(creation);
return editor;
});
jobs.push(link);
jobs.push(creation);
return editor;
});
}
}
}

Promise.all(jobs) as Promise<AnyObject>;
Expand Down Expand Up @@ -332,16 +329,22 @@ export class UserExperienceService {
const promises: Promise<void | AnyObject>[] = [];

if (experience) {
const editors = await this.experienceRepository.editors(experience.id).find({
where: {
id: userId
}
})
const editors = await this.experienceRepository
.editors(experience.id)
.find({
where: {
id: userId,
},
});
if (editors) {
editors.map(editor => {
promises.push(this.experienceRepository.editors(experience.id).unlink(editor.id));
return editor
})
promises.push(
this.experienceRepository
.editors(experience.id)
.unlink(editor.id),
);
return editor;
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ export class UserService {
): Promise<Count> {
experience.createdBy = this.currentUser[securityId];

return this.userExperienceService.update(id, experience,editors);
return this.userExperienceService.update(id, experience, editors);
}

public async unsubscribeExperience(id: string): Promise<void> {
Expand Down

0 comments on commit 9b63b4c

Please sign in to comment.