fix(usernames): various

Partial fixage for autocomplete @ing
Don't add username to chat message if user is unverified
Fix flying pets
Fix console error about avatar intro
This commit is contained in:
Sabe Jones
2018-11-06 19:55:06 -06:00
parent 2dadd74097
commit 38efe83cc7
5 changed files with 8 additions and 12 deletions

View File

@@ -48,6 +48,7 @@
.avatar {
width: 140px;
height: 147px;
image-rendering: pixelated;
position: relative;
cursor: pointer;

View File

@@ -68,7 +68,7 @@ export default {
props: ['selections', 'text', 'caretPosition', 'coords', 'chat', 'textbox'],
data () {
return {
atRegex: new RegExp(/@[\w-]+$/),
atRegex: /(?!\b)@[\w-]*$/,
currentSearch: '',
searchActive: false,
searchEscaped: false,
@@ -134,7 +134,6 @@ export default {
return;
}
if (newText[newText.length - 1] === '@') {
this.searchActive = false;
this.searchEscaped = false;
}
if (this.searchEscaped) return;
@@ -142,7 +141,6 @@ export default {
if (!this.atRegex.test(newText)) return;
this.searchActive = true;
this.currentSearchPosition = newText.lastIndexOf('@', this.caretPosition);
},
chat () {
this.resetDefaults();
@@ -153,10 +151,8 @@ export default {
resetDefaults () {
// Mounted is not called when switching between group pages because they have the
// the same parent component. So, reset the data
this.currentSearch = '';
this.searchActive = false;
this.searchEscaped = false;
this.currentSearchPosition = 0;
this.tmpSelections = [];
},
grabUserNames () {
@@ -189,13 +185,12 @@ export default {
return this.icons[`tier${message.contributor.level}`];
},
select (result) {
let newText = this.text.slice(0, this.currentSearchPosition + 1);
let newText = this.text;
if (result.username) {
newText = newText.concat(result.username);
newText = `${newText}${result.username} `;
} else {
newText = newText.concat(result.displayName);
newText = `${newText}${result.displayName} `;
}
this.searchActive = false;
this.$emit('select', newText);
},
handleEsc (e) {

View File

@@ -292,7 +292,7 @@ export default {
this.$emit('show-member-modal', memberId);
},
atHighlight (text) {
return text.replace(new RegExp(/@[\w-]+/g), match => {
return text.replace(new RegExp(/(?!\b)@[\w-]+/g), match => {
return `<span class="at-highlight">${match}</span>`;
});
},

View File

@@ -373,7 +373,7 @@ b-modal#avatar-modal(title="", :size='editing ? "lg" : "md"', :hide-header='true
p(v-once) {{ $t('justinIntroMessage3') }}
.npc-justin-textbox
.section.mr-5.ml-5(v-if='modalPage === 1')
username-form(@usernameConfirmed='modalPage += 1', :avatarIntro='"true"')
username-form(@usernameConfirmed='modalPage += 1', :avatarIntro='true')
.small.text-center(v-html="$t('usernameTOSRequirements')")
.section.container.footer

View File

@@ -118,7 +118,7 @@ export function messageDefaults (msg, user) {
contributor: user.contributor && user.contributor.toObject(),
backer: user.backer && user.backer.toObject(),
user: user.profile.name,
username: user.auth && user.auth.local && user.auth.local.username,
username: user.flags.verifiedUsername && user.auth && user.auth.local && user.auth.local.username,
});
} else {
message.uuid = 'system';