Fix random memos being nuked when opening user dialog

This commit is contained in:
Natsumi
2023-04-22 06:42:25 +12:00
parent e1d3a1d412
commit 47e1047220
3 changed files with 35 additions and 17 deletions
+25 -10
View File
@@ -7280,10 +7280,13 @@ speechSynthesis.getVoices();
$app.methods.getMemo = async function (userId) { $app.methods.getMemo = async function (userId) {
try { try {
var row = await database.getMemo(userId); return await database.getMemo(userId);
return row.memo;
} catch (err) {} } catch (err) {}
return ''; return {
userId: '',
editedAt: '',
memo: ''
};
}; };
$app.methods.saveMemo = function (id, memo) { $app.methods.saveMemo = function (id, memo) {
@@ -7531,12 +7534,14 @@ speechSynthesis.getVoices();
}; };
if (this.friendLogInitStatus) { if (this.friendLogInitStatus) {
this.getMemo(id).then((memo) => { this.getMemo(id).then((memo) => {
ctx.memo = memo; if (memo.userId === id) {
ctx.memo = memo.memo;
ctx.$nickName = ''; ctx.$nickName = '';
if (memo) { if (memo.memo) {
var array = memo.split('\n'); var array = memo.memo.split('\n');
ctx.$nickName = array[0]; ctx.$nickName = array[0];
} }
}
}); });
} }
if (typeof ref === 'undefined') { if (typeof ref === 'undefined') {
@@ -14764,7 +14769,13 @@ speechSynthesis.getVoices();
unFriended: false unFriended: false
}; };
$app.data.ignoreUserMemoSave = false;
$app.watch['userDialog.memo'] = function () { $app.watch['userDialog.memo'] = function () {
if (this.ignoreUserMemoSave) {
this.ignoreUserMemoSave = false;
return;
}
var D = this.userDialog; var D = this.userDialog;
this.saveMemo(D.id, D.memo); this.saveMemo(D.id, D.memo);
}; };
@@ -14959,21 +14970,25 @@ speechSynthesis.getVoices();
var D = this.userDialog; var D = this.userDialog;
D.id = userId; D.id = userId;
D.treeData = []; D.treeData = [];
this.ignoreUserMemoSave = true;
D.memo = ''; D.memo = '';
D.note = ''; D.note = '';
D.noteSaving = false; D.noteSaving = false;
this.getMemo(userId).then((memo) => { this.getMemo(userId).then((memo) => {
D.memo = memo; if (memo.userId === userId) {
this.ignoreUserMemoSave = true;
D.memo = memo.memo;
var ref = this.friends.get(userId); var ref = this.friends.get(userId);
if (ref) { if (ref) {
ref.memo = String(memo || ''); ref.memo = String(memo.memo || '');
if (memo) { if (memo.memo) {
var array = memo.split('\n'); var array = memo.memo.split('\n');
ref.$nickName = array[0]; ref.$nickName = array[0];
} else { } else {
ref.$nickName = ''; ref.$nickName = '';
} }
} }
}
}); });
D.visible = true; D.visible = true;
D.loading = true; D.loading = true;
+2
View File
@@ -1525,6 +1525,8 @@ html
span.name {{ $t('view.settings.advanced.advanced.cache_debug.world_cache') }} #[span(v-text="API.cachedWorlds.size")] span.name {{ $t('view.settings.advanced.advanced.cache_debug.world_cache') }} #[span(v-text="API.cachedWorlds.size")]
div.options-container-item div.options-container-item
span.name {{ $t('view.settings.advanced.advanced.cache_debug.avatar_cache') }} #[span(v-text="API.cachedAvatars.size")] span.name {{ $t('view.settings.advanced.advanced.cache_debug.avatar_cache') }} #[span(v-text="API.cachedAvatars.size")]
div.options-container-item
span.name {{ $t('view.settings.advanced.advanced.cache_debug.group_cache') }} #[span(v-text="API.cachedGroups.size")]
div.options-container-item div.options-container-item
span.name {{ $t('view.settings.advanced.advanced.cache_debug.avatar_name_cache') }} #[span(v-text="API.cachedAvatarNames.size")] span.name {{ $t('view.settings.advanced.advanced.cache_debug.avatar_name_cache') }} #[span(v-text="API.cachedAvatarNames.size")]
div.options-container-item div.options-container-item
+1
View File
@@ -406,6 +406,7 @@
"user_cache": "User cache:", "user_cache": "User cache:",
"world_cache": "World cache:", "world_cache": "World cache:",
"avatar_cache": "Avatar cache:", "avatar_cache": "Avatar cache:",
"group_cache": "Group cache:",
"avatar_name_cache": "Avatar Name cache:", "avatar_name_cache": "Avatar Name cache:",
"clear_cache": "Clear Cache", "clear_cache": "Clear Cache",
"auto_clear_cache": "Auto Clear Cache", "auto_clear_cache": "Auto Clear Cache",