geo distance meter
This commit is contained in:
@@ -137,6 +137,11 @@ export class CallbackHandlers {
|
||||
console.log(`User ${telegramId} confirmed city edit: ${editState.tempCity}`);
|
||||
// Обновляем город в профиле
|
||||
await this.messageHandlers.updateProfileField(telegramId, 'city', editState.tempCity);
|
||||
// Обновляем координаты, если они есть
|
||||
if (editState.tempLocation) {
|
||||
console.log(`User ${telegramId} updating location: lat=${editState.tempLocation.latitude}, lon=${editState.tempLocation.longitude}`);
|
||||
await this.messageHandlers.updateProfileField(telegramId, 'location', editState.tempLocation);
|
||||
}
|
||||
// Очищаем состояние
|
||||
this.messageHandlers.clearProfileEditState(telegramId);
|
||||
// Убираем inline-кнопки
|
||||
@@ -1061,7 +1066,20 @@ export class CallbackHandlers {
|
||||
const mainPhotoFileId = profile.photos[0]; // Первое фото - главное
|
||||
|
||||
let profileText = '👤 ' + profile.name + ', ' + profile.age + '\n';
|
||||
profileText += '📍 ' + (profile.city || 'Не указан') + '\n';
|
||||
profileText += '📍 ' + (profile.city || 'Не указан');
|
||||
|
||||
// Добавляем расстояние, если это не владелец профиля и есть viewerId
|
||||
if (!isOwner && viewerId) {
|
||||
const viewerProfile = await this.profileService.getProfileByTelegramId(viewerId);
|
||||
if (viewerProfile && viewerProfile.location && profile.location) {
|
||||
const distance = viewerProfile.getDistanceTo(profile);
|
||||
if (distance !== null) {
|
||||
profileText += ` (${Math.round(distance)} км)`;
|
||||
}
|
||||
}
|
||||
}
|
||||
profileText += '\n';
|
||||
|
||||
if (profile.job) profileText += '💼 ' + profile.job + '\n';
|
||||
if (profile.education) profileText += '🎓 ' + profile.education + '\n';
|
||||
if (profile.height) profileText += '📏 ' + profile.height + ' см\n';
|
||||
@@ -1204,8 +1222,21 @@ export class CallbackHandlers {
|
||||
|
||||
const candidatePhotoFileId = candidate.photos[0]; // Первое фото - главное
|
||||
|
||||
// Получаем профиль текущего пользователя для вычисления расстояния
|
||||
const userProfile = await this.profileService.getProfileByTelegramId(telegramId);
|
||||
|
||||
let candidateText = candidate.name + ', ' + candidate.age + '\n';
|
||||
candidateText += '📍 ' + (candidate.city || 'Не указан') + '\n';
|
||||
candidateText += '📍 ' + (candidate.city || 'Не указан');
|
||||
|
||||
// Добавляем расстояние, если есть координаты у обоих пользователей
|
||||
if (userProfile && userProfile.location && candidate.location) {
|
||||
const distance = userProfile.getDistanceTo(candidate);
|
||||
if (distance !== null) {
|
||||
candidateText += ` (${Math.round(distance)} км)`;
|
||||
}
|
||||
}
|
||||
candidateText += '\n';
|
||||
|
||||
if (candidate.job) candidateText += '💼 ' + candidate.job + '\n';
|
||||
if (candidate.education) candidateText += '🎓 ' + candidate.education + '\n';
|
||||
if (candidate.height) candidateText += '📏 ' + candidate.height + ' см\n';
|
||||
|
||||
Reference in New Issue
Block a user