diff --git a/src/webapp.jsx b/src/webapp.jsx index 3a01cfca..6457326f 100644 --- a/src/webapp.jsx +++ b/src/webapp.jsx @@ -4847,12 +4847,14 @@ class TinodeWeb extends React.Component { errorText: '', errorLevel: null, mobilePanel: 'topic-view', - topicSelectedOnline: online, - topicSelectedAcs: acs, showInfoPanel: false }); - // Contact selected + // Different contact selected. if (this.state.topicSelected != topicName) { + this.setState({ + topicSelectedOnline: online, + topicSelectedAcs: acs + }); navigateTo(setUrlTopic("", topicName)); } } else { diff --git a/umd/index.dev.js b/umd/index.dev.js index badf2dd3..c31f2c1d 100644 --- a/umd/index.dev.js +++ b/umd/index.dev.js @@ -28679,7 +28679,6 @@ class SidepanelView extends React.Component { chatList: this.props.chatList, showContextMenu: this.props.showContextMenu, onTopicSelected: this.props.onTopicSelected }) : view === 'newtpk' ? React.createElement(NewTopicView, { - contactsSearchQuery: this.props.contactsSearchQuery, searchResults: this.props.searchResults, onInitFind: this.props.onInitFind, onSearchContacts: this.props.onSearchContacts, @@ -29623,7 +29622,6 @@ class NewTopicView extends React.Component { this.state = { tabSelected: "p2p", - searchQuery: props.contactsSearchQuery, contactList: props.searchResults }; @@ -29639,7 +29637,6 @@ class NewTopicView extends React.Component { static getDerivedStateFromProps(nextProps, prevState) { return { - searchQuery: nextProps.contactsSearchQuery, contactList: nextProps.searchResults }; } @@ -29708,7 +29705,6 @@ class NewTopicView extends React.Component { 'div', { className: 'flex-column' }, React.createElement(SearchContacts, { type: 'p2p', - searchQuery: this.state.searchQuery, onSearchContacts: this.props.onSearchContacts }), React.createElement(ContactList, { contacts: this.state.contactList, @@ -29818,13 +29814,13 @@ class NewTopicGroup extends React.PureComponent { } }; -class SearchContacts extends React.Component { +class SearchContacts extends React.PureComponent { constructor(props) { super(props); this.state = { edited: false, - search: props.searchQuery + search: '' }; this.handleSearchChange = this.handleSearchChange.bind(this); @@ -29834,8 +29830,8 @@ class SearchContacts extends React.Component { } componentWillUnmount() { - if (this.state.search) { - this.setState({ search: '' }); + if (this.state.edited) { + this.setState({ search: '', edited: false }); this.props.onSearchContacts(Tinode.DEL_CHAR); } } @@ -29847,16 +29843,12 @@ class SearchContacts extends React.Component { handleSearch(e) { e.preventDefault(); var query = this.state.search.trim(); - if (query.length > 0) { - this.setState({ edited: true }); - this.props.onSearchContacts(query); - } else if (this.props.searchQuery) { - this.props.onSearchContacts(Tinode.DEL_CHAR); - } + this.setState({ edited: query.length > 0 }); + this.props.onSearchContacts(query.length > 0 ? query : Tinode.DEL_CHAR); } handleClear() { - if (this.state.edited || this.state.search) { + if (this.state.edited) { this.props.onSearchContacts(Tinode.DEL_CHAR); } this.setState({ search: '', edited: false }); @@ -31988,7 +31980,6 @@ class TinodeWeb extends React.Component { contextMenuParams: null, contextMenuItems: [], - contactsSearchQuery: '', // Chats as shown in the ContactsView chatList: [], // Contacts returned by a search query. @@ -32401,7 +32392,6 @@ class TinodeWeb extends React.Component { tnInitFind() { let fnd = this.tinode.getFndTopic(); if (fnd.isSubscribed()) { - this.setState({ contactsSearchQuery: '' }); this.tnFndSubsUpdated(); } else { fnd.onSubsUpdated = this.tnFndSubsUpdated; @@ -32428,7 +32418,6 @@ class TinodeWeb extends React.Component { */ handleSearchContacts(query) { var fnd = this.tinode.getFndTopic(); - this.setState({ contactsSearchQuery: query == Tinode.DEL_CHAR ? '' : query }); fnd.setMeta({ desc: { public: query } }).then(ctrl => { return fnd.getMeta(fnd.startMetaQuery().withSub().build()); }).catch(err => { @@ -32443,12 +32432,14 @@ class TinodeWeb extends React.Component { errorText: '', errorLevel: null, mobilePanel: 'topic-view', - topicSelectedOnline: online, - topicSelectedAcs: acs, showInfoPanel: false }); - // Contact selected + // Different contact selected. if (this.state.topicSelected != topicName) { + this.setState({ + topicSelectedOnline: online, + topicSelectedAcs: acs + }); navigateTo(setUrlTopic("", topicName)); } } else { @@ -32881,7 +32872,6 @@ class TinodeWeb extends React.Component { onValidateCredentials: this.handleValidateCredentialsRequest, onInitFind: this.tnInitFind, - contactsSearchQuery: this.state.contactsSearchQuery, searchResults: this.state.searchResults, onSearchContacts: this.handleSearchContacts, diff --git a/umd/index.prod.js b/umd/index.prod.js index 994ec0cd..959382c9 100644 --- a/umd/index.prod.js +++ b/umd/index.prod.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Webapp=e()}}(function(){return function(){return function e(t,n,r){function i(o,s){if(!n[o]){if(!t[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[o]={exports:{}};t[o][0].call(u.exports,function(e){return i(t[o][1][e]||e)},u,u.exports,e,t,n,r)}return n[o].exports}for(var a="function"==typeof require&&require,o=0;oo&&console.warn("This browser only supports "+o+" actions.The remaining actions will not be displayed."),[2,i.showNotification(r,n)];case 3:return this.bgMessageHandler?[4,this.bgMessageHandler(t)]:[3,5];case 4:return s.sent(),[2];case 5:return[2]}})})},t.prototype.onSubChange_=function(e){return l.__awaiter(this,void 0,void 0,function(){var e,t,n,r;return l.__generator(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.getSWRegistration_()];case 1:return e=i.sent(),[3,3];case 2:throw t=i.sent(),p.create(u.UNABLE_TO_RESUBSCRIBE,{message:t});case 3:return i.trys.push([3,5,,8]),[4,e.pushManager.getSubscription()];case 4:return i.sent(),[3,8];case 5:return n=i.sent(),[4,this.getTokenDetailsModel().getTokenDetailsFromSWScope(e.scope)];case 6:if(!(r=i.sent()))throw n;return[4,this.deleteToken(r.fcmToken)];case 7:throw i.sent(),n;case 8:return[2]}})})},t.prototype.onNotificationClick_=function(e){return l.__awaiter(this,void 0,void 0,function(){var t,n,r,i;return l.__generator(this,function(a){switch(a.label){case 0:return e.notification&&e.notification.data&&e.notification.data.FCM_MSG?e.action?[2]:(e.stopImmediatePropagation(),e.notification.close(),(t=e.notification.data.FCM_MSG).notification&&(n=t.fcmOptions&&t.fcmOptions.link||t.notification.click_action)?[4,this.getWindowClient_(n)]:[2]):[2];case 1:return(r=a.sent())?[3,3]:[4,self.clients.openWindow(n)];case 2:return r=a.sent(),[3,5];case 3:return[4,r.focus()];case 4:r=a.sent(),a.label=5;case 5:return r?(delete t.notification,delete t.fcmOptions,i=M(o.NOTIFICATION_CLICKED,t),[2,this.attemptToMessageClient_(r,i)]):[2]}})})},t.prototype.getNotificationData_=function(e){if(e&&"object"==typeof e.notification){var t,n=l.__assign({},e.notification);return n.data=l.__assign({},e.notification.data,((t={}).FCM_MSG=e,t)),n}},t.prototype.setBackgroundMessageHandler=function(e){if(!e||"function"!=typeof e)throw p.create(u.BG_HANDLER_FUNCTION_EXPECTED);this.bgMessageHandler=e},t.prototype.getWindowClient_=function(e){return l.__awaiter(this,void 0,void 0,function(){var t,n,r,i;return l.__generator(this,function(a){switch(a.label){case 0:return t=new URL(e,self.location.href).href,[4,N()];case 1:for(n=a.sent(),r=null,i=0;i0?V:z)(e)},H=Math.min,K=function(e){return e>0?H(q(e),9007199254740991):0},G=Array.isArray||function(e){return"Array"==L(e)},$=h["__core-js_shared__"]||(h["__core-js_shared__"]={}),Q=function(e){return $[e]||($[e]={})},Y=p(function(e){var t=Q("wks"),n=h.Symbol,r="function"==typeof n;(e.exports=function(e){return t[e]||(t[e]=r&&n[e]||(r?n:A)("Symbol."+e))}).store=t}),X=Y("species"),J=function(e,t){return new(function(e){var t;return G(e)&&("function"!=typeof(t=e.constructor)||t!==Array&&!G(t.prototype)||(t=void 0),m(t)&&null===(t=t[X])&&(t=void 0)),void 0===t?Array:t}(e))(t)},Z=function(e,t){var n=1==e,r=2==e,i=3==e,a=4==e,o=6==e,s=5==e||o,l=t||J;return function(t,c,u){for(var d,p,h=B(t),f=j(h),m=I(c,u,3),g=K(f.length),v=0,b=n?l(t,g):r?l(t,0):void 0;g>v;v++)if((s||v in f)&&(p=m(d=f[v],v,h),e))if(n)b[v]=p;else if(p)switch(e){case 3:return!0;case 5:return d;case 6:return v;case 2:b.push(d)}else if(a)return!1;return o?-1:i||a?a:b}},ee=Y("unscopables"),te=Array.prototype;void 0==te[ee]&&x(te,ee,{});var ne=function(e){te[ee][e]=!0},re=Z(5),ie=!0;"find"in[]&&Array(1).find(function(){ie=!1}),U(U.P+U.F*ie,"Array",{find:function(e){return re(this,e,arguments.length>1?arguments[1]:void 0)}}),ne("find");f.Array.find;var ae=Z(6),oe=!0;"findIndex"in[]&&Array(1).findIndex(function(){oe=!1}),U(U.P+U.F*oe,"Array",{findIndex:function(e){return ae(this,e,arguments.length>1?arguments[1]:void 0)}}),ne("findIndex");f.Array.findIndex;var se,le=function(e){return j(W(e))},ce=Math.max,ue=Math.min,de=Q("keys"),pe=function(e){return de[e]||(de[e]=A(e))},he=(se=!1,function(e,t,n){var r,i=le(e),a=K(i.length),o=function(e,t){return(e=q(e))<0?ce(e+t,0):ue(e,t)}(n,a);if(se&&t!=t){for(;a>o;)if((r=i[o++])!=r)return!0}else for(;a>o;o++)if((se||o in i)&&i[o]===t)return se||o||0;return!se&&-1}),fe=pe("IE_PROTO"),me=function(e,t){var n,r=le(e),i=0,a=[];for(n in r)n!=fe&&N(r,n)&&a.push(n);for(;t.length>i;)N(r,n=t[i++])&&(~he(a,n)||a.push(n));return a},ge="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),ve=Object.keys||function(e){return me(e,ge)},be={f:Object.getOwnPropertySymbols},ye={f:{}.propertyIsEnumerable},we=Object.assign,Ee=!we||v(function(){var e={},t={},n=Symbol(),r="abcdefghijklmnopqrst";return e[n]=7,r.split("").forEach(function(e){t[e]=e}),7!=we({},e)[n]||Object.keys(we({},t)).join("")!=r})?function(e,t){for(var n=B(e),r=arguments.length,i=1,a=be.f,o=ye.f;r>i;)for(var s,l=j(arguments[i++]),c=a?ve(l).concat(a(l)):ve(l),u=c.length,d=0;u>d;)o.call(l,s=c[d++])&&(n[s]=l[s]);return n}:we;U(U.S+U.F,"Object",{assign:Ee});f.Object.assign;var _e=Y("match"),Se=function(e,t,n){if(m(r=t)&&(void 0!==(i=r[_e])?i:"RegExp"==L(r)))throw TypeError("String#"+n+" doesn't accept regex!");var r,i;return String(W(e))},Te=Y("match"),Ce="".startsWith;U(U.P+U.F*function(e){var t=/./;try{"/./"[e](t)}catch(n){try{return t[Te]=!1,!"/./"[e](t)}catch(e){}}return!0}("startsWith"),"String",{startsWith:function(e){var t=Se(this,e,"startsWith"),n=K(Math.min(arguments.length>1?arguments[1]:void 0,t.length)),r=String(e);return Ce?Ce.call(t,r,n):t.slice(n,n+r.length)===r}});f.String.startsWith;U(U.P,"String",{repeat:function(e){var t=String(W(this)),n="",r=q(e);if(r<0||r==1/0)throw RangeError("Count can't be negative");for(;r>0;(r>>>=1)&&(t+=t))1&r&&(n+=t);return n}});f.String.repeat;var ke=p(function(e){var t=A("meta"),n=C.f,r=0,i=Object.isExtensible||function(){return!0},a=!v(function(){return i(Object.preventExtensions({}))}),o=function(e){n(e,t,{value:{i:"O"+ ++r,w:{}}})},s=e.exports={KEY:t,NEED:!1,fastKey:function(e,n){if(!m(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!N(e,t)){if(!i(e))return"F";if(!n)return"E";o(e)}return e[t].i},getWeak:function(e,n){if(!N(e,t)){if(!i(e))return!0;if(!n)return!1;o(e)}return e[t].w},onFreeze:function(e){return a&&s.NEED&&i(e)&&!N(e,t)&&o(e),e}}}),xe=(ke.KEY,ke.NEED,ke.fastKey,ke.getWeak,ke.onFreeze,C.f),Pe=Y("toStringTag"),Ne=function(e,t,n){e&&!N(e=n?e:e.prototype,Pe)&&xe(e,Pe,{configurable:!0,value:t})},Me={f:Y},De=C.f,Ae=function(e){var t=f.Symbol||(f.Symbol=h.Symbol||{});"_"==e.charAt(0)||e in t||De(t,e,{value:Me.f(e)})},Oe=b?Object.defineProperties:function(e,t){g(e);for(var n,r=ve(t),i=r.length,a=0;i>a;)C.f(e,n=r[a++],t[n]);return e},Ie=h.document,Re=Ie&&Ie.documentElement,Ue=pe("IE_PROTO"),Fe=function(){},Le=function(){var e,t=E("iframe"),n=ge.length;for(t.style.display="none",Re.appendChild(t),t.src="javascript:",(e=t.contentWindow.document).open(),e.write("