Location group name cache

This commit is contained in:
Natsumi
2022-12-11 22:01:44 +13:00
parent 8e83c626d2
commit db298a4d20
4 changed files with 144 additions and 68 deletions
+74 -34
View File
@@ -823,6 +823,10 @@ speechSynthesis.getVoices();
type: String, type: String,
default: '' default: ''
}, },
grouphint: {
type: String,
default: ''
},
link: { link: {
type: Boolean, type: Boolean,
default: true default: true
@@ -884,7 +888,9 @@ speechSynthesis.getVoices();
this.text = ref.name; this.text = ref.name;
} }
} }
if (L.groupId) { if (this.grouphint) {
this.groupName = this.grouphint;
} else if (L.groupId) {
this.groupName = L.groupId; this.groupName = L.groupId;
API.getCachedGroup({groupId: L.groupId}).then((args) => { API.getCachedGroup({groupId: L.groupId}).then((args) => {
this.groupName = args.json.name; this.groupName = args.json.name;
@@ -946,7 +952,11 @@ speechSynthesis.getVoices();
props: { props: {
locationobject: Object, locationobject: Object,
currentuserid: String, currentuserid: String,
worlddialogshortname: String worlddialogshortname: String,
grouphint: {
type: String,
default: ''
}
}, },
data() { data() {
return { return {
@@ -954,6 +964,7 @@ speechSynthesis.getVoices();
instanceName: this.instanceName, instanceName: this.instanceName,
accessType: this.accessType, accessType: this.accessType,
region: this.region, region: this.region,
shortName: this.shortName,
isUnlocked: this.isUnlocked, isUnlocked: this.isUnlocked,
strict: this.strict, strict: this.strict,
groupName: this.groupName groupName: this.groupName
@@ -965,6 +976,7 @@ speechSynthesis.getVoices();
this.instanceName = this.locationobject.instanceName; this.instanceName = this.locationobject.instanceName;
this.accessType = this.locationobject.accessType; this.accessType = this.locationobject.accessType;
this.strict = this.locationobject.strict; this.strict = this.locationobject.strict;
this.shortName = this.locationobject.shortName;
this.isUnlocked = false; this.isUnlocked = false;
if ( if (
@@ -983,7 +995,9 @@ speechSynthesis.getVoices();
} }
this.groupName = ''; this.groupName = '';
if (this.locationobject.groupId) { if (this.grouphint) {
this.groupName = this.grouphint;
} else if (this.locationobject.groupId) {
this.groupName = this.locationobject.groupId; this.groupName = this.locationobject.groupId;
API.getCachedGroup({ API.getCachedGroup({
groupId: this.locationobject.groupId groupId: this.locationobject.groupId
@@ -994,7 +1008,7 @@ speechSynthesis.getVoices();
} }
}, },
showLaunchDialog() { showLaunchDialog() {
API.$emit('SHOW_LAUNCH_DIALOG', this.location); API.$emit('SHOW_LAUNCH_DIALOG', this.location, this.shortName);
}, },
showGroupDialog() { showGroupDialog() {
if (!this.location) { if (!this.location) {
@@ -4601,7 +4615,9 @@ speechSynthesis.getVoices();
this.verifyShortName('', tag) this.verifyShortName('', tag)
); );
API.$on('SHOW_GROUP_DIALOG', (tag) => this.showGroupDialog(tag)); API.$on('SHOW_GROUP_DIALOG', (tag) => this.showGroupDialog(tag));
API.$on('SHOW_LAUNCH_DIALOG', (tag) => this.showLaunchDialog(tag)); API.$on('SHOW_LAUNCH_DIALOG', (tag, shortName) =>
this.showLaunchDialog(tag, shortName)
);
this.updateLoop(); this.updateLoop();
this.getGameLogTable(); this.getGameLogTable();
this.refreshCustomCss(); this.refreshCustomCss();
@@ -7477,6 +7493,7 @@ speechSynthesis.getVoices();
var ts = Date.now(); var ts = Date.now();
var time = ts - $location_at; var time = ts - $location_at;
var worldName = await this.getWorldName(location); var worldName = await this.getWorldName(location);
var groupName = await this.getGroupName(location);
var feed = { var feed = {
created_at: new Date().toJSON(), created_at: new Date().toJSON(),
type: 'Offline', type: 'Offline',
@@ -7484,6 +7501,7 @@ speechSynthesis.getVoices();
displayName: newRef.displayName, displayName: newRef.displayName,
location, location,
worldName, worldName,
groupName,
time time
}; };
this.addFeed(feed); this.addFeed(feed);
@@ -7498,6 +7516,7 @@ speechSynthesis.getVoices();
ctx.ref.$online_for = Date.now(); ctx.ref.$online_for = Date.now();
ctx.ref.$offline_for = ''; ctx.ref.$offline_for = '';
var worldName = await this.getWorldName(newRef.location); var worldName = await this.getWorldName(newRef.location);
var groupName = await this.getGroupName(location);
var feed = { var feed = {
created_at: new Date().toJSON(), created_at: new Date().toJSON(),
type: 'Online', type: 'Online',
@@ -7505,6 +7524,7 @@ speechSynthesis.getVoices();
displayName: ctx.name, displayName: ctx.name,
location: newRef.location, location: newRef.location,
worldName, worldName,
groupName,
time: '' time: ''
}; };
this.addFeed(feed); this.addFeed(feed);
@@ -7569,6 +7589,20 @@ speechSynthesis.getVoices();
return worldName; return worldName;
}; };
$app.methods.getGroupName = async function (location) {
var groupName = '';
try {
var L = API.parseLocation(location);
if (L.groupId) {
var args = await API.getCachedGroup({
groupId: L.groupId
});
groupName = args.ref.name;
}
} catch (err) {}
return groupName;
};
$app.methods.updateFriendGPS = function (userId) { $app.methods.updateFriendGPS = function (userId) {
if (!this.orderFriendsGroupGPS) { if (!this.orderFriendsGroupGPS) {
if (this.orderFriendsGroupPrivate || this.orderFriendsGroupStatus) { if (this.orderFriendsGroupPrivate || this.orderFriendsGroupStatus) {
@@ -8291,6 +8325,7 @@ speechSynthesis.getVoices();
ref.$location_at = Date.now() - props.location[2]; ref.$location_at = Date.now() - props.location[2];
} else { } else {
var worldName = await $app.getWorldName(props.location[0]); var worldName = await $app.getWorldName(props.location[0]);
var groupName = await $app.getGroupName(props.location[0]);
var feed = { var feed = {
created_at: new Date().toJSON(), created_at: new Date().toJSON(),
type: 'GPS', type: 'GPS',
@@ -8298,6 +8333,7 @@ speechSynthesis.getVoices();
displayName: ref.displayName, displayName: ref.displayName,
location: props.location[0], location: props.location[0],
worldName, worldName,
groupName,
previousLocation, previousLocation,
time time
}; };
@@ -8866,7 +8902,7 @@ speechSynthesis.getVoices();
worldName: gameLog.worldName, worldName: gameLog.worldName,
time: 0 time: 0
}; };
database.addGamelogLocationToDatabase(entry); this.addGamelogLocationToDatabase(entry);
break; break;
case 'player-joined': case 'player-joined':
var joinTime = Date.parse(gameLog.dt); var joinTime = Date.parse(gameLog.dt);
@@ -9098,6 +9134,15 @@ speechSynthesis.getVoices();
} }
}; };
$app.methods.addGamelogLocationToDatabase = async function (input) {
var groupName = await this.getGroupName(input.location);
var entry = {
...input,
groupName
};
database.addGamelogLocationToDatabase(entry);
};
$app.data.lastPortalList = new Map(); $app.data.lastPortalList = new Map();
$app.data.moderationEventQueue = new Map(); $app.data.moderationEventQueue = new Map();
$app.data.moderationAgainstTable = []; $app.data.moderationAgainstTable = [];
@@ -16467,7 +16512,8 @@ speechSynthesis.getVoices();
D.instanceName = D.instanceName.replace(/[^A-Za-z0-9-_]/g, ''); D.instanceName = D.instanceName.replace(/[^A-Za-z0-9-_]/g, '');
tags.push(D.instanceName); tags.push(D.instanceName);
} else { } else {
tags.push((99999 * Math.random() + 1).toFixed(0)); var randValue = (99999 * Math.random() + 1).toFixed(0);
tags.push(String(randValue).padStart(5, '0'));
} }
if (!D.userId) { if (!D.userId) {
D.userId = API.currentUser.id; D.userId = API.currentUser.id;
@@ -16478,15 +16524,14 @@ speechSynthesis.getVoices();
tags.push(`~hidden(${userId})`); tags.push(`~hidden(${userId})`);
} else if (D.accessType === 'friends') { } else if (D.accessType === 'friends') {
tags.push(`~friends(${userId})`); tags.push(`~friends(${userId})`);
} else if (D.accessType === 'group') {
tags.push(`~group(${D.groupId})`);
} else { } else {
tags.push(`~private(${userId})`); tags.push(`~private(${userId})`);
} }
if (D.accessType === 'invite+') { if (D.accessType === 'invite+') {
tags.push('~canRequestInvite'); tags.push('~canRequestInvite');
} }
if (D.accessType === 'group') {
tags.push(`~group(${D.groupId})`);
}
} }
if (D.region === 'US West') { if (D.region === 'US West') {
tags.push(`~region(us)`); tags.push(`~region(us)`);
@@ -16497,7 +16542,7 @@ speechSynthesis.getVoices();
} else if (D.region === 'Japan') { } else if (D.region === 'Japan') {
tags.push(`~region(jp)`); tags.push(`~region(jp)`);
} }
if (D.accessType !== 'public') { if (D.accessType !== 'public' && D.accessType !== 'group') {
tags.push(`~nonce(${uuidv4()})`); tags.push(`~nonce(${uuidv4()})`);
} }
if (D.accessType !== 'invite' && D.accessType !== 'friends') { if (D.accessType !== 'invite' && D.accessType !== 'friends') {
@@ -21327,7 +21372,7 @@ speechSynthesis.getVoices();
$app.data.databaseVersion = configRepository.getInt('VRCX_databaseVersion'); $app.data.databaseVersion = configRepository.getInt('VRCX_databaseVersion');
$app.methods.updateDatabaseVersion = async function () { $app.methods.updateDatabaseVersion = async function () {
var databaseVersion = 3; var databaseVersion = 4;
if (this.databaseVersion !== databaseVersion) { if (this.databaseVersion !== databaseVersion) {
console.log( console.log(
`Updating database from ${this.databaseVersion} to ${databaseVersion}...` `Updating database from ${this.databaseVersion} to ${databaseVersion}...`
@@ -21337,6 +21382,9 @@ speechSynthesis.getVoices();
await database.fixNegativeGPS(); // fix GPS being a negative value due to VRCX bug with traveling await database.fixNegativeGPS(); // fix GPS being a negative value due to VRCX bug with traveling
await database.fixBrokenLeaveEntries(); // fix user instance timer being higher than current user location timer await database.fixBrokenLeaveEntries(); // fix user instance timer being higher than current user location timer
await database.fixBrokenGroupInvites(); // fix notification v2 in wrong table await database.fixBrokenGroupInvites(); // fix notification v2 in wrong table
if (this.databaseVersion && this.databaseVersion < 4) {
await database.updateTableForGroupNames(); // alter tables to include group name
}
this.databaseVersion = databaseVersion; this.databaseVersion = databaseVersion;
configRepository.setInt('VRCX_databaseVersion', databaseVersion); configRepository.setInt('VRCX_databaseVersion', databaseVersion);
console.log('Database update complete.'); console.log('Database update complete.');
@@ -23363,27 +23411,28 @@ speechSynthesis.getVoices();
$app.data.loadMoreGroupMembersParams = {}; $app.data.loadMoreGroupMembersParams = {};
$app.methods.getGroupDialogGroupMembers = async function () { $app.methods.getGroupDialogGroupMembers = async function () {
this.groupDialog.members = []; var D = this.groupDialog;
D.members = [];
this.isGroupMembersDone = false; this.isGroupMembersDone = false;
this.loadMoreGroupMembersParams = { this.loadMoreGroupMembersParams = {
n: 25, n: 25,
offset: 0, offset: 0,
groupId: this.groupDialog.id groupId: D.id
}; };
if (this.isAllowedToViewGroupMembers()) { if (this.hasGroupPermission(D.ref, 'group-members-viewall')) {
// friend only group view perms only allow max n=25 // friend only group view perms only allow max n=25
this.loadMoreGroupMembersParams.n = 100; this.loadMoreGroupMembersParams.n = 100;
} }
if (!this.groupDialog.inGroup) { if (!D.inGroup) {
return; return;
} }
await API.getGroupMember({ await API.getGroupMember({
groupId: this.groupDialog.id, groupId: D.id,
userId: API.currentUser.id userId: API.currentUser.id
}).then((args) => { }).then((args) => {
if (args.json) { if (args.json) {
args.json.user = API.currentUser; args.json.user = API.currentUser;
this.groupDialog.members.push(args.json); D.members.push(args.json);
} }
return args; return args;
}); });
@@ -23422,14 +23471,13 @@ speechSynthesis.getVoices();
}); });
}; };
$app.methods.isAllowedToViewGroupMembers = function () { $app.methods.hasGroupPermission = function (ref, permission) {
var D = this.groupDialog;
if ( if (
D.ref && ref &&
D.ref.myMember && ref.myMember &&
D.ref.myMember.permissions && ref.myMember.permissions &&
(D.ref.myMember.permissions.includes('*') || (ref.myMember.permissions.includes('*') ||
D.ref.myMember.permissions.includes('group-members-viewall')) ref.myMember.permissions.includes(permission))
) { ) {
return true; return true;
} }
@@ -23534,15 +23582,7 @@ speechSynthesis.getVoices();
D.loading = true; D.loading = true;
API.getGroup({groupId}) API.getGroup({groupId})
.then((args) => { .then((args) => {
var group = args.ref; if (this.hasGroupPermission(args.ref, 'group-invites-manage')) {
if (
group.myMember &&
group.myMember.permissions &&
(group.myMember.permissions.includes('*') ||
group.myMember.permissions.includes(
'group-invites-manage'
))
) {
return args; return args;
} }
// not allowed to invite // not allowed to invite
+13 -13
View File
@@ -176,7 +176,7 @@ html
i.x-user-status(:class="statusClass(scope.row.status)") i.x-user-status(:class="statusClass(scope.row.status)")
span(v-if="scope.row.statusDescription !== scope.row.previousStatusDescription" v-text="scope.row.statusDescription" style="margin-left:5px") span(v-if="scope.row.statusDescription !== scope.row.previousStatusDescription" v-text="scope.row.statusDescription" style="margin-left:5px")
span.x-link(v-else-if="scope.row.type === 'PortalSpawn'" @click="showWorldDialog(scope.row.location, scope.row.shortName)") span.x-link(v-else-if="scope.row.type === 'PortalSpawn'" @click="showWorldDialog(scope.row.location, scope.row.shortName)")
location(:location="scope.row.location" :hint="scope.row.worldName" :link="false") location(:location="scope.row.location" :hint="scope.row.worldName" :grouphint="scope.row.groupName" :link="false")
span(v-else-if="scope.row.type === 'ChatBoxMessage'" v-text="scope.row.text") span(v-else-if="scope.row.type === 'ChatBoxMessage'" v-text="scope.row.text")
span(v-else-if="scope.row.type === 'OnPlayerJoined'") span(v-else-if="scope.row.type === 'OnPlayerJoined'")
span.x-link(v-text="scope.row.avatar.name" @click="showAvatarDialog(scope.row.avatar.id)") span.x-link(v-text="scope.row.avatar.name" @click="showAvatarDialog(scope.row.avatar.id)")
@@ -230,7 +230,7 @@ html
i.x-user-status(:class="statusClass(scope.row.status)") i.x-user-status(:class="statusClass(scope.row.status)")
span(v-if="scope.row.statusDescription !== scope.row.previousStatusDescription" v-text="scope.row.statusDescription" style="margin-left:5px") span(v-if="scope.row.statusDescription !== scope.row.previousStatusDescription" v-text="scope.row.statusDescription" style="margin-left:5px")
span.x-link(v-else-if="scope.row.type === 'PortalSpawn'" @click="showWorldDialog(scope.row.location, scope.row.shortName)") span.x-link(v-else-if="scope.row.type === 'PortalSpawn'" @click="showWorldDialog(scope.row.location, scope.row.shortName)")
location(:location="scope.row.location" :hint="scope.row.worldName" :link="false") location(:location="scope.row.location" :hint="scope.row.worldName" :grouphint="scope.row.groupName" :link="false")
span(v-else-if="scope.row.type === 'ChatBoxMessage'" v-text="scope.row.text") span(v-else-if="scope.row.type === 'ChatBoxMessage'" v-text="scope.row.text")
span(v-else-if="scope.row.type === 'OnPlayerJoined'") span(v-else-if="scope.row.type === 'OnPlayerJoined'")
span.x-link(v-text="scope.row.avatar.name" @click="showAvatarDialog(scope.row.avatar.id)") span.x-link(v-text="scope.row.avatar.name" @click="showAvatarDialog(scope.row.avatar.id)")
@@ -328,13 +328,13 @@ html
br br
span span
i.el-icon-right i.el-icon-right
location(v-if="scope.row.location" :location="scope.row.location" :hint="scope.row.worldName") location(v-if="scope.row.location" :location="scope.row.location" :hint="scope.row.worldName" :grouphint="scope.row.groupName")
template(v-else-if="scope.row.type === 'Offline'") template(v-else-if="scope.row.type === 'Offline'")
template(v-if="scope.row.location") template(v-if="scope.row.location")
location(:location="scope.row.location" :hint="scope.row.worldName") location(:location="scope.row.location" :hint="scope.row.worldName" :grouphint="scope.row.groupName")
el-tag(type="info" effect="plain" size="mini" style="margin-left:5px") {{ scope.row.time | timeToText }} el-tag(type="info" effect="plain" size="mini" style="margin-left:5px") {{ scope.row.time | timeToText }}
template(v-else-if="scope.row.type === 'Online'") template(v-else-if="scope.row.type === 'Online'")
location(v-if="scope.row.location" :location="scope.row.location" :hint="scope.row.worldName") location(v-if="scope.row.location" :location="scope.row.location" :hint="scope.row.worldName" :grouphint="scope.row.groupName")
template(v-else-if="scope.row.type === 'Avatar'") template(v-else-if="scope.row.type === 'Avatar'")
el-popover(placement="right" width="500px" trigger="click") el-popover(placement="right" width="500px" trigger="click")
img.x-link(slot="reference" v-lazy="scope.row.previousCurrentAvatarThumbnailImageUrl" style="flex:none;width:160px;height:120px;border-radius:4px") img.x-link(slot="reference" v-lazy="scope.row.previousCurrentAvatarThumbnailImageUrl" style="flex:none;width:160px;height:120px;border-radius:4px")
@@ -379,9 +379,9 @@ html
el-table-column(label="Detail") el-table-column(label="Detail")
template(v-once #default="scope") template(v-once #default="scope")
template(v-if="scope.row.type === 'GPS'") template(v-if="scope.row.type === 'GPS'")
location(v-if="scope.row.location" :location="scope.row.location" :hint="scope.row.worldName") location(v-if="scope.row.location" :location="scope.row.location" :hint="scope.row.worldName" :grouphint="scope.row.groupName")
template(v-else-if="scope.row.type === 'Offline' || scope.row.type === 'Online'") template(v-else-if="scope.row.type === 'Offline' || scope.row.type === 'Online'")
location(v-if="scope.row.location" :location="scope.row.location" :hint="scope.row.worldName") location(v-if="scope.row.location" :location="scope.row.location" :hint="scope.row.worldName" :grouphint="scope.row.groupName")
template(v-else-if="scope.row.type === 'Status'") template(v-else-if="scope.row.type === 'Status'")
template(v-if="scope.row.statusDescription === scope.row.previousStatusDescription") template(v-if="scope.row.statusDescription === scope.row.previousStatusDescription")
el-tooltip(placement="top") el-tooltip(placement="top")
@@ -441,8 +441,8 @@ html
span.x-link(v-if="scope.row.displayName" v-text="scope.row.displayName" @click="lookupUser(scope.row)" style="padding-right:10px") span.x-link(v-if="scope.row.displayName" v-text="scope.row.displayName" @click="lookupUser(scope.row)" style="padding-right:10px")
el-table-column(label="Detail" prop="data") el-table-column(label="Detail" prop="data")
template(v-once #default="scope") template(v-once #default="scope")
location(v-if="scope.row.type === 'Location'" :location="scope.row.location" :hint="scope.row.worldName") location(v-if="scope.row.type === 'Location'" :location="scope.row.location" :hint="scope.row.worldName" :grouphint="scope.row.groupName")
location(v-else-if="scope.row.type === 'PortalSpawn'" :location="scope.row.instanceId" :hint="scope.row.worldName") location(v-else-if="scope.row.type === 'PortalSpawn'" :location="scope.row.instanceId" :hint="scope.row.worldName" :grouphint="scope.row.groupName")
template(v-else-if="scope.row.type === 'Event'") template(v-else-if="scope.row.type === 'Event'")
span(v-text="scope.row.data") span(v-text="scope.row.data")
template(v-else-if="scope.row.type === 'VideoPlay'") template(v-else-if="scope.row.type === 'VideoPlay'")
@@ -757,7 +757,7 @@ html
template(v-once #default="scope") template(v-once #default="scope")
el-tooltip(v-if="scope.row.type === 'invite'" placement="top") el-tooltip(v-if="scope.row.type === 'invite'" placement="top")
template(#content) template(#content)
location(v-if="scope.row.details" :location="scope.row.details.worldId" :hint="scope.row.details.worldName" :link="false") location(v-if="scope.row.details" :location="scope.row.details.worldId" :hint="scope.row.details.worldName" :grouphint="scope.row.details.groupName" :link="false")
span.x-link(v-text="scope.row.type" @click="showWorldDialog(scope.row.details.worldId)") span.x-link(v-text="scope.row.type" @click="showWorldDialog(scope.row.details.worldId)")
template(v-else-if="scope.row.link") template(v-else-if="scope.row.link")
el-tooltip(placement="top" :content="scope.row.linkText" :disabled="hideTooltips") el-tooltip(placement="top" :content="scope.row.linkText" :disabled="hideTooltips")
@@ -2304,7 +2304,7 @@ html
span.extra {{ groupDialog.ref.myMember.joinedAt | formatDate('long') }} span.extra {{ groupDialog.ref.myMember.joinedAt | formatDate('long') }}
el-tab-pane(label="Members") el-tab-pane(label="Members")
template(v-if="groupDialog.visible && groupDialog.ref.membershipStatus === 'member'") template(v-if="groupDialog.visible && groupDialog.ref.membershipStatus === 'member'")
span(v-if="isAllowedToViewGroupMembers()" style="font-weight:bold;font-size:16px") All Members span(v-if="hasGroupPermission(groupDialog.ref, 'group-members-viewall')" style="font-weight:bold;font-size:16px") All Members
span(v-else style="font-weight:bold;font-size:16px") Friends Only span(v-else style="font-weight:bold;font-size:16px") Friends Only
br br
el-button(type="default" @click="getGroupDialogGroupMembers()" size="mini" icon="el-icon-refresh" circle) el-button(type="default" @click="getGroupDialogGroupMembers()" size="mini" icon="el-icon-refresh" circle)
@@ -3310,7 +3310,7 @@ html
span {{ scope.row.created_at | formatDate('short') }} span {{ scope.row.created_at | formatDate('short') }}
el-table-column(label="World" prop="name" sortable) el-table-column(label="World" prop="name" sortable)
template(v-once #default="scope") template(v-once #default="scope")
location(:location="scope.row.location" :hint="scope.row.name") location(:location="scope.row.location" :hint="scope.row.worldName" :grouphint="scope.row.groupName")
el-table-column(label="Instance Creator" prop="location" width="160") el-table-column(label="Instance Creator" prop="location" width="160")
template(v-once #default="scope") template(v-once #default="scope")
display-name(:userid="scope.row.$location.userId" :location="scope.row.$location.tag" :key="previousInstancesUserDialog.forceUpdate") display-name(:userid="scope.row.$location.userId" :location="scope.row.$location.tag" :key="previousInstancesUserDialog.forceUpdate")
@@ -3336,7 +3336,7 @@ html
span {{ scope.row.created_at | formatDate('short') }} span {{ scope.row.created_at | formatDate('short') }}
el-table-column(label="Instance Name" prop="name") el-table-column(label="Instance Name" prop="name")
template(v-once #default="scope") template(v-once #default="scope")
location-world(:locationobject="scope.row.$location" :currentuserid="API.currentUser.id") location-world(:locationobject="scope.row.$location" :grouphint="scope.row.groupName" :currentuserid="API.currentUser.id")
el-table-column(label="Instance Creator" prop="location") el-table-column(label="Instance Creator" prop="location")
template(v-once #default="scope") template(v-once #default="scope")
display-name(:userid="scope.row.$location.userId" :location="scope.row.$location.tag" :key="previousInstancesWorldDialog.forceUpdate") display-name(:userid="scope.row.$location.userId" :location="scope.row.$location.tag" :key="previousInstancesWorldDialog.forceUpdate")
+46 -19
View File
@@ -9,7 +9,7 @@ class Database {
Database.userId = userId; Database.userId = userId;
Database.userPrefix = userId.replaceAll('-', '').replaceAll('_', ''); Database.userPrefix = userId.replaceAll('-', '').replaceAll('_', '');
await sqliteService.executeNonQuery( await sqliteService.executeNonQuery(
`CREATE TABLE IF NOT EXISTS ${Database.userPrefix}_feed_gps (id INTEGER PRIMARY KEY, created_at TEXT, user_id TEXT, display_name TEXT, location TEXT, world_name TEXT, previous_location TEXT, time INTEGER)` `CREATE TABLE IF NOT EXISTS ${Database.userPrefix}_feed_gps (id INTEGER PRIMARY KEY, created_at TEXT, user_id TEXT, display_name TEXT, location TEXT, world_name TEXT, previous_location TEXT, time INTEGER, group_name TEXT)`
); );
await sqliteService.executeNonQuery( await sqliteService.executeNonQuery(
`CREATE TABLE IF NOT EXISTS ${Database.userPrefix}_feed_status (id INTEGER PRIMARY KEY, created_at TEXT, user_id TEXT, display_name TEXT, status TEXT, status_description TEXT, previous_status TEXT, previous_status_description TEXT)` `CREATE TABLE IF NOT EXISTS ${Database.userPrefix}_feed_status (id INTEGER PRIMARY KEY, created_at TEXT, user_id TEXT, display_name TEXT, status TEXT, status_description TEXT, previous_status TEXT, previous_status_description TEXT)`
@@ -18,7 +18,7 @@ class Database {
`CREATE TABLE IF NOT EXISTS ${Database.userPrefix}_feed_avatar (id INTEGER PRIMARY KEY, created_at TEXT, user_id TEXT, display_name TEXT, owner_id TEXT, avatar_name TEXT, current_avatar_image_url TEXT, current_avatar_thumbnail_image_url TEXT, previous_current_avatar_image_url TEXT, previous_current_avatar_thumbnail_image_url TEXT)` `CREATE TABLE IF NOT EXISTS ${Database.userPrefix}_feed_avatar (id INTEGER PRIMARY KEY, created_at TEXT, user_id TEXT, display_name TEXT, owner_id TEXT, avatar_name TEXT, current_avatar_image_url TEXT, current_avatar_thumbnail_image_url TEXT, previous_current_avatar_image_url TEXT, previous_current_avatar_thumbnail_image_url TEXT)`
); );
await sqliteService.executeNonQuery( await sqliteService.executeNonQuery(
`CREATE TABLE IF NOT EXISTS ${Database.userPrefix}_feed_online_offline (id INTEGER PRIMARY KEY, created_at TEXT, user_id TEXT, display_name TEXT, type TEXT, location TEXT, world_name TEXT, time INTEGER)` `CREATE TABLE IF NOT EXISTS ${Database.userPrefix}_feed_online_offline (id INTEGER PRIMARY KEY, created_at TEXT, user_id TEXT, display_name TEXT, type TEXT, location TEXT, world_name TEXT, time INTEGER, group_name TEXT)`
); );
await sqliteService.executeNonQuery( await sqliteService.executeNonQuery(
`CREATE TABLE IF NOT EXISTS ${Database.userPrefix}_friend_log_current (user_id TEXT PRIMARY KEY, display_name TEXT, trust_level TEXT)` `CREATE TABLE IF NOT EXISTS ${Database.userPrefix}_friend_log_current (user_id TEXT PRIMARY KEY, display_name TEXT, trust_level TEXT)`
@@ -42,7 +42,7 @@ class Database {
async initTables() { async initTables() {
await sqliteService.executeNonQuery( await sqliteService.executeNonQuery(
`CREATE TABLE IF NOT EXISTS gamelog_location (id INTEGER PRIMARY KEY, created_at TEXT, location TEXT, world_id TEXT, world_name TEXT, time INTEGER, UNIQUE(created_at, location))` `CREATE TABLE IF NOT EXISTS gamelog_location (id INTEGER PRIMARY KEY, created_at TEXT, location TEXT, world_id TEXT, world_name TEXT, time INTEGER, groupName TEXT, UNIQUE(created_at, location))`
); );
await sqliteService.executeNonQuery( await sqliteService.executeNonQuery(
`CREATE TABLE IF NOT EXISTS gamelog_join_leave (id INTEGER PRIMARY KEY, created_at TEXT, type TEXT, display_name TEXT, location TEXT, user_id TEXT, time INTEGER, UNIQUE(created_at, type, display_name))` `CREATE TABLE IF NOT EXISTS gamelog_join_leave (id INTEGER PRIMARY KEY, created_at TEXT, type TEXT, display_name TEXT, location TEXT, user_id TEXT, time INTEGER, UNIQUE(created_at, type, display_name))`
@@ -82,7 +82,8 @@ class Database {
location: dbRow[4], location: dbRow[4],
worldName: dbRow[5], worldName: dbRow[5],
previousLocation: dbRow[6], previousLocation: dbRow[6],
time: dbRow[7] time: dbRow[7],
groupName: dbRow[8]
}; };
feedDatabase.unshift(row); feedDatabase.unshift(row);
}, `SELECT * FROM ${Database.userPrefix}_feed_gps WHERE created_at >= date('${dateOffset}') ORDER BY id DESC`); }, `SELECT * FROM ${Database.userPrefix}_feed_gps WHERE created_at >= date('${dateOffset}') ORDER BY id DESC`);
@@ -125,7 +126,8 @@ class Database {
type: dbRow[4], type: dbRow[4],
location: dbRow[5], location: dbRow[5],
worldName: dbRow[6], worldName: dbRow[6],
time: dbRow[7] time: dbRow[7],
groupName: dbRow[8]
}; };
feedDatabase.unshift(row); feedDatabase.unshift(row);
}, `SELECT * FROM ${Database.userPrefix}_feed_online_offline WHERE created_at >= date('${dateOffset}') ORDER BY id DESC`); }, `SELECT * FROM ${Database.userPrefix}_feed_online_offline WHERE created_at >= date('${dateOffset}') ORDER BY id DESC`);
@@ -346,7 +348,7 @@ class Database {
addGPSToDatabase(entry) { addGPSToDatabase(entry) {
sqliteService.executeNonQuery( sqliteService.executeNonQuery(
`INSERT OR IGNORE INTO ${Database.userPrefix}_feed_gps (created_at, user_id, display_name, location, world_name, previous_location, time) VALUES (@created_at, @user_id, @display_name, @location, @world_name, @previous_location, @time)`, `INSERT OR IGNORE INTO ${Database.userPrefix}_feed_gps (created_at, user_id, display_name, location, world_name, previous_location, time, group_name) VALUES (@created_at, @user_id, @display_name, @location, @world_name, @previous_location, @time, @group_name)`,
{ {
'@created_at': entry.created_at, '@created_at': entry.created_at,
'@user_id': entry.userId, '@user_id': entry.userId,
@@ -354,7 +356,8 @@ class Database {
'@location': entry.location, '@location': entry.location,
'@world_name': entry.worldName, '@world_name': entry.worldName,
'@previous_location': entry.previousLocation, '@previous_location': entry.previousLocation,
'@time': entry.time '@time': entry.time,
'@group_name': entry.groupName
} }
); );
} }
@@ -396,7 +399,7 @@ class Database {
addOnlineOfflineToDatabase(entry) { addOnlineOfflineToDatabase(entry) {
sqliteService.executeNonQuery( sqliteService.executeNonQuery(
`INSERT OR IGNORE INTO ${Database.userPrefix}_feed_online_offline (created_at, user_id, display_name, type, location, world_name, time) VALUES (@created_at, @user_id, @display_name, @type, @location, @world_name, @time)`, `INSERT OR IGNORE INTO ${Database.userPrefix}_feed_online_offline (created_at, user_id, display_name, type, location, world_name, time, group_name) VALUES (@created_at, @user_id, @display_name, @type, @location, @world_name, @time, @group_name)`,
{ {
'@created_at': entry.created_at, '@created_at': entry.created_at,
'@user_id': entry.userId, '@user_id': entry.userId,
@@ -404,7 +407,8 @@ class Database {
'@type': entry.type, '@type': entry.type,
'@location': entry.location, '@location': entry.location,
'@world_name': entry.worldName, '@world_name': entry.worldName,
'@time': entry.time '@time': entry.time,
'@group_name': entry.groupName
} }
); );
} }
@@ -422,7 +426,8 @@ class Database {
location: dbRow[2], location: dbRow[2],
worldId: dbRow[3], worldId: dbRow[3],
worldName: dbRow[4], worldName: dbRow[4],
time: dbRow[5] time: dbRow[5],
groupName: dbRow[6]
}; };
gamelogDatabase.unshift(row); gamelogDatabase.unshift(row);
}, `SELECT * FROM gamelog_location WHERE created_at >= date('${dateOffset}') ORDER BY id DESC`); }, `SELECT * FROM gamelog_location WHERE created_at >= date('${dateOffset}') ORDER BY id DESC`);
@@ -491,13 +496,14 @@ class Database {
addGamelogLocationToDatabase(entry) { addGamelogLocationToDatabase(entry) {
sqliteService.executeNonQuery( sqliteService.executeNonQuery(
`INSERT OR IGNORE INTO gamelog_location (created_at, location, world_id, world_name, time) VALUES (@created_at, @location, @world_id, @world_name, @time)`, `INSERT OR IGNORE INTO gamelog_location (created_at, location, world_id, world_name, time, group_name) VALUES (@created_at, @location, @world_id, @world_name, @time, @group_name)`,
{ {
'@created_at': entry.created_at, '@created_at': entry.created_at,
'@location': entry.location, '@location': entry.location,
'@world_id': entry.worldId, '@world_id': entry.worldId,
'@world_name': entry.worldName, '@world_name': entry.worldName,
'@time': entry.time '@time': entry.time,
'@group_name': entry.groupName
} }
); );
} }
@@ -1019,7 +1025,8 @@ class Database {
location: dbRow[4], location: dbRow[4],
worldName: dbRow[5], worldName: dbRow[5],
previousLocation: dbRow[6], previousLocation: dbRow[6],
time: dbRow[7] time: dbRow[7],
groupName: dbRow[8]
}; };
feedDatabase.unshift(row); feedDatabase.unshift(row);
}, `SELECT * FROM ${Database.userPrefix}_feed_gps WHERE (display_name LIKE '%${search}%' OR world_name LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${Database.maxTableSize}`); }, `SELECT * FROM ${Database.userPrefix}_feed_gps WHERE (display_name LIKE '%${search}%' OR world_name LIKE '%${search}%') ${vipQuery} ORDER BY id DESC LIMIT ${Database.maxTableSize}`);
@@ -1076,7 +1083,8 @@ class Database {
type: dbRow[4], type: dbRow[4],
location: dbRow[5], location: dbRow[5],
worldName: dbRow[6], worldName: dbRow[6],
time: dbRow[7] time: dbRow[7],
groupName: dbRow[8]
}; };
feedDatabase.unshift(row); feedDatabase.unshift(row);
}, `SELECT * FROM ${Database.userPrefix}_feed_online_offline WHERE ((display_name LIKE '%${search}%' OR world_name LIKE '%${search}%') ${query}) ${vipQuery} ORDER BY id DESC LIMIT ${Database.maxTableSize}`); }, `SELECT * FROM ${Database.userPrefix}_feed_online_offline WHERE ((display_name LIKE '%${search}%' OR world_name LIKE '%${search}%') ${query}) ${vipQuery} ORDER BY id DESC LIMIT ${Database.maxTableSize}`);
@@ -1145,7 +1153,8 @@ class Database {
location: dbRow[2], location: dbRow[2],
worldId: dbRow[3], worldId: dbRow[3],
worldName: dbRow[4], worldName: dbRow[4],
time: dbRow[5] time: dbRow[5],
groupName: dbRow[6]
}; };
gamelogDatabase.unshift(row); gamelogDatabase.unshift(row);
}, `SELECT * FROM gamelog_location WHERE world_name LIKE '%${search}%' ORDER BY id DESC LIMIT ${Database.maxTableSize}`); }, `SELECT * FROM gamelog_location WHERE world_name LIKE '%${search}%' ORDER BY id DESC LIMIT ${Database.maxTableSize}`);
@@ -1336,11 +1345,12 @@ class Database {
created_at: dbRow[0], created_at: dbRow[0],
location: dbRow[1], location: dbRow[1],
time, time,
name: dbRow[3] worldName: dbRow[3],
groupName: dbRow[4]
}; };
data.set(row.location, row); data.set(row.location, row);
}, },
`SELECT DISTINCT gamelog_join_leave.created_at, gamelog_join_leave.location, gamelog_join_leave.time, gamelog_location.world_name `SELECT DISTINCT gamelog_join_leave.created_at, gamelog_join_leave.location, gamelog_join_leave.time, gamelog_location.world_name, gamelog_location.group_name
FROM gamelog_join_leave FROM gamelog_join_leave
INNER JOIN gamelog_location ON gamelog_join_leave.location = gamelog_location.location INNER JOIN gamelog_location ON gamelog_join_leave.location = gamelog_location.location
WHERE user_id = @userId OR display_name = @displayName WHERE user_id = @userId OR display_name = @displayName
@@ -1380,11 +1390,12 @@ class Database {
created_at: dbRow[0], created_at: dbRow[0],
location: dbRow[1], location: dbRow[1],
time, time,
name: dbRow[3] worldName: dbRow[3],
groupName: dbRow[4]
}; };
data.set(row.location, row); data.set(row.location, row);
}, },
`SELECT created_at, location, time, world_name `SELECT created_at, location, time, world_name, group_name
FROM gamelog_location FROM gamelog_location
WHERE world_id = @worldId WHERE world_id = @worldId
ORDER BY id DESC`, ORDER BY id DESC`,
@@ -1762,6 +1773,22 @@ class Database {
); );
}); });
} }
async updateTableForGroupNames() {
try {
var tables = [];
await sqliteService.execute((dbRow) => {
tables.push(dbRow[0]);
}, `SELECT name FROM sqlite_schema WHERE type='table' AND name LIKE '%_feed_gps' OR name LIKE '%_feed_online_offline' OR name = 'gamelog_location'`);
tables.forEach((tableName) => {
sqliteService.executeNonQuery(
`ALTER TABLE ${tableName} ADD group_name TEXT DEFAULT ''`
);
});
} catch (e) {
console.error(e);
}
}
} }
var self = new Database(); var self = new Database();
+11 -2
View File
@@ -79,19 +79,27 @@ Vue.component('marquee-text', MarqueeText);
Vue.component('location', { Vue.component('location', {
template: template:
'<span><span style="margin-right:5px">{{ text }}</span><span class="flags" :class="region" style="display:inline-block;margin-bottom:2px"></span><i v-if="strict" class="el-icon el-icon-lock" style="display:inline-block;margin-left:5px"></i></span>', '<span><span style="margin-right:5px">{{ text }}</span>' +
'<span v-if="groupName" style="margin-right:5px">{{ groupName }}</span>' +
'<span class="flags" :class="region" style="display:inline-block;margin-bottom:2px"></span>' +
'<i v-if="strict" class="el-icon el-icon-lock" style="display:inline-block;margin-left:5px"></i></span>',
props: { props: {
location: String, location: String,
hint: { hint: {
type: String, type: String,
default: '' default: ''
},
grouphint: {
type: String,
default: ''
} }
}, },
data() { data() {
return { return {
text: this.location, text: this.location,
region: this.region, region: this.region,
strict: this.strict strict: this.strict,
groupName: this.groupName
}; };
}, },
methods: { methods: {
@@ -130,6 +138,7 @@ Vue.component('marquee-text', MarqueeText);
} }
} }
this.strict = L.strict; this.strict = L.strict;
this.groupName = this.grouphint;
} }
}, },
watch: { watch: {