Skip to content

Commit b487b8d

Browse files
committed
Merge follow-up
1 parent 17772fc commit b487b8d

File tree

4 files changed

+57
-25
lines changed

4 files changed

+57
-25
lines changed

src/components/peerProfile.tsx

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ import {makeMediaSize} from '../helpers/mediaSize';
3535
import type {MyStarGift} from '../lib/appManagers/appGiftsManager';
3636
import IS_PARALLAX_SUPPORTED from '../environment/parallaxSupport';
3737
import {generateDelimiter} from './generateDelimiter';
38+
import {attachClickEvent} from '../helpers/dom/clickEvent';
39+
import ListenerSetter from '../helpers/listenerSetter';
3840

3941
type PeerProfileContextValue = {
4042
peerId: PeerId,
@@ -49,6 +51,8 @@ type PeerProfileContextValue = {
4951
canBeDetailed: () => boolean,
5052
isSavedDialog: boolean,
5153
isTopic: boolean,
54+
isBotforum: boolean,
55+
needSimpleAvatar: boolean,
5256
getDetailsForUse: () => {peerId: PeerId, threadId?: number},
5357
verifyContext: (peerId: PeerId, threadId?: number) => boolean,
5458
};
@@ -110,7 +114,13 @@ const PeerProfile = (props: {
110114
},
111115
isSavedDialog: !!(props.peerId === rootScope.myId && props.threadId),
112116
get isTopic() {
113-
return !!(props.threadId && (value.peer as Chat.channel).pFlags.forum);
117+
return !!(props.threadId && ((value.peer as Chat.channel).pFlags.forum || value.isBotforum));
118+
},
119+
get isBotforum() {
120+
return !!(value.peer as User.user).pFlags.bot_forum_view;
121+
},
122+
get needSimpleAvatar() {
123+
return value.isTopic;
114124
},
115125
canBeDetailed: () => value.peerId !== rootScope.myId || !value.isDialog,
116126
getDetailsForUse: () => {
@@ -165,7 +175,7 @@ const PeerProfile = (props: {
165175
value.peerId === rootScope.myId && 'is-me'
166176
)}
167177
>
168-
<Show when={!value.isTopic}>
178+
<Show when={!value.needSimpleAvatar}>
169179
<PeerProfile.AutoAvatar />
170180
</Show>
171181
<Show when={props.changeAvatarBtn}>
@@ -192,7 +202,7 @@ PeerProfile.Avatar = () => {
192202
const name = (<PeerProfile.Name />) as HTMLElement;
193203
const subtitle = (<PeerProfile.Subtitle />) as HTMLElement;
194204

195-
if(!context.isTopic) {
205+
if(!context.needSimpleAvatar) {
196206
const avatars = new PeerProfileAvatars(
197207
context.scrollable,
198208
rootScope.managers,
@@ -330,17 +340,24 @@ PeerProfile.SubtitleStatus = () => {
330340
}
331341

332342
const {peerId, isDialog} = context;
333-
334-
const isForum = !!(context.peer as Chat.channel).pFlags.forum;
335343
const middleware = createMiddleware().get();
336-
if(isForum && context.threadId) {
344+
if(context.isTopic) {
337345
const [element] = createResource(() => {
346+
const listenerSetter = new ListenerSetter();
347+
onCleanup(() => listenerSetter.removeAll());
338348
return wrapTopicNameButton({
339349
peerId,
350+
withIcons: false,
351+
noAvatarAndLink: true,
340352
wrapOptions: {
341353
middleware
342354
}
343-
}).then(({element}) => element);
355+
}).then(({element}) => {
356+
attachClickEvent(element, (e) => {
357+
appImManager.setPeer({peerId});
358+
}, {listenerSetter});
359+
return element;
360+
});
344361
});
345362

346363
return (
@@ -1071,19 +1088,21 @@ PeerProfile.MainSection = () => {
10711088
return (
10721089
<Section
10731090
noDelimiter
1074-
contentProps={{class: classNames(context.isTopic && 'has-simple-avatar')}}
1091+
contentProps={{class: classNames(context.needSimpleAvatar && 'has-simple-avatar')}}
10751092
>
1076-
<Show when={context.isTopic}>
1093+
<Show when={context.needSimpleAvatar}>
10771094
<PeerProfile.AutoAvatar />
10781095
</Show>
1079-
<PeerProfile.Phone />
1080-
<PeerProfile.Username />
1081-
<PeerProfile.Location />
1082-
<PeerProfile.Bio />
1083-
<PeerProfile.Link />
1084-
<PeerProfile.BusinessHours />
1085-
<PeerProfile.BusinessLocation />
1086-
<PeerProfile.Notifications />
1096+
<Show when={!(context.isBotforum && context.threadId)}>
1097+
<PeerProfile.Phone />
1098+
<PeerProfile.Username />
1099+
<PeerProfile.Location />
1100+
<PeerProfile.Bio />
1101+
<PeerProfile.Link />
1102+
<PeerProfile.BusinessHours />
1103+
<PeerProfile.BusinessLocation />
1104+
<PeerProfile.Notifications />
1105+
</Show>
10871106
</Section>
10881107
);
10891108
};

src/lib/appManagers/appMessagesManager.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6172,7 +6172,8 @@ export class AppMessagesManager extends AppManager {
61726172
'readMaxId',
61736173
'readOutboxMaxId',
61746174
'maxOutId',
6175-
'replyMarkup'
6175+
'replyMarkup',
6176+
'key'
61766177
]);
61776178

61786179
// * using proxy to catch only outside calls
@@ -6186,7 +6187,10 @@ export class AppMessagesManager extends AppManager {
61866187

61876188
MTProtoMessagePort.getInstance<false>().invokeVoid('mirror', {
61886189
name: 'historyStorage',
6189-
key: joinDeepPath(historyStorage.key, prop),
6190+
key: joinDeepPath(
6191+
prop === 'key' ? oldValue : historyStorage.key,
6192+
prop
6193+
),
61906194
value,
61916195
accountNumber: this.getAccountNumber()
61926196
});
@@ -6494,18 +6498,19 @@ export class AppMessagesManager extends AppManager {
64946498
title_missing: true
64956499
});
64966500

6501+
if(updates._ === 'updates') {
6502+
const messageIdUpdate = updates.updates.find((update) => update._ === 'updateMessageID');
6503+
if(messageIdUpdate) {
6504+
pendingTopic.newId = this.appMessagesIdsManager.generateMessageId(messageIdUpdate.id);
6505+
}
6506+
}
64976507

64986508
const temporaryStorage = this.getHistoryStorage(peerId, pendingTopic.tempId);
64996509
temporaryStorage.key = getHistoryStorageKey({type: 'replies', peerId, threadId: pendingTopic.newId});
65006510
(this.threadsStorage[peerId] ??= {})[pendingTopic.newId] = temporaryStorage;
65016511

65026512
this.apiUpdatesManager.processUpdateMessage(updates);
65036513

6504-
if(updates._ === 'updates') {
6505-
const messageIdUpdate = updates.updates.find(update => update._ === 'updateMessageID');
6506-
if(messageIdUpdate) pendingTopic.newId = messageIdUpdate.id;
6507-
}
6508-
65096514
await this.dialogsStorage.getForumTopicById(peerId, pendingTopic.newId);
65106515
this.rootScope.dispatchEvent('botforum_pending_topic_created', {peerId, tempId, newId: pendingTopic.newId});
65116516

src/lib/mtproto/mtprotoworker.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import DeferredIsUsingPasscode from '../passcode/deferredIsUsingPasscode';
6363
import CacheStorageController from '../files/cacheStorage';
6464
import type {PushSingleManager} from './pushSingleManager';
6565
import getDeepProperty from '../../helpers/object/getDeepProperty';
66-
import {_deleteHistoryStorage, _useHistoryStorage} from '../../stores/historyStorages';
66+
import {_changeHistoryStorageKey, _deleteHistoryStorage, _useHistoryStorage} from '../../stores/historyStorages';
6767
import SlicedArray, {SliceEnd} from '../../helpers/slicedArray';
6868
import {createHistoryStorageSearchSlicedArray} from '../appManagers/utils/messages/createHistoryStorage';
6969

@@ -269,6 +269,9 @@ class ApiManagerProxy extends MTProtoMessagePort {
269269
readOutboxMaxId: undefined,
270270
triedToReadMaxId: undefined
271271
});
272+
} else if(property === 'key') {
273+
_changeHistoryStorageKey(historyStorageKey as any, payload.value);
274+
setHistoryStorage('key', payload.value);
272275
} else if(property === 'slices') {
273276
// @ts-ignore
274277
(historyStorage.searchHistory || historyStorage.history).slices[+smth1][smth2](...payload.value);

src/stores/historyStorages.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,9 @@ export function _deleteHistoryStorage(key: HistoryStorageKey) {
2020
delete cache[key];
2121
}
2222

23+
export function _changeHistoryStorageKey(key: HistoryStorageKey, newKey: HistoryStorageKey) {
24+
cache[newKey] = cache[key];
25+
delete cache[key];
26+
}
27+
2328
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.historyStorages = cache);

0 commit comments

Comments
 (0)