Enhance readability
MODIFY
src/server/rest/v1/service/TagService.ts
src/server/rest/v1/service/TagService.ts
@@ -380,21 +380,22 @@ export default class TagService {
formerTagUserID = tag.userID;
formerTagDefault = tag.default;
}
+ if (filteredRequest.userID) {
// Clear User's default Tag
- if (filteredRequest.default && !formerTagUserID && filteredRequest.userID && (tag.default !== filteredRequest.default)) {
+ if (filteredRequest.default) {
await TagStorage.clearDefaultUserTag(req.tenant, filteredRequest.userID);
- }
// Check default Tag existence
- if (!filteredRequest.default && filteredRequest.userID) {
+ } else {
// Check if another one is the default
const defaultTag = await TagStorage.getDefaultUserTag(req.tenant, filteredRequest.userID, {
issuer: true,
});
// Force default Tag
- if (!defaultTag && filteredRequest.userID) {
+ if (!defaultTag) {
filteredRequest.default = true;
}
}
+ }
// Update
tag.visualID = filteredRequest.visualID;
tag.description = filteredRequest.description;

Enhance readability