mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 14:53:50 +02:00
getFriendLogHistoryForUserId
This commit is contained in:
@@ -356,8 +356,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="currentUser.id !== userDialog.id" class="x-friend-item" style="cursor: default">
|
<div v-if="currentUser.id !== userDialog.id" class="x-friend-item" style="cursor: default">
|
||||||
<TooltipWrapper side="top" :disabled="!userDialog.dateFriendedInfo.length">
|
<TooltipWrapper side="top">
|
||||||
<template v-if="userDialog.dateFriendedInfo.length" #content>
|
<template #content>
|
||||||
<template v-for="ref in userDialog.dateFriendedInfo" :key="ref.type">
|
<template v-for="ref in userDialog.dateFriendedInfo" :key="ref.type">
|
||||||
<span>{{ ref.type }}: {{ formatDateFilter(ref.created_at, 'long') }}</span
|
<span>{{ ref.type }}: {{ formatDateFilter(ref.created_at, 'long') }}</span
|
||||||
><br />
|
><br />
|
||||||
@@ -1309,11 +1309,11 @@
|
|||||||
import { userDialogGroupSortingOptions, userDialogMutualFriendSortingOptions } from '../../../shared/constants';
|
import { userDialogGroupSortingOptions, userDialogMutualFriendSortingOptions } from '../../../shared/constants';
|
||||||
import { userDialogWorldOrderOptions, userDialogWorldSortingOptions } from '../../../shared/constants/';
|
import { userDialogWorldOrderOptions, userDialogWorldSortingOptions } from '../../../shared/constants/';
|
||||||
import { database } from '../../../service/database';
|
import { database } from '../../../service/database';
|
||||||
|
import { formatJsonVars } from '../../../shared/utils/base/ui';
|
||||||
|
|
||||||
import InstanceActionBar from '../../InstanceActionBar.vue';
|
import InstanceActionBar from '../../InstanceActionBar.vue';
|
||||||
import SendInviteDialog from '../InviteDialog/SendInviteDialog.vue';
|
import SendInviteDialog from '../InviteDialog/SendInviteDialog.vue';
|
||||||
import UserSummaryHeader from './UserSummaryHeader.vue';
|
import UserSummaryHeader from './UserSummaryHeader.vue';
|
||||||
import { formatJsonVars } from '../../../shared/utils/base/ui';
|
|
||||||
|
|
||||||
const BioDialog = defineAsyncComponent(() => import('./BioDialog.vue'));
|
const BioDialog = defineAsyncComponent(() => import('./BioDialog.vue'));
|
||||||
const LanguageDialog = defineAsyncComponent(() => import('./LanguageDialog.vue'));
|
const LanguageDialog = defineAsyncComponent(() => import('./LanguageDialog.vue'));
|
||||||
|
|||||||
@@ -83,6 +83,39 @@ const friendLogHistory = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async getFriendLogHistoryForUserId(userId, types) {
|
||||||
|
let friendLogHistory = [];
|
||||||
|
let typeFilter = '';
|
||||||
|
if (types && types.length > 0) {
|
||||||
|
const escapedTypes = types.map((t) => `'${t.replace(/'/g, "''")}'`);
|
||||||
|
typeFilter = ` AND type IN (${escapedTypes.join(', ')})`;
|
||||||
|
}
|
||||||
|
await sqliteService.execute(
|
||||||
|
(dbRow) => {
|
||||||
|
const row = {
|
||||||
|
rowId: dbRow[0],
|
||||||
|
created_at: dbRow[1],
|
||||||
|
type: dbRow[2],
|
||||||
|
userId: dbRow[3],
|
||||||
|
displayName: dbRow[4],
|
||||||
|
friendNumber: dbRow[8]
|
||||||
|
};
|
||||||
|
if (row.type === 'DisplayName') {
|
||||||
|
row.previousDisplayName = dbRow[5];
|
||||||
|
} else if (row.type === 'TrustLevel') {
|
||||||
|
row.trustLevel = dbRow[6];
|
||||||
|
row.previousTrustLevel = dbRow[7];
|
||||||
|
}
|
||||||
|
friendLogHistory.push(row);
|
||||||
|
},
|
||||||
|
`SELECT * FROM ${dbVars.userPrefix}_friend_log_history WHERE user_id = @user_id${typeFilter}`,
|
||||||
|
{
|
||||||
|
'@user_id': userId
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return friendLogHistory;
|
||||||
|
},
|
||||||
|
|
||||||
deleteFriendLogHistory(rowId) {
|
deleteFriendLogHistory(rowId) {
|
||||||
sqliteService.executeNonQuery(
|
sqliteService.executeNonQuery(
|
||||||
`DELETE FROM ${dbVars.userPrefix}_friend_log_history WHERE id = @row_id`,
|
`DELETE FROM ${dbVars.userPrefix}_friend_log_history WHERE id = @row_id`,
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ export const useFriendStore = defineStore('Friend', () => {
|
|||||||
|
|
||||||
const isRefreshFriendsLoading = ref(false);
|
const isRefreshFriendsLoading = ref(false);
|
||||||
const onlineFriendCount = ref(0);
|
const onlineFriendCount = ref(0);
|
||||||
const isFriendLogLoaded = ref(false);
|
|
||||||
|
|
||||||
const pendingOfflineDelay = 170000;
|
const pendingOfflineDelay = 170000;
|
||||||
let pendingOfflineWorker = null;
|
let pendingOfflineWorker = null;
|
||||||
@@ -1286,7 +1285,6 @@ export const useFriendStore = defineStore('Friend', () => {
|
|||||||
friendLogTable.value.loading = true;
|
friendLogTable.value.loading = true;
|
||||||
friendLogTable.value.data = await database.getFriendLogHistory();
|
friendLogTable.value.data = await database.getFriendLogHistory();
|
||||||
friendLogTable.value.loading = false;
|
friendLogTable.value.loading = false;
|
||||||
isFriendLogLoaded.value = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1658,7 +1656,6 @@ export const useFriendStore = defineStore('Friend', () => {
|
|||||||
onlineFriendCount,
|
onlineFriendCount,
|
||||||
friendLog,
|
friendLog,
|
||||||
friendLogTable,
|
friendLogTable,
|
||||||
isFriendLogLoaded,
|
|
||||||
|
|
||||||
initFriendsList,
|
initFriendsList,
|
||||||
updateLocalFavoriteFriends,
|
updateLocalFavoriteFriends,
|
||||||
|
|||||||
@@ -911,52 +911,57 @@ export const useUserStore = defineStore('User', () => {
|
|||||||
}
|
}
|
||||||
const displayNameMap =
|
const displayNameMap =
|
||||||
ref1.previousDisplayNames;
|
ref1.previousDisplayNames;
|
||||||
if (!friendStore.isFriendLogLoaded) {
|
const userNotifications =
|
||||||
await friendStore.initFriendLogHistoryTable();
|
await database.getFriendLogHistoryForUserId(
|
||||||
}
|
D.id,
|
||||||
friendStore.friendLogTable.data.forEach(
|
[
|
||||||
(ref2) => {
|
'DisplayName',
|
||||||
if (ref2.userId === D.id) {
|
'Friend',
|
||||||
|
'Unfriend'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
for (const notification of userNotifications) {
|
||||||
|
if (notification.userId !== D.id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
notification.type === 'DisplayName'
|
||||||
|
) {
|
||||||
|
displayNameMap.set(
|
||||||
|
notification.previousDisplayName,
|
||||||
|
notification.created_at
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (!D.dateFriended) {
|
||||||
|
if (
|
||||||
|
notification.type === 'Unfriend'
|
||||||
|
) {
|
||||||
|
D.unFriended = true;
|
||||||
if (
|
if (
|
||||||
ref2.type === 'DisplayName'
|
!appearanceSettingsStore.hideUnfriends
|
||||||
) {
|
) {
|
||||||
displayNameMap.set(
|
D.dateFriended =
|
||||||
ref2.previousDisplayName,
|
notification.created_at;
|
||||||
ref2.created_at
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (!D.dateFriended) {
|
|
||||||
if (
|
|
||||||
ref2.type === 'Unfriend'
|
|
||||||
) {
|
|
||||||
D.unFriended = true;
|
|
||||||
if (
|
|
||||||
!appearanceSettingsStore.hideUnfriends
|
|
||||||
) {
|
|
||||||
D.dateFriended =
|
|
||||||
ref2.created_at;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
ref2.type === 'Friend'
|
|
||||||
) {
|
|
||||||
D.unFriended = false;
|
|
||||||
D.dateFriended =
|
|
||||||
ref2.created_at;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
ref2.type === 'Friend' ||
|
|
||||||
(ref2.type === 'Unfriend' &&
|
|
||||||
!appearanceSettingsStore.hideUnfriends)
|
|
||||||
) {
|
|
||||||
D.dateFriendedInfo.push(
|
|
||||||
ref2
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
notification.type === 'Friend'
|
||||||
|
) {
|
||||||
|
D.unFriended = false;
|
||||||
|
D.dateFriended =
|
||||||
|
notification.created_at;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
if (
|
||||||
|
notification.type === 'Friend' ||
|
||||||
|
(notification.type === 'Unfriend' &&
|
||||||
|
!appearanceSettingsStore.hideUnfriends)
|
||||||
|
) {
|
||||||
|
D.dateFriendedInfo.push(
|
||||||
|
notification
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
displayNameMap.forEach(
|
displayNameMap.forEach(
|
||||||
(updated_at, displayName) => {
|
(updated_at, displayName) => {
|
||||||
D.previousDisplayNames.push({
|
D.previousDisplayNames.push({
|
||||||
|
|||||||
Reference in New Issue
Block a user