mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 14:53:50 +02:00
World memos
This commit is contained in:
@@ -7721,6 +7721,9 @@ speechSynthesis.getVoices();
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// #endregion
|
||||||
|
// #region | User Memos
|
||||||
|
|
||||||
$app.methods.migrateMemos = async function () {
|
$app.methods.migrateMemos = async function () {
|
||||||
var json = JSON.parse(await VRCXStorage.GetAll());
|
var json = JSON.parse(await VRCXStorage.GetAll());
|
||||||
database.begin();
|
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
|
// #endregion
|
||||||
// #region | App: Friends
|
// #region | App: Friends
|
||||||
|
|
||||||
@@ -16942,6 +16971,7 @@ speechSynthesis.getVoices();
|
|||||||
visible: false,
|
visible: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
id: '',
|
id: '',
|
||||||
|
memo: '',
|
||||||
$location: {},
|
$location: {},
|
||||||
ref: {},
|
ref: {},
|
||||||
isFavorite: false,
|
isFavorite: false,
|
||||||
@@ -16961,6 +16991,17 @@ speechSynthesis.getVoices();
|
|||||||
isIos: false
|
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 () {
|
API.$on('LOGOUT', function () {
|
||||||
$app.worldDialog.visible = false;
|
$app.worldDialog.visible = false;
|
||||||
});
|
});
|
||||||
@@ -17082,11 +17123,19 @@ speechSynthesis.getVoices();
|
|||||||
D.isPC = false;
|
D.isPC = false;
|
||||||
D.isQuest = false;
|
D.isQuest = false;
|
||||||
D.isIos = false;
|
D.isIos = false;
|
||||||
|
this.ignoreWorldMemoSave = true;
|
||||||
|
D.memo = '';
|
||||||
var LL = API.parseLocation(this.lastLocation.location);
|
var LL = API.parseLocation(this.lastLocation.location);
|
||||||
var currentWorldMatch = false;
|
var currentWorldMatch = false;
|
||||||
if (LL.worldId === D.id) {
|
if (LL.worldId === D.id) {
|
||||||
currentWorldMatch = true;
|
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) => {
|
database.getLastVisit(D.id, currentWorldMatch).then((ref) => {
|
||||||
if (ref.worldId === D.id) {
|
if (ref.worldId === D.id) {
|
||||||
D.lastVisit = ref.created_at;
|
D.lastVisit = ref.created_at;
|
||||||
|
|||||||
@@ -641,6 +641,10 @@ html
|
|||||||
timer(:epoch="user.$location_at")
|
timer(:epoch="user.$location_at")
|
||||||
el-tab-pane(:label="$t('dialog.world.info.header')")
|
el-tab-pane(:label="$t('dialog.world.info.header')")
|
||||||
.x-friend-list(style="max-height:none")
|
.x-friend-list(style="max-height:none")
|
||||||
|
.x-friend-item(style="width:100%;cursor:default")
|
||||||
|
.detail
|
||||||
|
span.name {{ $t('dialog.world.info.memo') }}
|
||||||
|
el-input.extra(v-model="worldDialog.memo" type="textarea" :rows="2" :autosize="{ minRows: 1, maxRows: 20 }" :placeholder="$t('dialog.world.info.memo_placeholder')" size="mini" resize="none")
|
||||||
div(style="width:100%;display:flex")
|
div(style="width:100%;display:flex")
|
||||||
.x-friend-item(style="width:350px;cursor:default")
|
.x-friend-item(style="width:350px;cursor:default")
|
||||||
.detail
|
.detail
|
||||||
|
|||||||
@@ -644,6 +644,8 @@
|
|||||||
},
|
},
|
||||||
"info": {
|
"info": {
|
||||||
"header": "Info",
|
"header": "Info",
|
||||||
|
"memo": "Memo",
|
||||||
|
"memo_placeholder": "Click to add a memo",
|
||||||
"id": "World ID",
|
"id": "World ID",
|
||||||
"id_tooltip": "Copy to clipboard",
|
"id_tooltip": "Copy to clipboard",
|
||||||
"copy_id": "Copy ID",
|
"copy_id": "Copy ID",
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ class Database {
|
|||||||
await sqliteService.executeNonQuery(
|
await sqliteService.executeNonQuery(
|
||||||
`CREATE TABLE IF NOT EXISTS memos (user_id TEXT PRIMARY KEY, edited_at TEXT, memo TEXT)`
|
`CREATE TABLE IF NOT EXISTS memos (user_id TEXT PRIMARY KEY, edited_at TEXT, memo TEXT)`
|
||||||
);
|
);
|
||||||
|
await sqliteService.executeNonQuery(
|
||||||
|
`CREATE TABLE IF NOT EXISTS world_memos (world_id TEXT PRIMARY KEY, edited_at TEXT, memo TEXT)`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async initTables() {
|
async initTables() {
|
||||||
@@ -172,6 +175,8 @@ class Database {
|
|||||||
sqliteService.executeNonQuery('COMMIT');
|
sqliteService.executeNonQuery('COMMIT');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// memos
|
||||||
|
|
||||||
async getMemo(userId) {
|
async getMemo(userId) {
|
||||||
var row = {};
|
var row = {};
|
||||||
await sqliteService.execute(
|
await sqliteService.execute(
|
||||||
@@ -222,6 +227,46 @@ class Database {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// world memos
|
||||||
|
|
||||||
|
async getWorldMemo(worldId) {
|
||||||
|
var row = {};
|
||||||
|
await sqliteService.execute(
|
||||||
|
(dbRow) => {
|
||||||
|
row = {
|
||||||
|
worldId: dbRow[0],
|
||||||
|
editedAt: dbRow[1],
|
||||||
|
memo: dbRow[2]
|
||||||
|
};
|
||||||
|
},
|
||||||
|
`SELECT * FROM world_memos WHERE world_id = @world_id`,
|
||||||
|
{
|
||||||
|
'@world_id': worldId
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
setWorldMemo(entry) {
|
||||||
|
sqliteService.executeNonQuery(
|
||||||
|
`INSERT OR REPLACE INTO world_memos (world_id, edited_at, memo) VALUES (@world_id, @edited_at, @memo)`,
|
||||||
|
{
|
||||||
|
'@world_id': entry.worldId,
|
||||||
|
'@edited_at': entry.editedAt,
|
||||||
|
'@memo': entry.memo
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteWorldMemo(worldId) {
|
||||||
|
sqliteService.executeNonQuery(
|
||||||
|
`DELETE FROM world_memos WHERE world_id = @world_id`,
|
||||||
|
{
|
||||||
|
'@world_id': worldId
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
async getFriendLogCurrent() {
|
async getFriendLogCurrent() {
|
||||||
var friendLogCurrent = [];
|
var friendLogCurrent = [];
|
||||||
await sqliteService.execute((dbRow) => {
|
await sqliteService.execute((dbRow) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user