mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
fix(inbox): more UN display fixes
This commit is contained in:
@@ -355,7 +355,10 @@ export default {
|
||||
sendMessage (member) {
|
||||
this.$root.$emit('habitica::new-inbox-message', {
|
||||
userIdToMessage: member._id,
|
||||
userName: member.profile.name,
|
||||
displayName: member.profile.name,
|
||||
username: member.auth.local.username,
|
||||
backer: member.backer,
|
||||
contributor: member.contributor,
|
||||
});
|
||||
},
|
||||
async searchMembers (searchTerm = '') {
|
||||
|
||||
@@ -261,9 +261,11 @@ export default {
|
||||
}
|
||||
|
||||
this.initiatedConversation = {
|
||||
uuid: data.userIdToMessage,
|
||||
user: data.displayName,
|
||||
username: data.username,
|
||||
uuid: data.userIdToMessage,
|
||||
backer: data.backer,
|
||||
contributor: data.contributor,
|
||||
};
|
||||
|
||||
this.selectConversation(data.userIdToMessage);
|
||||
@@ -312,11 +314,13 @@ export default {
|
||||
// Add placeholder for new conversations
|
||||
if (this.initiatedConversation && this.initiatedConversation.uuid) {
|
||||
inboxGroup[this.initiatedConversation.uuid] = [{
|
||||
uuid: this.initiatedConversation.uuid,
|
||||
user: this.initiatedConversation.user,
|
||||
username: this.initiatedConversation.username, // ?
|
||||
backer: this.initiatedConversation.backer,
|
||||
contributor: this.initiatedConversation.contributor,
|
||||
id: '',
|
||||
text: '',
|
||||
user: this.initiatedConversation.user,
|
||||
username: this.initiatedConversation.username,
|
||||
uuid: this.initiatedConversation.uuid,
|
||||
timestamp: new Date(),
|
||||
}];
|
||||
}
|
||||
@@ -349,12 +353,14 @@ export default {
|
||||
const recentMessage = newChatModels[newChatModels.length - 1];
|
||||
if (!recentMessage.text) newChatModels.splice(newChatModels.length - 1, 1);
|
||||
|
||||
if (recentMessage.username === this.user.auth.local.username) recentMessage.username = null;
|
||||
|
||||
const convoModel = {
|
||||
backer: recentMessage.toUserBacker ? recentMessage.toUserBacker : recentMessage.backer,
|
||||
contributor: recentMessage.toUserContributor ? recentMessage.toUserContributor : recentMessage.contributor,
|
||||
key: recentMessage.toUUID ? recentMessage.toUUID : recentMessage.uuid,
|
||||
name: recentMessage.toUser ? recentMessage.toUser : recentMessage.user, // Handles case where from user sent the only message or the to user sent the only message
|
||||
username: recentMessage.toUserName ? recentMessage.toUserName : recentMessage.username,
|
||||
backer: recentMessage.toUserBacker ? recentMessage.toUserBacker : recentMessage.backer,
|
||||
contributor: recentMessage.toUserContributor ? recentMessage.toUserContributor : recentMessage.contributor,
|
||||
date: recentMessage.timestamp,
|
||||
lastMessageText: recentMessage.text,
|
||||
messages: newChatModels,
|
||||
@@ -426,9 +432,11 @@ export default {
|
||||
const messageIndex = this.messages.findIndex(msg => msg.id === message.id);
|
||||
if (messageIndex !== -1) this.messages.splice(messageIndex, 1);
|
||||
if (this.selectedConversationMessages.length === 0) this.initiatedConversation = {
|
||||
uuid: this.selectedConversation.key,
|
||||
user: this.selectedConversation.name,
|
||||
username: this.selectedConversation.username,
|
||||
uuid: this.selectedConversation.key,
|
||||
backer: this.selectedConversation.backer,
|
||||
contributor: this.selectedConversation.contributor,
|
||||
};
|
||||
},
|
||||
toggleClick () {
|
||||
@@ -491,11 +499,11 @@ export default {
|
||||
this.$root.$emit('bv::hide::modal', 'inbox-modal');
|
||||
},
|
||||
tierIcon (message) {
|
||||
if (!message.contributor) return;
|
||||
const isNPC = Boolean(message.backer && message.backer.npc);
|
||||
if (isNPC) {
|
||||
return this.icons.tierNPC;
|
||||
}
|
||||
if (!message.contributor) return;
|
||||
return this.icons[`tier${message.contributor.level}`];
|
||||
},
|
||||
},
|
||||
|
||||
@@ -472,6 +472,8 @@ export default {
|
||||
userIdToMessage: this.user._id,
|
||||
displayName: this.user.profile.name,
|
||||
username: this.user.auth.local.username,
|
||||
backer: this.user.backer,
|
||||
contributor: this.user.contributor,
|
||||
});
|
||||
},
|
||||
getProgressDisplay () {
|
||||
|
||||
@@ -109,7 +109,7 @@ api.getMember = {
|
||||
|
||||
if (!member) throw new NotFound(res.t('userWithIDNotFound', {userId: memberId}));
|
||||
|
||||
if (!member.flags.verifiedUsername) delete member.auth.local.username;
|
||||
if (!member.flags.verifiedUsername) member.auth.local.username = null;
|
||||
|
||||
// manually call toJSON with minimize: true so empty paths aren't returned
|
||||
let memberToJSON = member.toJSON({minimize: true});
|
||||
@@ -607,6 +607,7 @@ api.sendPrivateMessage = {
|
||||
const message = req.body.message;
|
||||
const receiver = await User.findById(req.body.toUserId).exec();
|
||||
if (!receiver) throw new NotFound(res.t('userNotFound'));
|
||||
if (!receiver.flags.verifiedUsername) delete receiver.auth.local.username;
|
||||
|
||||
const objections = sender.getObjectionsToInteraction('send-private-message', receiver);
|
||||
if (objections.length > 0 && !sender.isAdmin()) throw new NotAuthorized(res.t(objections[0]));
|
||||
|
||||
@@ -220,7 +220,7 @@ schema.statics.transformJSONUser = function transformJSONUser (jsonUser, addComp
|
||||
jsonUser.id = jsonUser._id;
|
||||
|
||||
// Remove username if not verified
|
||||
if (!jsonUser.flags.verifiedUsername) delete jsonUser.auth.local.username;
|
||||
if (!jsonUser.flags.verifiedUsername) jsonUser.auth.local.username = null;
|
||||
|
||||
if (addComputedStats) this.addComputedStatsToJSONObj(jsonUser.stats, jsonUser);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user