[什么值得买] 修复不能正常取消收藏文章的问题

This commit is contained in:
blackmatrix7 2022-10-12 09:42:10 +08:00
parent 79862c473d
commit 5a88a2b13a

View File

@ -374,10 +374,10 @@ function clickFavArticle(articleId) {
.then((resp) => { .then((resp) => {
const obj = resp.body; const obj = resp.body;
if (obj.error_code == 0) { if (obj.error_code == 0) {
$.logger.debug(`好文${articleId}收藏成功`); $.logger.info(`好文${articleId}收藏成功`);
resolve(true); resolve(true);
} else if (obj.error_code == 2) { } else if (obj.error_code == 2) {
$.logger.debug(`好文${articleId}取消收藏成功`); $.logger.info(`好文${articleId}取消收藏成功`);
resolve(true); resolve(true);
} else { } else {
$.logger.error(`好文${articleId}收藏失败,${JSON.stringify(obj)}`); $.logger.error(`好文${articleId}收藏失败,${JSON.stringify(obj)}`);
@ -425,7 +425,7 @@ function favArticles() {
}); });
let favArticlesId = articlesId.splice(0, clickFavArticleMaxTimes); let favArticlesId = articlesId.splice(0, clickFavArticleMaxTimes);
if (favArticlesId.length > 0) { if (favArticlesId.length > 0) {
// 加入收藏 // 加入收藏与取消收藏
for (let articleId of favArticlesId) { for (let articleId of favArticlesId) {
await $.utils await $.utils
.retry( .retry(
@ -441,10 +441,7 @@ function favArticles() {
.catch((err) => { .catch((err) => {
$.logger.error(`文章加入收藏失败,${err}`); $.logger.error(`文章加入收藏失败,${err}`);
}); });
await $.utils.sleep(500); await $.utils.sleep(1000);
}
// 取消收藏
for (let articleId of articlesId) {
await $.utils await $.utils
.retry( .retry(
clickFavArticle, clickFavArticle,
@ -454,6 +451,7 @@ function favArticles() {
.catch((err) => { .catch((err) => {
$.logger.error(`文章取消收藏失败,${err}`); $.logger.error(`文章取消收藏失败,${err}`);
}); });
await $.utils.sleep(1000);
} }
} }
resolve(success); resolve(success);