FIX: Update user options only once (#19066)

* FIX: Update user options only once

Performing actions that updated list of seen popups used to update user
options everytime instead of checking if the change has any effect.

* FIX: Load updated user data from response
This commit is contained in:
Bianca Nenciu 2022-11-17 00:12:54 +02:00 committed by GitHub
parent a2e5c43683
commit 35980ad56e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 9 deletions

View File

@ -611,7 +611,7 @@ export default Controller.extend(bufferedProperty("model"), {
// Post related methods
replyToPost(post) {
if (this.currentUser) {
if (this.currentUser && this.siteSettings.enable_user_tips) {
this.currentUser.hideUserTipForever("post_menu");
}

View File

@ -449,11 +449,13 @@ const User = RestModel.extend({
.then((result) => {
this.set("bio_excerpt", result.user.bio_excerpt);
const userProps = getProperties(
this.user_option,
result.user.user_option || this.user_option,
"enable_quoting",
"enable_defer",
"external_links_in_new_tab",
"dynamic_favicon"
"dynamic_favicon",
"seen_popups",
"skip_new_user_tips"
);
User.current()?.setProperties(userProps);
this.setProperties(updatedState);
@ -1171,11 +1173,17 @@ const User = RestModel.extend({
// Hide any shown user tips.
let seenUserTips = this.seen_popups || [];
if (userTipId) {
hideUserTip(userTipId);
if (!seenUserTips.includes(userTips[userTipId])) {
seenUserTips.push(userTips[userTipId]);
if (seenUserTips.includes(userTips[userTipId])) {
return;
}
hideUserTip(userTipId);
seenUserTips.push(userTips[userTipId]);
} else {
if (seenUserTips.includes(-1)) {
return;
}
hideAllUserTips();
seenUserTips = [-1];
}

View File

@ -711,7 +711,7 @@ export default createWidget("post-menu", {
},
showMoreActions() {
if (this.currentUser) {
if (this.currentUser && this.siteSettings.enable_user_tips) {
this.currentUser.hideUserTipForever("post_menu");
}
@ -734,7 +734,9 @@ export default createWidget("post-menu", {
keyValueStore &&
keyValueStore.set({ key: "likedPostId", value: attrs.id });
return this.sendWidgetAction("showLogin");
} else {
}
if (this.currentUser && this.siteSettings.enable_user_tips) {
this.currentUser.hideUserTipForever("post_menu");
}

View File

@ -594,7 +594,7 @@ createWidget("post-contents", {
},
share() {
if (this.currentUser) {
if (this.currentUser && this.siteSettings.enable_user_tips) {
this.currentUser.hideUserTipForever("post_menu");
}