Skip to content

Commit

Permalink
fix: error by duplicate tag id in add tags
Browse files Browse the repository at this point in the history
  • Loading branch information
lastsunday committed Dec 20, 2024
1 parent 053f402 commit b77a1b2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions entrypoints/offscreen/service/tagService.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,18 @@ export async function _batchGetTagByIds(ids) {
* @param {string[]} tags
*/
export async function _addNotExistsTags(tags) {
//对tags进行去重处理
const uniqueTags = Array.from(new Set(tags));
const tagIds = [];
for (let i = 0; i < tags.length; i++) {
let tagName = tags[i];
for (let i = 0; i < uniqueTags.length; i++) {
let tagName = uniqueTags[i];
let id = genIdFromText(tagName);
tagIds.push(id);
}
const existsTags = await _batchGetTagByIds(tagIds);
const existsTagIds = existsTags.map(item => item.tagId);
for (let i = 0; i < tags.length; i++) {
let tagName = tags[i];
for (let i = 0; i < uniqueTags.length; i++) {
let tagName = uniqueTags[i];
let id = genIdFromText(tagName);
if (!existsTagIds.includes(id)) {
let tag = new Tag();
Expand Down

0 comments on commit b77a1b2

Please sign in to comment.