From 2e619d3fb89851b70ebd1ef17e7ac93fe8303555 Mon Sep 17 00:00:00 2001 From: or-else Date: Wed, 16 May 2018 10:17:00 -0700 Subject: [PATCH] show unread threads in title, bug fix --- img/logo32x32a.png | Bin 1658 -> 1811 bytes index.html | 27 ++++++++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/img/logo32x32a.png b/img/logo32x32a.png index cf5e329f6cfbc860e1dd110111a70c1ca2297072..1bacf143a0e0613baa6142af8c4472a4199ac8f6 100644 GIT binary patch delta 1722 zcmV;r21WV$43iF!ZGQ%kNklg(%wM-_Fdg-jZv ziD9P0-ns7Pvd79-ENhvzfT{yESL}M@gPj9Ip;Uc}6;BnE5Tx3yp?hvw{---{ENz@{ zef&W6!6UiPRekVm{}gc1G`;@SImbXSWUYMX<7cW59)HPAD&TC7-(0!x<86b%kTp@Q zEs}^$x39zlYj1)ohk=bDRaMg5)mxnCrYm#Y$jnF^Gd3&TfugJP0RUfrdlFGa1vrNu4TG8_5FznePJ4aD z5j8^1%&ap2_;B~`YtG7i!j2e@2iD$mDZnyM0RW(6%@&;R4S*5?0N|Pe za2U8J6SFd^W_Ip2P05H3&`O?4H&LmWvD^vjAcTNY0)T)} z0xAiBKqlPNrJl+LVkMX>`=vDAn-DGCdDKVz% z1Ofz@C=13N&;&7fF##AgP8-q^8@HEE62j$ z-GbjDs)7Ga^vM3*wRtPD%si}6MKm+(jYQ^Gj_H=F(T{l$Mg94}u{ zQPH)2?uS=zpA3?*c;ay4L z0H8yMPwj=!(TbB@jX`Fy*g{GOt$|jw_5YBx=?DNGB|{sozGrJrM$VWm&%)tw$PW9I z0stVDrb7Mxe|YAj25(1dbRHBwWzzv1km=ycxhu9^H}AU6@i}R2ZEa1SlnX1dCWU9y zZ0J!9Qb&uC+yuZ(fKlhbcz^4;%E4rIX5IWdH*a40`-aK#QisEFysoZZyNj$%2&bUf zL^j~RAAW*7yJhqRaFGLSWczV&a8(BnbJ=a0^V;86JiFo6t8Vos%w17Y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7o!2Lr!c zSB7xLR|8*h1OgbK$8@Lyq42vxcoMFTU`_=fei|p&yxVnP+lFmJYuBzVH#Ic{LI|op zObUNH*6f`5Xo<`Y-9)8)Gk+;*G8Gui^I`yT3IdHu83BM_ZcI-7D=9Oi6yuWHK`HPl zM+Kw;=B)9T2N}5-2D9L>8FO6xXVIC(AKV`89_;S!&aYavs*=fM0&)2P+tA~5K1nHA zxm@OBV`KX8@UWH5X03caZ%8SbWm!QgmGau#+bheKE%RDhT71j0NEys}J^vT%8@eV; S2$He@0000 - Tinode example: chat web application in react.js + Tinode @@ -231,8 +231,8 @@ reader.readAsDataURL(file); } - // Make shortcut icon appear with a green dot. - function updateFavicon(on) { + // Make shortcut icon appear with a green dot + show unread count in title. + function updateFavicon(count) { var oldIcon = document.getElementById("shortcut-icon"); if (oldIcon) { var head = document.head || document.getElementsByTagName('head')[0]; @@ -240,10 +240,11 @@ newIcon.type = "image/png"; newIcon.id = "shortcut-icon"; newIcon.rel = "shortcut icon"; - newIcon.href = "img/logo32x32" + (on ? 'a' : '') + ".png"; + newIcon.href = "img/logo32x32" + (count > 0 ? 'a' : '') + ".png"; head.removeChild(oldIcon); head.appendChild(newIcon); } + document.title = (count > 0 ? '('+count+') ' : '') + "Tinode"; } // Get 32 bit integer hash value for a string. Ideally it should produce the same value @@ -1957,13 +1958,13 @@ prepareContactList: function() { var instance = this; var contacts = []; - var totalUnread = 0; + var unreadThreads = 0; Tinode.getMeTopic().contacts(function(c) { // Force to integers; c.seq = ~~c.seq; c.read = ~~c.read; c.unread = c.seq - c.read; - totalUnread += c.unread; + unreadThreads += c.unread > 0 ? 1 : 0; contacts.push(c); if (instance.props.topicSelected == c.topic) { instance.props.onOnlineChange(c.online); @@ -1973,7 +1974,7 @@ contacts.sort(function(a,b){ return b.touched - a.touched; }); - updateFavicon(totalUnread > 0); + updateFavicon(unreadThreads); return contacts; }, @@ -2776,12 +2777,11 @@ }, handleShowAddMembers: function() { - // this.props.onAddMember(this.props.topic); + this.props.onInitFind(); this.setState({showMemberPanel: true}); }, handleHideAddMembers: function() { - // this.props.onAddMember(this.props.topic); this.setState({showMemberPanel: false}); }, @@ -3308,6 +3308,7 @@ } }, + // Get older messages fetchMoreMessages: function(event) { var instance = this; if (event.target.scrollTop <= 0) { @@ -3316,7 +3317,7 @@ this.setState(function(prevState, props) { if (!prevState.fetchingMessages) { var topic = Tinode.getTopic(instance.state.topic); - if (topic && topic.isSubscribed() && topic.msgHasMore()) { + if (topic && topic.isSubscribed() && topic.msgHasMoreMessages()) { newState.fetchingMessages = true; topic.getMessagesPage(MESSAGES_PAGE).then(function() { instance.setState({fetchingMessages: false}); @@ -4050,13 +4051,13 @@ /* Fnd topic: find contacts by tokens */ tnInitFind: function() { var fnd = Tinode.getFndTopic(); - fnd.onSubsUpdated = this.tnFndSubsUpdated; - fnd.onMetaDesc = this.tnFndMetaDesc; - var instance = this; if (fnd.isSubscribed()) { this.setState({contactsSearchQuery: fnd.private ? fnd.private.toString() : ''}); this.tnFndSubsUpdated(); } else { + fnd.onSubsUpdated = this.tnFndSubsUpdated; + fnd.onMetaDesc = this.tnFndMetaDesc; + var instance = this; fnd.subscribe(fnd.startMetaQuery().withSub().withLaterDesc().withTags().build()).catch(function(err){ instance.handleError(err.message, "err"); });