User dialog notes

This commit is contained in:
Natsumi
2022-09-17 02:28:55 +12:00
parent 03faa57128
commit 56f7b57344
2 changed files with 109 additions and 10 deletions
+87
View File
@@ -7328,6 +7328,9 @@ speechSynthesis.getVoices();
if (!match && ctx.memo) { if (!match && ctx.memo) {
match = String(ctx.memo).toUpperCase().includes(QUERY); match = String(ctx.memo).toUpperCase().includes(QUERY);
} }
if (!match && ctx.ref.note) {
match = String(ctx.ref.note).toUpperCase().includes(QUERY);
}
if (match) { if (match) {
results.push({ results.push({
value: ctx.id, value: ctx.id,
@@ -11731,6 +11734,8 @@ speechSynthesis.getVoices();
$app.data.randomUserColours = configRepository.getBool( $app.data.randomUserColours = configRepository.getBool(
'VRCX_randomUserColours' 'VRCX_randomUserColours'
); );
$app.data.hideUserNotes = configRepository.getBool('VRCX_hideUserNotes');
$app.data.hideUserMemos = configRepository.getBool('VRCX_hideUserMemos');
$app.methods.saveOpenVROption = function () { $app.methods.saveOpenVROption = function () {
configRepository.setBool('openVR', this.openVR); configRepository.setBool('openVR', this.openVR);
configRepository.setBool('openVRAlways', this.openVRAlways); configRepository.setBool('openVRAlways', this.openVRAlways);
@@ -11796,6 +11801,10 @@ speechSynthesis.getVoices();
this.updateVRLastLocation(); this.updateVRLastLocation();
AppApi.ExecuteVrOverlayFunction('notyClear', ''); AppApi.ExecuteVrOverlayFunction('notyClear', '');
}; };
$app.methods.saveUserDialogOption = function () {
configRepository.setBool('VRCX_hideUserNotes', this.hideUserNotes);
configRepository.setBool('VRCX_hideUserMemos', this.hideUserMemos);
};
$app.data.TTSvoices = speechSynthesis.getVoices(); $app.data.TTSvoices = speechSynthesis.getVoices();
$app.methods.saveNotificationTTS = function () { $app.methods.saveNotificationTTS = function () {
speechSynthesis.cancel(); speechSynthesis.cancel();
@@ -12976,6 +12985,8 @@ speechSynthesis.getVoices();
ref: {}, ref: {},
friend: {}, friend: {},
isFriend: false, isFriend: false,
note: '',
noteSaving: false,
incomingRequest: false, incomingRequest: false,
outgoingRequest: false, outgoingRequest: false,
isBlock: false, isBlock: false,
@@ -13039,6 +13050,8 @@ speechSynthesis.getVoices();
return; return;
} }
D.ref = ref; D.ref = ref;
D.note = String(ref.note || '');
D.noteSaving = false;
D.incomingRequest = false; D.incomingRequest = false;
D.outgoingRequest = false; D.outgoingRequest = false;
if (D.ref.friendRequestStatus === 'incoming') { if (D.ref.friendRequestStatus === 'incoming') {
@@ -13210,6 +13223,8 @@ speechSynthesis.getVoices();
D.id = userId; D.id = userId;
D.treeData = []; D.treeData = [];
D.memo = ''; D.memo = '';
D.note = '';
D.noteSaving = false;
this.getMemo(userId).then((memo) => { this.getMemo(userId).then((memo) => {
D.memo = memo; D.memo = memo;
var ref = this.friends.get(userId); var ref = this.friends.get(userId);
@@ -13263,6 +13278,7 @@ speechSynthesis.getVoices();
D.ref = args.ref; D.ref = args.ref;
D.friend = this.friends.get(D.id); D.friend = this.friends.get(D.id);
D.isFriend = Boolean(D.friend); D.isFriend = Boolean(D.friend);
D.note = String(D.ref.note || '');
D.incomingRequest = false; D.incomingRequest = false;
D.outgoingRequest = false; D.outgoingRequest = false;
D.isBlock = false; D.isBlock = false;
@@ -20177,6 +20193,77 @@ speechSynthesis.getVoices();
this.updateWorldExportDialog(); this.updateWorldExportDialog();
}; };
// App: user dialog notes
API.saveNote = function (params) {
return this.call('userNotes', {
method: 'POST',
params
}).then((json) => {
var args = {
json,
params
};
this.$emit('NOTE', args);
return args;
});
};
API.$on('NOTE', function (args) {
var note = '';
var targetUserId = '';
if (typeof args.json !== 'undefined') {
note = args.json.note;
}
if (typeof args.params !== 'undefined') {
targetUserId = args.params.targetUserId;
}
if (targetUserId === $app.userDialog.id) {
if (note === args.params.note) {
$app.userDialog.noteSaving = false;
$app.userDialog.note = note;
} else {
// response is cached sadge :<
this.getUser({userId: targetUserId});
}
}
var ref = API.cachedUsers.get(targetUserId);
if (typeof ref !== 'undefined') {
ref.note = note;
}
});
$app.methods.checkNote = function (ref, note) {
if (ref.note !== note) {
this.addNote(ref.id, note);
}
};
$app.methods.cleanNote = function (note) {
// remove newlines because they aren't supported
$app.userDialog.note = note.replace(/[\r\n]/g, '');
};
$app.methods.addNote = function (userId, note) {
if (this.userDialog.id === userId) {
this.userDialog.noteSaving = true;
}
return API.saveNote({
targetUserId: userId,
note
});
};
$app.methods.deleteNote = function (userId) {
if (this.userDialog.id === userId) {
this.userDialog.noteSaving = true;
}
return API.saveNote({
targetUserId: userId,
note: ''
});
};
$app = new Vue($app); $app = new Vue($app);
window.$app = $app; window.$app = $app;
})(); })();
+22 -10
View File
@@ -1068,6 +1068,14 @@ html
span.sub-header Width span.sub-header Width
div.options-container-item div.options-container-item
el-slider(v-model="asideWidth" @input="setAsideWidth" :show-tooltip="false" :marks="{236: ''}" :min="141" :max="500" style="width:300px") el-slider(v-model="asideWidth" @input="setAsideWidth" :show-tooltip="false" :marks="{236: ''}" :min="141" :max="500" style="width:300px")
div.options-container
span.header User Dialog
div.options-container-item
span.name Hide VRChat Notes
el-switch(v-model="hideUserNotes" @change="saveUserDialogOption")
div.options-container-item
span.name Hide VRCX Memos
el-switch(v-model="hideUserMemos" @change="saveUserDialogOption")
div.options-container div.options-container
span.header User Colours span.header User Colours
div.options-container-item div.options-container-item
@@ -1385,7 +1393,7 @@ html
.avatar(:class="userStatusClass(friend.ref, friend.pendingOffline)") .avatar(:class="userStatusClass(friend.ref, friend.pendingOffline)")
img(v-lazy="userImage(friend.ref)") img(v-lazy="userImage(friend.ref)")
.detail .detail
span.name(v-if="friend.$nickName" :style="{'color':friend.ref.$userColour}") {{ friend.ref.displayName }} ({{ friend.$nickName }}) span.name(v-if="!hideUserMemos && friend.$nickName" :style="{'color':friend.ref.$userColour}") {{ friend.ref.displayName }} ({{ friend.$nickName }})
span.name(v-else v-text="friend.ref.displayName" :style="{'color':friend.ref.$userColour}") span.name(v-else v-text="friend.ref.displayName" :style="{'color':friend.ref.$userColour}")
span.extra(v-if="friend.pendingOffline") #[i.el-icon-warning-outline] Pending Offline span.extra(v-if="friend.pendingOffline") #[i.el-icon-warning-outline] Pending Offline
location.extra(v-else :location="friend.ref.location" :traveling="friend.ref.travelingToLocation" :link="false") location.extra(v-else :location="friend.ref.location" :traveling="friend.ref.travelingToLocation" :link="false")
@@ -1401,7 +1409,7 @@ html
.avatar(:class="userStatusClass(friend.ref, friend.pendingOffline)") .avatar(:class="userStatusClass(friend.ref, friend.pendingOffline)")
img(v-lazy="userImage(friend.ref)") img(v-lazy="userImage(friend.ref)")
.detail .detail
span.name(v-if="friend.$nickName" :style="{'color':friend.ref.$userColour}") {{ friend.ref.displayName }} ({{ friend.$nickName }}) span.name(v-if="!hideUserMemos && friend.$nickName" :style="{'color':friend.ref.$userColour}") {{ friend.ref.displayName }} ({{ friend.$nickName }})
span.name(v-else v-text="friend.ref.displayName" :style="{'color':friend.ref.$userColour}") span.name(v-else v-text="friend.ref.displayName" :style="{'color':friend.ref.$userColour}")
span.extra(v-if="friend.pendingOffline") #[i.el-icon-warning-outline] Pending Offline span.extra(v-if="friend.pendingOffline") #[i.el-icon-warning-outline] Pending Offline
location.extra(v-else :location="friend.ref.location" :traveling="friend.ref.travelingToLocation" :link="false") location.extra(v-else :location="friend.ref.location" :traveling="friend.ref.travelingToLocation" :link="false")
@@ -1417,7 +1425,7 @@ html
.avatar .avatar
img(v-lazy="userImage(friend.ref)") img(v-lazy="userImage(friend.ref)")
.detail .detail
span.name(v-if="friend.$nickName" :style="{'color':friend.ref.$userColour}") {{ friend.ref.displayName }} ({{ friend.$nickName }}) span.name(v-if="!hideUserMemos && friend.$nickName" :style="{'color':friend.ref.$userColour}") {{ friend.ref.displayName }} ({{ friend.$nickName }})
span.name(v-else v-text="friend.ref.displayName" :style="{'color':friend.ref.$userColour}") span.name(v-else v-text="friend.ref.displayName" :style="{'color':friend.ref.$userColour}")
span.extra(v-text="friend.ref.statusDescription" :link="false") span.extra(v-text="friend.ref.statusDescription" :link="false")
template(v-else) template(v-else)
@@ -1432,7 +1440,7 @@ html
.avatar .avatar
img(v-lazy="userImage(friend.ref)") img(v-lazy="userImage(friend.ref)")
.detail .detail
span.name(v-if="friend.$nickName" :style="{'color':friend.ref.$userColour}") {{ friend.ref.displayName }} ({{ friend.$nickName }}) span.name(v-if="!hideUserMemos && friend.$nickName" :style="{'color':friend.ref.$userColour}") {{ friend.ref.displayName }} ({{ friend.$nickName }})
span.name(v-else v-text="friend.ref.displayName" :style="{'color':friend.ref.$userColour}") span.name(v-else v-text="friend.ref.displayName" :style="{'color':friend.ref.$userColour}")
span.extra(v-text="friend.ref.statusDescription") span.extra(v-text="friend.ref.statusDescription")
template(v-else) template(v-else)
@@ -1569,14 +1577,18 @@ html
span.extra(v-else) span.extra(v-else)
timer(:epoch="user.$location_at") timer(:epoch="user.$location_at")
.x-friend-list(style="max-height:none") .x-friend-list(style="max-height:none")
//- .x-friend-item(v-if="userDialog.id !== API.currentUser.id" style="width:100%;cursor:default") .x-friend-item(v-if="!hideUserNotes" style="width:100%;cursor:default")
//- .detail
//- span.name Note
//- span.extra(v-text="userDialog.ref.note")
.x-friend-item(style="width:100%;cursor:default")
.detail .detail
span.name Note span.name Note
el-input.extra(v-model="userDialog.memo" type="textarea" :rows="2" :autosize="{ minRows: 1, maxRows: 20 }" placeholder="Click to add a note" size="mini" resize="none") el-input(v-model="userDialog.note" type="textarea" maxlength="256" show-word-limit :rows="2" :autosize="{ minRows: 1, maxRows: 20 }" @change="checkNote(userDialog.ref, userDialog.note)" @input="cleanNote(userDialog.note)" placeholder="Click to add a note" size="mini" resize="none")
div(style="float:right")
i.el-icon-loading(v-if="userDialog.noteSaving" style="margin-left:5px")
i.el-icon-more-outline(v-else-if="userDialog.note !== userDialog.ref.note" style="margin-left:5px")
el-button(v-if="userDialog.note" type="text" icon="el-icon-delete" size="mini" @click="deleteNote(userDialog.id)" style="margin-left:5px")
.x-friend-item(v-if="!hideUserMemos" style="width:100%;cursor:default")
.detail
span.name Memo
el-input.extra(v-model="userDialog.memo" type="textarea" :rows="2" :autosize="{ minRows: 1, maxRows: 20 }" placeholder="Click to add a memo" size="mini" resize="none")
.x-friend-item(style="width:100%;cursor:default") .x-friend-item(style="width:100%;cursor:default")
.detail .detail
span.name(v-if="userDialog.id !== API.currentUser.id && userDialog.ref.profilePicOverride && userDialog.ref.currentAvatarImageUrl") Avatar Info Last Seen span.name(v-if="userDialog.id !== API.currentUser.id && userDialog.ref.profilePicOverride && userDialog.ref.currentAvatarImageUrl") Avatar Info Last Seen