World memos

This commit is contained in:
Natsumi
2023-06-25 01:01:37 +12:00
parent 62e350cc91
commit b2942e5981
4 changed files with 100 additions and 0 deletions

View File

@@ -7721,6 +7721,9 @@ speechSynthesis.getVoices();
}
};
// #endregion
// #region | User Memos
$app.methods.migrateMemos = async function () {
var json = JSON.parse(await VRCXStorage.GetAll());
database.begin();
@@ -7785,6 +7788,32 @@ speechSynthesis.getVoices();
});
};
// #endregion
// #region | World Memos
$app.methods.getWorldMemo = async function (worldId) {
try {
return await database.getWorldMemo(worldId);
} catch (err) {}
return {
worldId: '',
editedAt: '',
memo: ''
};
};
$app.methods.saveWorldMemo = function (worldId, memo) {
if (memo) {
database.setWorldMemo({
worldId,
editedAt: new Date().toJSON(),
memo
});
} else {
database.deleteWorldMemo(worldId);
}
};
// #endregion
// #region | App: Friends
@@ -16942,6 +16971,7 @@ speechSynthesis.getVoices();
visible: false,
loading: false,
id: '',
memo: '',
$location: {},
ref: {},
isFavorite: false,
@@ -16961,6 +16991,17 @@ speechSynthesis.getVoices();
isIos: false
};
$app.data.ignoreWorldMemoSave = false;
$app.watch['worldDialog.memo'] = function () {
if (this.ignoreWorldMemoSave) {
this.ignoreWorldMemoSave = false;
return;
}
var D = this.worldDialog;
this.saveWorldMemo(D.id, D.memo);
};
API.$on('LOGOUT', function () {
$app.worldDialog.visible = false;
});
@@ -17082,11 +17123,19 @@ speechSynthesis.getVoices();
D.isPC = false;
D.isQuest = false;
D.isIos = false;
this.ignoreWorldMemoSave = true;
D.memo = '';
var LL = API.parseLocation(this.lastLocation.location);
var currentWorldMatch = false;
if (LL.worldId === D.id) {
currentWorldMatch = true;
}
this.getWorldMemo(D.id).then((memo) => {
if (memo.worldId === D.id) {
this.ignoreWorldMemoSave = true;
D.memo = memo.memo;
}
});
database.getLastVisit(D.id, currentWorldMatch).then((ref) => {
if (ref.worldId === D.id) {
D.lastVisit = ref.created_at;