pinning topics work as expected

This commit is contained in:
or-else
2025-09-23 17:08:34 +03:00
parent 4818ee7a25
commit 5faacc1f53
14 changed files with 97 additions and 70 deletions
-1
View File
@@ -32,7 +32,6 @@ export default class AccGeneralView extends React.PureComponent {
}
handleSendOnEnterSelected(e) {
console.log('handleSendOnEnterSelected', e.currentTarget.value);
this.setState({sendOnEnter: e.currentTarget.value});
this.props.onSendOnEnterChanged(e.currentTarget.value);
}
+40 -26
View File
@@ -843,29 +843,37 @@ class TinodeWeb extends React.Component {
}
tnMeMetaDesc(desc) {
if (desc) {
if (desc.public) {
this.setState({
sidePanelTitle: desc.public.fn,
sidePanelAvatar: makeImageUrl(desc.public.photo)
});
}
if (desc.trusted) {
const badges = [];
for (const [key, val] of Object.entries(desc.trusted)) {
if (val) {
badges.push(key);
}
if (!desc) {
return;
}
if (desc.public) {
this.setState({
sidePanelTitle: desc.public.fn,
sidePanelAvatar: makeImageUrl(desc.public.photo)
});
}
if (desc.trusted) {
const badges = [];
for (const [key, val] of Object.entries(desc.trusted)) {
if (val) {
badges.push(key);
}
this.setState({
myTrustedBadges: badges,
});
}
if (desc.acs) {
this.setState({
incognitoMode: !desc.acs.isPresencer()
});
}
this.setState({
myTrustedBadges: badges,
});
}
if (desc.acs) {
this.setState({
incognitoMode: !desc.acs.isPresencer()
});
}
if (TinodeWeb.checkIfPinsUpdated(desc, this.state.chatList)) {
this.resetContactList();
}
}
@@ -985,15 +993,21 @@ class TinodeWeb extends React.Component {
return pins != 0 ? pins : (b.touched || past).getTime() - (a.touched || past).getTime();
});
newState.chatList.forEach(c => {
console.log("sorted:", c.topic, me.pinnedTopicRank(c.topic));
});
// Merge search results and chat list.
newState.searchableContacts = TinodeWeb.prepareSearchableContacts(newState.chatList, this.state.searchResults);
this.setState(newState);
}
static checkIfPinsUpdated(me, chatList) {
for (let i = 0; i < chatList.length; i++) {
const c = chatList[i];
if (!!me.pinnedTopicRank(c.topic) != c.pinned) {
return true;
}
}
return false;
}
/* Fnd topic: find contacts by tokens */
tnInitFind() {
const fnd = this.tinode.getFndTopic();
@@ -1690,7 +1704,7 @@ class TinodeWeb extends React.Component {
subscribed && deleter && !self ? 'messages_clear_hard' : null,
self ? null : (muted ? (blocked ? null : 'topic_unmute') : 'topic_mute'),
self ? null : (self_blocked ? 'topic_unblock' : 'topic_block'),
subscribed ? (pinned ? 'topic_unpin' : 'topic_pin') : null,
pinned ? 'topic_unpin' : 'topic_pin',
archived ? 'topic_restore' : 'topic_archive',
'topic_delete'
];
+1
View File
@@ -132,6 +132,7 @@ class ContactList extends React.Component {
badges={badges}
showCheckmark={showCheckmark}
selected={selected}
pinned={c.pinned}
showOnline={this.props.showOnline && !isChannel}
isChannel={isChannel}
isGroup={isGroup}
+1 -1
View File
@@ -117,7 +117,7 @@ class Contact extends React.Component {
const comment = preview || this.props.comment ||
(self ? this.props.intl.formatMessage(messages.self_topic_comment) : '\u00A0');
const bgColor = this.props.showCheckmark ? null :
(this.props.selected ? 'selected' : (this.props.pinned ? 'pinned' : null));
(this.props.selected ? 'selected' : (this.props.pinned ? 'tpinned' : null));
return (
<li className={bgColor} onClick={this.handleClick}>
<div className="avatar-box">