Feature: Added avatar memo as for issue #595 (#613)

This commit is contained in:
KazaWai
2023-08-07 09:52:41 +02:00
committed by GitHub
parent 74a1353675
commit 8e4aa39064
9 changed files with 114 additions and 6 deletions

View File

@@ -7825,6 +7825,32 @@ speechSynthesis.getVoices();
}
};
// #endregion
// #region | App: Avatar Memos
$app.methods.getAvatarMemo = async function (avatarId) {
try {
return await database.getAvatarMemoDB(avatarId);
} catch (err) {console.error(err);}
return {
avatarId: '',
editedAt: '',
memo: ''
};
};
$app.methods.saveAvatarMemo = function (avatarId, memo) {
if (memo) {
database.setAvatarMemo({
avatarId,
editedAt: new Date().toJSON(),
memo
});
} else {
database.deleteAvatarMemo(avatarId);
}
};
// #endregion
// #region | App: Friends
@@ -17841,6 +17867,7 @@ speechSynthesis.getVoices();
visible: false,
loading: false,
id: '',
memo: '',
ref: {},
isFavorite: false,
isBlocked: false,
@@ -17854,6 +17881,20 @@ speechSynthesis.getVoices();
fileAnalysis: {}
};
$app.data.ignoreAvatarMemoSave = false;
$app.watch['avatarDialog.memo'] = function (value) {
if (this.ignoreAvatarMemoSave) {
this.ignoreAvatarMemoSave = false;
return;
}
var D = this.avatarDialog;
if (D.visible === false) {
return;
}
this.saveAvatarMemo(D.id, value == null ? D.memo : value);
};
API.$on('LOGOUT', function () {
$app.avatarDialog.visible = false;
});
@@ -17891,6 +17932,8 @@ speechSynthesis.getVoices();
D.isQuestFallback = false;
D.isFavorite = API.cachedFavoritesByObjectId.has(avatarId);
D.isBlocked = API.cachedAvatarModerations.has(avatarId);
this.ignoreAvatarMemoSave = true;
D.memo = '';
var ref2 = API.cachedAvatars.get(avatarId);
if (typeof ref2 !== 'undefined') {
D.ref = ref2;
@@ -17966,6 +18009,12 @@ speechSynthesis.getVoices();
.finally(() => {
D.loading = false;
});
this.getAvatarMemo(avatarId).then((memo) => {
if (D.id === memo.avatarId) {
this.ignoreAvatarMemoSave = true;
D.memo = memo.memo;
}
});
};
$app.methods.avatarDialogCommand = function (command) {