Group add last visited fixes

This commit is contained in:
Natsumi
2025-08-24 12:22:41 +12:00
parent b96d26e174
commit 90c6422418
4 changed files with 164 additions and 160 deletions

View File

@@ -611,11 +611,23 @@
<span class="extra">{{ formatDateFilter(groupDialog.ref.createdAt, 'long') }}</span>
</div>
</div>
<el-tooltip :disabled="hideTooltips" placement="top" :content="t('dialog.user.info.open_previous_instance')">
<el-tooltip
:disabled="hideTooltips"
placement="top"
:content="t('dialog.user.info.open_previous_instance')">
<div class="x-friend-item" @click="showPreviousInstancesGroupDialog(groupDialog.ref)">
<div class="detail">
<span class="name">{{ t('dialog.group.info.last_visited') }}</span>
<span class="extra">{{formatDateFilter(groupDialog.lastVisit,'long') }}</span>
<span class="name">
{{ t('dialog.group.info.last_visited') }}
<el-tooltip
v-if="!hideTooltips"
placement="top"
style="margin-left: 5px"
:content="t('dialog.user.info.accuracy_notice')">
<i class="el-icon-warning"></i>
</el-tooltip>
</span>
<span class="extra">{{ formatDateFilter(groupDialog.lastVisit, 'long') }}</span>
</div>
</div>
</el-tooltip>
@@ -1176,8 +1188,7 @@
<InviteGroupDialog />
<PreviousInstancesGroupDialog
:previous-instances-group-dialog.sync="previousInstancesGroupDialog"
:current-user="currentUser"
/>
:current-user="currentUser" />
</safe-dialog>
</template>
@@ -1215,7 +1226,7 @@
} from '../../../stores';
import InviteGroupDialog from '../InviteGroupDialog.vue';
import GroupPostEditDialog from './GroupPostEditDialog.vue';
import PreviousInstancesGroupDialog from "../PreviousInstancesDialog/PreviousInstancesGroupDialog.vue";
import PreviousInstancesGroupDialog from '../PreviousInstancesDialog/PreviousInstancesGroupDialog.vue';
const { t } = useI18n();

View File

@@ -1,161 +1,158 @@
<template>
<safe-dialog
ref="previousInstancesGroupDialogRef"
:visible.sync="isVisible"
:title="t('dialog.previous_instances.header')"
width="1000px"
append-to-body
>
<div style="display: flex; align-items: center; justify-content: space-between">
<span style="font-size: 14px" v-text="previousInstancesGroupDialog.groupRef.name"></span>
<el-input
v-model="previousInstancesGroupDialogTable.filters[0].value"
:placeholder="t('dialog.previous_instances.search_placeholder')"
style="width: 150px"
/>
</div>
<safe-dialog
ref="previousInstancesGroupDialogRef"
:visible.sync="isVisible"
:title="t('dialog.previous_instances.header')"
width="1000px"
append-to-body>
<div style="display: flex; align-items: center; justify-content: space-between">
<span style="font-size: 14px" v-text="previousInstancesGroupDialog.groupRef.name"></span>
<el-input
v-model="previousInstancesGroupDialogTable.filters[0].value"
:placeholder="t('dialog.previous_instances.search_placeholder')"
style="width: 150px" />
</div>
<data-tables v-loading="loading" v-bind="previousInstancesGroupDialogTable" style="margin-top: 10px">
<el-table-column :label="t('table.previous_instances.date')" prop="created_at" sortable width="170">
<template #default="scope">
<span>{{ formatDateFilter(scope.row.created_at, 'long') }}</span>
</template>
</el-table-column>
<data-tables v-loading="loading" v-bind="previousInstancesGroupDialogTable" style="margin-top: 10px">
<el-table-column :label="t('table.previous_instances.date')" prop="created_at" sortable width="170">
<template #default="scope">
<span>{{ formatDateFilter(scope.row.created_at, 'long') }}</span>
</template>
</el-table-column>
<el-table-column :label="t('table.previous_instances.instance_name')" prop="name">
<template #default="scope">
<LocationWorld
:locationobject="scope.row.$location"
:grouphint="scope.row.groupName"
:currentuserid="currentUser.id"
/>
</template>
</el-table-column>
<el-table-column :label="t('table.previous_instances.instance_name')" prop="name">
<template #default="scope">
<Location
:location="scope.row.$location.tag"
:grouphint="scope.row.groupName"
:hint="scope.row.worldName" />
</template>
</el-table-column>
<el-table-column :label="t('table.previous_instances.instance_creator')" prop="location">
<template #default="scope">
<DisplayName
:userid="scope.row.$location.userId"
:location="scope.row.$location.tag"
:force-update-key="previousInstancesGroupDialog.forceUpdate"
/>
</template>
</el-table-column>
<el-table-column :label="t('table.previous_instances.time')" prop="time" width="100" sortable>
<template #default="scope">
<span v-text="scope.row.timer"></span>
</template>
</el-table-column>
<el-table-column :label="t('table.previous_instances.time')" prop="time" width="100" sortable>
<template #default="scope">
<span v-text="scope.row.timer"></span>
</template>
</el-table-column>
<el-table-column :label="t('table.previous_instances.action')" width="90" align="right">
<template #default="scope">
<el-button
type="text"
icon="el-icon-s-data"
size="mini"
@click="showPreviousInstancesInfoDialog(scope.row.location)"
/>
<el-button
v-if="shiftHeld"
style="color: #f56c6c"
type="text"
icon="el-icon-close"
size="mini"
@click="deleteGameLogGroupInstance(scope.row)"
/>
<el-button
v-else
type="text"
icon="el-icon-close"
size="mini"
@click="deleteGameLogGroupInstancePrompt(scope.row)"
/>
</template>
</el-table-column>
</data-tables>
</safe-dialog>
<el-table-column :label="t('table.previous_instances.action')" width="90" align="right">
<template #default="scope">
<el-button
type="text"
icon="el-icon-s-data"
size="mini"
@click="showPreviousInstancesInfoDialog(scope.row.location)" />
<el-button
v-if="shiftHeld"
style="color: #f56c6c"
type="text"
icon="el-icon-close"
size="mini"
@click="deleteGameLogGroupInstance(scope.row)" />
<el-button
v-else
type="text"
icon="el-icon-close"
size="mini"
@click="deleteGameLogGroupInstancePrompt(scope.row)" />
</template>
</el-table-column>
</data-tables>
</safe-dialog>
</template>
<script setup>
import { ref, reactive, computed, watch, nextTick, getCurrentInstance } from 'vue';
import { parseLocation, compareByCreatedAt, timeToText, removeFromArray, adjustDialogZ, formatDateFilter } from '../../../shared/utils';
import { database } from '../../../service/database';
import { useI18n } from 'vue-i18n-bridge';
import { useInstanceStore, useUiStore, useUserStore } from '../../../stores';
import { ref, reactive, computed, watch, nextTick, getCurrentInstance } from 'vue';
import {
parseLocation,
compareByCreatedAt,
timeToText,
removeFromArray,
adjustDialogZ,
formatDateFilter
} from '../../../shared/utils';
import { database } from '../../../service/database';
import { useI18n } from 'vue-i18n-bridge';
import { useInstanceStore, useUiStore } from '../../../stores';
const { proxy } = getCurrentInstance();
const { showPreviousInstancesInfoDialog } = useInstanceStore();
const { shiftHeld } = useUiStore();
const { currentUser } = useUserStore();
const { t } = useI18n();
const { proxy } = getCurrentInstance();
const { showPreviousInstancesInfoDialog } = useInstanceStore();
const { shiftHeld } = useUiStore();
const { t } = useI18n();
const previousInstancesGroupDialogRef = ref(null);
const loading = ref(false);
const previousInstancesGroupDialogRef = ref(null);
const loading = ref(false);
const previousInstancesGroupDialogTable = reactive({
data: [],
filters: [{ prop: 'groupName', value: '' }],
tableProps: {
stripe: true,
size: 'mini',
defaultSort: { prop: 'created_at', order: 'descending' }
},
pageSize: 10,
paginationProps: { small: true, layout: 'sizes,prev,pager,next,total', pageSizes: [10, 25, 50, 100] }
});
const props = defineProps({
previousInstancesGroupDialog: { type: Object, required: true },
});
const emit = defineEmits(['update:previousInstancesGroupDialog']);
const isVisible = computed({
get: () => props.previousInstancesGroupDialog.visible,
set: (value) => {
emit('update:previousInstancesGroupDialog', {
...props.previousInstancesGroupDialog,
visible: value
const previousInstancesGroupDialogTable = reactive({
data: [],
filters: [{ prop: 'groupName', value: '' }],
tableProps: {
stripe: true,
size: 'mini',
defaultSort: { prop: 'created_at', order: 'descending' }
},
pageSize: 10,
paginationProps: { small: true, layout: 'sizes,prev,pager,next,total', pageSizes: [10, 25, 50, 100] }
});
}
});
watch(() => props.previousInstancesGroupDialog.openFlg, () => {
if (props.previousInstancesGroupDialog.visible) {
nextTick(() => {
adjustDialogZ(previousInstancesGroupDialogRef.value.$el);
const props = defineProps({
previousInstancesGroupDialog: { type: Object, required: true }
});
refreshPreviousInstancesGroupTable();
}
});
const emit = defineEmits(['update:previousInstancesGroupDialog']);
function refreshPreviousInstancesGroupTable() {
loading.value = true;
const D = props.previousInstancesGroupDialog;
database.getPreviousInstancesByGroupName(D.groupRef.name).then((data) => {
const array = [];
for (const ref of data.values()) {
ref.$location = parseLocation(ref.location);
ref.timer = ref.time > 0 ? timeToText(ref.time) : '';
array.push(ref);
const isVisible = computed({
get: () => props.previousInstancesGroupDialog.visible,
set: (value) => {
emit('update:previousInstancesGroupDialog', {
...props.previousInstancesGroupDialog,
visible: value
});
}
});
watch(
() => props.previousInstancesGroupDialog.openFlg,
() => {
if (props.previousInstancesGroupDialog.visible) {
nextTick(() => {
adjustDialogZ(previousInstancesGroupDialogRef.value.$el);
});
refreshPreviousInstancesGroupTable();
}
}
);
function refreshPreviousInstancesGroupTable() {
loading.value = true;
const D = props.previousInstancesGroupDialog;
database.getPreviousInstancesByGroupId(D.groupRef.id).then((data) => {
const array = [];
for (const ref of data.values()) {
ref.$location = parseLocation(ref.location);
ref.timer = ref.time > 0 ? timeToText(ref.time) : '';
array.push(ref);
}
array.sort(compareByCreatedAt);
previousInstancesGroupDialogTable.data = array;
loading.value = false;
});
}
array.sort(compareByCreatedAt);
previousInstancesGroupDialogTable.data = array;
loading.value = false;
});
}
function deleteGameLogGroupInstance(row) {
database.deleteGameLogInstanceByInstanceId({ location: row.location });
removeFromArray(previousInstancesGroupDialogTable.data, row);
}
function deleteGameLogGroupInstance(row) {
database.deleteGameLogInstanceByInstanceId({ location: row.location });
removeFromArray(previousInstancesGroupDialogTable.data, row);
}
function deleteGameLogGroupInstancePrompt(row) {
proxy.$confirm('Continue? Delete GameLog Instance', 'Confirm', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'info',
callback: (action) => { if (action === 'confirm') deleteGameLogGroupInstance(row); }
});
}
function deleteGameLogGroupInstancePrompt(row) {
proxy.$confirm('Continue? Delete GameLog Instance', 'Confirm', {
confirmButtonText: 'Confirm',
cancelButtonText: 'Cancel',
type: 'info',
callback: (action) => {
if (action === 'confirm') {
deleteGameLogGroupInstance(row);
}
}
});
}
</script>

View File

@@ -829,7 +829,7 @@
"instance_hard_closed": "hard closed",
"close_instance": "Close Instance",
"instance_age_gated": "age gated",
"open_previous_instance": "Open Previous Instance"
"open_previous_instance": "Open Previous Instances"
},
"groups": {
"header": "Groups",

View File

@@ -324,11 +324,11 @@ const gameLog = {
return ref;
},
async getPreviousInstancesByGroupName(groupName) {
var data = new Map();
async getPreviousInstancesByGroupId(groupId) {
const data = new Map();
await sqliteService.execute(
(dbRow) => {
var time = 0;
let time = 0;
if (dbRow[2]) {
time = dbRow[2];
}
@@ -345,21 +345,17 @@ const gameLog = {
};
data.set(row.location, row);
},
`SELECT created_at, location, time, world_name, group_name FROM gamelog_location WHERE group_name = @groupName ORDER BY id DESC`,
`SELECT created_at, location, time, world_name, group_name FROM gamelog_location WHERE location LIKE '%${groupId}%' ORDER BY id DESC`,
{
'@groupName': groupName
'@groupId': groupId
}
);
return data;
},
async getLastSeen(input, inCurrentWorld) {
if (inCurrentWorld) {
var count = 2;
} else {
var count = 1;
}
var ref = {
const count = inCurrentWorld ? 2 : 1;
let ref = {
created_at: '',
userId: ''
};