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
+32 -17
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,11 +7534,13 @@ 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.$nickName = ''; ctx.memo = memo.memo;
if (memo) { ctx.$nickName = '';
var array = memo.split('\n'); if (memo.memo) {
ctx.$nickName = array[0]; var array = memo.memo.split('\n');
ctx.$nickName = array[0];
}
} }
}); });
} }
@@ -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,19 +14970,23 @@ 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) {
var ref = this.friends.get(userId); this.ignoreUserMemoSave = true;
if (ref) { D.memo = memo.memo;
ref.memo = String(memo || ''); var ref = this.friends.get(userId);
if (memo) { if (ref) {
var array = memo.split('\n'); ref.memo = String(memo.memo || '');
ref.$nickName = array[0]; if (memo.memo) {
} else { var array = memo.memo.split('\n');
ref.$nickName = ''; ref.$nickName = array[0];
} else {
ref.$nickName = '';
}
} }
} }
}); });
+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",