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
+2 -2
View File
@@ -1319,8 +1319,8 @@ i.search {
.contact-box > li.selected { .contact-box > li.selected {
background-color: var(--clr-background-blue-gray-100); /* blue-gray 100 highlight */ background-color: var(--clr-background-blue-gray-100); /* blue-gray 100 highlight */
} }
.contact-box > li.pinned { .contact-box > li.tpinned {
background-color: var(--clr-background-blue-gray-100); /* blue-gray 100 highlight */ background-color: var(--clr-background-blue-gray-75); /* blue-gray 75 highlight */
} }
.contact-box > li.action { .contact-box > li.action {
min-height: 2.5rem; min-height: 2.5rem;
+1 -1
View File
File diff suppressed because one or more lines are too long
-1
View File
@@ -32,7 +32,6 @@ export default class AccGeneralView extends React.PureComponent {
} }
handleSendOnEnterSelected(e) { handleSendOnEnterSelected(e) {
console.log('handleSendOnEnterSelected', e.currentTarget.value);
this.setState({sendOnEnter: e.currentTarget.value}); this.setState({sendOnEnter: e.currentTarget.value});
this.props.onSendOnEnterChanged(e.currentTarget.value); this.props.onSendOnEnterChanged(e.currentTarget.value);
} }
+20 -6
View File
@@ -843,13 +843,17 @@ class TinodeWeb extends React.Component {
} }
tnMeMetaDesc(desc) { tnMeMetaDesc(desc) {
if (desc) { if (!desc) {
return;
}
if (desc.public) { if (desc.public) {
this.setState({ this.setState({
sidePanelTitle: desc.public.fn, sidePanelTitle: desc.public.fn,
sidePanelAvatar: makeImageUrl(desc.public.photo) sidePanelAvatar: makeImageUrl(desc.public.photo)
}); });
} }
if (desc.trusted) { if (desc.trusted) {
const badges = []; const badges = [];
for (const [key, val] of Object.entries(desc.trusted)) { for (const [key, val] of Object.entries(desc.trusted)) {
@@ -861,11 +865,15 @@ class TinodeWeb extends React.Component {
myTrustedBadges: badges, myTrustedBadges: badges,
}); });
} }
if (desc.acs) { if (desc.acs) {
this.setState({ this.setState({
incognitoMode: !desc.acs.isPresencer() 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(); 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. // Merge search results and chat list.
newState.searchableContacts = TinodeWeb.prepareSearchableContacts(newState.chatList, this.state.searchResults); newState.searchableContacts = TinodeWeb.prepareSearchableContacts(newState.chatList, this.state.searchResults);
this.setState(newState); 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 */ /* Fnd topic: find contacts by tokens */
tnInitFind() { tnInitFind() {
const fnd = this.tinode.getFndTopic(); const fnd = this.tinode.getFndTopic();
@@ -1690,7 +1704,7 @@ class TinodeWeb extends React.Component {
subscribed && deleter && !self ? 'messages_clear_hard' : null, subscribed && deleter && !self ? 'messages_clear_hard' : null,
self ? null : (muted ? (blocked ? null : 'topic_unmute') : 'topic_mute'), self ? null : (muted ? (blocked ? null : 'topic_unmute') : 'topic_mute'),
self ? null : (self_blocked ? 'topic_unblock' : 'topic_block'), 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', archived ? 'topic_restore' : 'topic_archive',
'topic_delete' 'topic_delete'
]; ];
+1
View File
@@ -132,6 +132,7 @@ class ContactList extends React.Component {
badges={badges} badges={badges}
showCheckmark={showCheckmark} showCheckmark={showCheckmark}
selected={selected} selected={selected}
pinned={c.pinned}
showOnline={this.props.showOnline && !isChannel} showOnline={this.props.showOnline && !isChannel}
isChannel={isChannel} isChannel={isChannel}
isGroup={isGroup} isGroup={isGroup}
+1 -1
View File
@@ -117,7 +117,7 @@ class Contact extends React.Component {
const comment = preview || this.props.comment || const comment = preview || this.props.comment ||
(self ? this.props.intl.formatMessage(messages.self_topic_comment) : '\u00A0'); (self ? this.props.intl.formatMessage(messages.self_topic_comment) : '\u00A0');
const bgColor = this.props.showCheckmark ? null : 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 ( return (
<li className={bgColor} onClick={this.handleClick}> <li className={bgColor} onClick={this.handleClick}>
<div className="avatar-box"> <div className="avatar-box">
+17 -7
View File
@@ -8714,7 +8714,6 @@ class AccGeneralView extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureC
this.props.onTextSizeChanged(e.currentTarget.value / 10 | 0); this.props.onTextSizeChanged(e.currentTarget.value / 10 | 0);
} }
handleSendOnEnterSelected(e) { handleSendOnEnterSelected(e) {
console.log('handleSendOnEnterSelected', e.currentTarget.value);
this.setState({ this.setState({
sendOnEnter: e.currentTarget.value sendOnEnter: e.currentTarget.value
}); });
@@ -12580,7 +12579,9 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
_lib_navigation_js__WEBPACK_IMPORTED_MODULE_17__["default"].navigateTo(urlHash); _lib_navigation_js__WEBPACK_IMPORTED_MODULE_17__["default"].navigateTo(urlHash);
} }
tnMeMetaDesc(desc) { tnMeMetaDesc(desc) {
if (desc) { if (!desc) {
return;
}
if (desc.public) { if (desc.public) {
this.setState({ this.setState({
sidePanelTitle: desc.public.fn, sidePanelTitle: desc.public.fn,
@@ -12603,6 +12604,8 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
incognitoMode: !desc.acs.isPresencer() incognitoMode: !desc.acs.isPresencer()
}); });
} }
if (TinodeWeb.checkIfPinsUpdated(desc, this.state.chatList)) {
this.resetContactList();
} }
} }
tnMeContactUpdate(what, cont) { tnMeContactUpdate(what, cont) {
@@ -12685,12 +12688,18 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
const pins = me.pinnedTopicRank(b.topic) - me.pinnedTopicRank(a.topic); const pins = me.pinnedTopicRank(b.topic) - me.pinnedTopicRank(a.topic);
return pins != 0 ? pins : (b.touched || past).getTime() - (a.touched || past).getTime(); 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));
});
newState.searchableContacts = TinodeWeb.prepareSearchableContacts(newState.chatList, this.state.searchResults); newState.searchableContacts = TinodeWeb.prepareSearchableContacts(newState.chatList, this.state.searchResults);
this.setState(newState); 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;
}
tnInitFind() { tnInitFind() {
const fnd = this.tinode.getFndTopic(); const fnd = this.tinode.getFndTopic();
fnd.onSubsUpdated = this.tnFndSubsUpdated; fnd.onSubsUpdated = this.tnFndSubsUpdated;
@@ -13330,7 +13339,7 @@ class TinodeWeb extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component)
} : null, subscribed && p2p && webrtc ? { } : null, subscribed && p2p && webrtc ? {
title: this.props.intl.formatMessage(messages.menu_item_video_call), title: this.props.intl.formatMessage(messages.menu_item_video_call),
handler: this.handleStartVideoCall handler: this.handleStartVideoCall
} : null, subscribed ? 'messages_clear' : null, 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, archived ? 'topic_restore' : 'topic_archive', 'topic_delete']; } : null, subscribed ? 'messages_clear' : null, subscribed && deleter && !self ? 'messages_clear_hard' : null, self ? null : muted ? blocked ? null : 'topic_unmute' : 'topic_mute', self ? null : self_blocked ? 'topic_unblock' : 'topic_block', pinned ? 'topic_unpin' : 'topic_pin', archived ? 'topic_restore' : 'topic_archive', 'topic_delete'];
} }
handleHideContextMenu() { handleHideContextMenu() {
this.setState({ this.setState({
@@ -16413,6 +16422,7 @@ class ContactList extends (react__WEBPACK_IMPORTED_MODULE_0___default().Componen
badges: badges, badges: badges,
showCheckmark: showCheckmark, showCheckmark: showCheckmark,
selected: selected, selected: selected,
pinned: c.pinned,
showOnline: this.props.showOnline && !isChannel, showOnline: this.props.showOnline && !isChannel,
isChannel: isChannel, isChannel: isChannel,
isGroup: isGroup, isGroup: isGroup,
@@ -16600,7 +16610,7 @@ class Contact extends (react__WEBPACK_IMPORTED_MODULE_0___default().Component) {
}, icon.name) : null; }, icon.name) : null;
const titleClass = 'contact-title' + (this.props.deleted ? ' deleted' : ''); const titleClass = 'contact-title' + (this.props.deleted ? ' deleted' : '');
const comment = preview || this.props.comment || (self ? this.props.intl.formatMessage(messages.self_topic_comment) : '\u00A0'); 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; const bgColor = this.props.showCheckmark ? null : this.props.selected ? 'selected' : this.props.pinned ? 'tpinned' : null;
return react__WEBPACK_IMPORTED_MODULE_0___default().createElement("li", { return react__WEBPACK_IMPORTED_MODULE_0___default().createElement("li", {
className: bgColor, className: bgColor,
onClick: this.handleClick onClick: this.handleClick
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+9 -6
View File
@@ -3496,6 +3496,7 @@ class TopicMe extends _topic_js__WEBPACK_IMPORTED_MODULE_2__["default"] {
} }
} }
_processMetaDesc(desc) { _processMetaDesc(desc) {
console.log("_processMetaDesc", desc);
const turnOff = desc.acs && !desc.acs.isPresencer() && this.acs && this.acs.isPresencer(); const turnOff = desc.acs && !desc.acs.isPresencer() && this.acs && this.acs.isPresencer();
(0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.mergeObj)(this, desc); (0,_utils_js__WEBPACK_IMPORTED_MODULE_3__.mergeObj)(this, desc);
this._tinode._db.updTopic(this); this._tinode._db.updTopic(this);
@@ -5242,7 +5243,7 @@ function rfc3339DateString(d) {
const millis = d.getUTCMilliseconds(); const millis = d.getUTCMilliseconds();
return d.getUTCFullYear() + '-' + pad(d.getUTCMonth() + 1) + '-' + pad(d.getUTCDate()) + 'T' + pad(d.getUTCHours()) + ':' + pad(d.getUTCMinutes()) + ':' + pad(d.getUTCSeconds()) + (millis ? '.' + pad(millis, 3) : '') + 'Z'; return d.getUTCFullYear() + '-' + pad(d.getUTCMonth() + 1) + '-' + pad(d.getUTCDate()) + 'T' + pad(d.getUTCHours()) + ':' + pad(d.getUTCMinutes()) + ':' + pad(d.getUTCSeconds()) + (millis ? '.' + pad(millis, 3) : '') + 'Z';
} }
function mergeObj(dst, src, ignore) { function mergeObj(dst, src) {
if (typeof src != 'object') { if (typeof src != 'object') {
if (src === undefined) { if (src === undefined) {
return dst; return dst;
@@ -5253,7 +5254,7 @@ function mergeObj(dst, src, ignore) {
return src; return src;
} }
if (src === null) { if (src === null) {
return src; return dst;
} }
if (src instanceof Date && !isNaN(src)) { if (src instanceof Date && !isNaN(src)) {
return !dst || !(dst instanceof Date) || isNaN(dst) || dst < src ? src : dst; return !dst || !(dst instanceof Date) || isNaN(dst) || dst < src ? src : dst;
@@ -5268,16 +5269,18 @@ function mergeObj(dst, src, ignore) {
dst = src.constructor(); dst = src.constructor();
} }
for (let prop in src) { for (let prop in src) {
if (src.hasOwnProperty(prop) && (!ignore || !ignore[prop]) && prop != '_noForwarding') { if (src.hasOwnProperty(prop) && prop != '_noForwarding') {
try { try {
dst[prop] = mergeObj(dst[prop], src[prop]); dst[prop] = mergeObj(dst[prop], src[prop]);
} catch (err) {} } catch (err) {
console.warn("Error merging property:", prop, err);
}
} }
} }
return dst; return dst;
} }
function mergeToCache(cache, key, newval, ignore) { function mergeToCache(cache, key, newval) {
cache[key] = mergeObj(cache[key], newval, ignore); cache[key] = mergeObj(cache[key], newval);
return cache[key]; return cache[key];
} }
function simplify(obj) { function simplify(obj) {
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long