SHA256
Отключить мультиаккаунтность и уточнить статусы профиля
This commit is contained in:
+7
-44
@@ -40,9 +40,6 @@ import {
|
||||
addAppLogEntry,
|
||||
authorizeSession,
|
||||
hydrateMessagesFromStore,
|
||||
getSavedProfiles,
|
||||
closeSavedProfile,
|
||||
switchToSavedProfile,
|
||||
isSessionInvalidError,
|
||||
refreshSessions,
|
||||
setSessionAuthorizedHandler,
|
||||
@@ -125,7 +122,6 @@ import * as chatMediaView from './pages/chat-media-view.js';
|
||||
import { isDmChatMuted } from './services/dm-chat-prefs.js';
|
||||
import { getDevicePref } from './services/device-prefs.js';
|
||||
import { isDeveloperToolsEnabled } from './services/feature-settings.js';
|
||||
import { confirmDialog } from './components/confirm-dialog.js';
|
||||
import * as userProfileView from './pages/user-profile-view.js?v=20261110-pwa-avatar';
|
||||
import * as userProfileListView from './pages/user-profile-list-view.js';
|
||||
import * as userRelationManageView from './pages/user-relation-manage-view.js';
|
||||
@@ -967,41 +963,13 @@ function pushTargetPath(payload = {}) {
|
||||
return '/profile';
|
||||
}
|
||||
|
||||
function savedProfileExists(login) {
|
||||
const normalized = String(login || '').trim().toLowerCase();
|
||||
if (!normalized) return false;
|
||||
return getSavedProfiles().some((item) => String(item.login || '').trim().toLowerCase() === normalized);
|
||||
}
|
||||
|
||||
async function ensurePushTargetProfile(payload = {}, { action = '' } = {}) {
|
||||
// Multi-profile switching is disabled; never open a notification for another login.
|
||||
async function ensurePushTargetProfile(payload = {}) {
|
||||
const targetLogin = pushTargetLogin(payload);
|
||||
const currentLogin = String(state.session.login || '').trim();
|
||||
if (!targetLogin || targetLogin.toLowerCase() === currentLogin.toLowerCase()) return true;
|
||||
if (!savedProfileExists(targetLogin)) {
|
||||
showToast(t('remaining.app.a_notification_was_sent_to_profile_login_which_is_not_sav', { login: targetLogin }), { kind: 'info' });
|
||||
return false;
|
||||
}
|
||||
|
||||
const kind = String(payload?.kind || '').trim();
|
||||
const question = kind === 'incoming_call'
|
||||
? t('remaining.app.incoming_call_for_profile_login_switch_to_this_profile', { login: targetLogin })
|
||||
: t('remaining.app.this_message_was_sent_to_profile_login_switch_profiles_to', { login: targetLogin });
|
||||
const confirmed = await confirmDialog({ title: t('remaining.app.switch_profile'), text: question, confirmLabel: t('remaining.app.switch') });
|
||||
if (!confirmed) return false;
|
||||
|
||||
try {
|
||||
await switchToSavedProfile(targetLogin);
|
||||
if (action === 'accept' || action === 'decline') {
|
||||
savePendingCallPushAction(action, payload);
|
||||
window.location.assign(pushTargetPath(payload));
|
||||
} else {
|
||||
window.location.assign(pushTargetPath(payload));
|
||||
}
|
||||
return false;
|
||||
} catch (error) {
|
||||
showToast(toUserMessage(error, t('remaining.app.could_not_switch_profile')), { kind: 'error' });
|
||||
return false;
|
||||
}
|
||||
showToast(t('screens.registration_identity.other_profile_notification'), { kind: 'info' });
|
||||
return false;
|
||||
}
|
||||
|
||||
async function handleNotificationClick(payload = {}) {
|
||||
@@ -1544,7 +1512,7 @@ function renderApp() {
|
||||
return;
|
||||
}
|
||||
|
||||
const addingProfile = state.session.isAuthorized && String(state.authReturnHash || '').trim() === '/profiles';
|
||||
const addingProfile = false; // Multi-profile mode temporarily disabled.
|
||||
if (state.session.isAuthorized && PRE_AUTH_PAGES.includes(pageId) && !addingProfile) {
|
||||
navigate('messages-list');
|
||||
return;
|
||||
@@ -1638,11 +1606,6 @@ async function tryAutoLogin() {
|
||||
} catch {}
|
||||
} catch (error) {
|
||||
if (isSessionInvalidError(error)) {
|
||||
const result = await closeSavedProfile(state.session.login);
|
||||
if (result?.nextProfile) {
|
||||
window.location.assign('/profile');
|
||||
return;
|
||||
}
|
||||
await terminateCurrentSession({
|
||||
infoMessage: t('remaining.app.this_session_has_ended_on_this_device_please_sign_in_agai'),
|
||||
});
|
||||
@@ -1794,8 +1757,8 @@ async function init() {
|
||||
}
|
||||
|
||||
authService.onEvent('SessionRevoked', async () => {
|
||||
const result = await closeSavedProfile(state.session.login);
|
||||
window.location.assign(result?.nextProfile ? '/profile' : '/start');
|
||||
await terminateCurrentSession({ notifySessionReset: false });
|
||||
window.location.assign('/start');
|
||||
});
|
||||
|
||||
authService.onEvent('ForceUiReload', async (evt) => {
|
||||
|
||||
Reference in New Issue
Block a user