From 7abb371a2015a3eb0c01c0e1909c219e91b2df3f Mon Sep 17 00:00:00 2001 From: Logan Allen Date: Thu, 27 Feb 2020 14:54:03 -0800 Subject: [PATCH] chat: unmanaged chats are cleaned up and sync down metadata properly --- pkg/arvo/app/chat-view.hoon | 15 ++++++++++++--- pkg/arvo/app/chat/js/index.js | 2 +- pkg/arvo/app/metadata-hook.hoon | 2 +- pkg/arvo/app/metadata-store.hoon | 2 ++ pkg/arvo/app/permission-group-hook.hoon | 2 ++ pkg/interface/chat/src/js/components/join.js | 13 +++++++------ 6 files changed, 25 insertions(+), 11 deletions(-) diff --git a/pkg/arvo/app/chat-view.hoon b/pkg/arvo/app/chat-view.hoon index 7b2614316..ad299acfe 100644 --- a/pkg/arvo/app/chat-view.hoon +++ b/pkg/arvo/app/chat-view.hoon @@ -215,6 +215,7 @@ :: %delete =/ group-path (group-from-chat app-path.act) + ~& delete+group-path ?> ?=(^ app-path.act) %- zing :~ :~ (chat-hook-poke [%remove app-path.act]) @@ -224,6 +225,7 @@ :: ?: (is-managed group-path) ~ :~ (permission-hook-poke [%remove group-path]) + (permission-poke [%delete group-path]) (group-poke [%unbundle group-path]) (metadata-hook-poke [%remove group-path]) == @@ -264,9 +266,9 @@ ++ create-metadata |= [group-path=path app-path=path] ^- (list card) - ~& group-path+group-path - ~& app-path+app-path - ~& is-managed+(is-managed app-path) + ::~& group-path+group-path + ::~& app-path+app-path + ::~& is-managed+(is-managed app-path) =/ =metadata %* . *metadata date-created now.bol @@ -342,6 +344,7 @@ (scot %da now.bol) /resource-indices == + ~& resource-indices =/ groups=(set path) (~(got by resource-indices) [%chat app-path]) (snag 0 ~(tap in groups)) :: @@ -349,6 +352,7 @@ |= =path ^- ? ?> ?=(^ path) + ~& is-managed+!=(i.path '~') !=(i.path '~') -- :: @@ -373,6 +377,11 @@ ^- card [%pass / %agent [our.bol %group-store] %poke %group-action !>(act)] :: +++ permission-poke + |= act=permission-action + ^- card + [%pass / %agent [our.bol %permission-store] %poke %permission-action !>(act)] +:: ++ chat-hook-poke |= act=chat-hook-action ^- card diff --git a/pkg/arvo/app/chat/js/index.js b/pkg/arvo/app/chat/js/index.js index de7639018..613d57742 100644 --- a/pkg/arvo/app/chat/js/index.js +++ b/pkg/arvo/app/chat/js/index.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("buffer")):"function"==typeof define&&define.amd?define("index",["buffer"],t):t((e=e||self).buffer)}(this,function(e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var t="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},n=t.performance||{},r=(n.now||n.mozNow||n.msNow||n.oNow||n.webkitNow,"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{});function i(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}function a(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function l(e,t){return e(t={exports:{}},t.exports),t.exports}var o=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;var c=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach(function(e){r[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var n,r,i=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),a=1;a2?n-2:0),i=2;i1?t-1:0),r=1;r2?n-2:0),i=2;i8)throw new Error("warningWithoutStack() currently supports at most 8 arguments.");if(!e){if("undefined"!=typeof console){var a=r.map(function(e){return""+e});a.unshift("Warning: "+t),Function.prototype.apply.call(console.error,console,a)}try{var l=0,o="Warning: "+t.replace(/%s/g,function(){return r[l++]});throw new Error(o)}catch(e){}}},T={};function N(e,t){var n=e.constructor,r=n&&(n.displayName||n.name)||"ReactClass",i=r+"."+t;T[i]||(S(!1,"Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",t,r),T[i]=!0)}var P={isMounted:function(e){return!1},enqueueForceUpdate:function(e,t,n){N(e,"forceUpdate")},enqueueReplaceState:function(e,t,n,r){N(e,"replaceState")},enqueueSetState:function(e,t,n,r){N(e,"setState")}},R={};function L(e,t,n){this.props=e,this.context=t,this.refs=R,this.updater=n||P}Object.freeze(R),L.prototype.isReactComponent={},L.prototype.setState=function(e,t){!function(){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw M(Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables."))}(),this.updater.enqueueSetState(this,e,t,"setState")},L.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};var O={isMounted:["isMounted","Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],replaceState:["replaceState","Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]},D=function(e,t){Object.defineProperty(L.prototype,e,{get:function(){E(!1,"%s(...) is deprecated in plain JavaScript React classes. %s",t[0],t[1])}})};for(var A in O)O.hasOwnProperty(A)&&D(A,O[A]);function I(){}function U(e,t,n){this.props=e,this.context=t,this.refs=R,this.updater=n||P}I.prototype=L.prototype;var j=U.prototype=new I;j.constructor=U,t(j,L.prototype),j.isPureReactComponent=!0;var z={current:null},H={suspense:null},F={current:null},Z=/^(.*)[\\\/]/,V=1;function W(e){if(null==e)return null;if("number"==typeof e.tag&&S(!1,"Received an unexpected object in getComponentName(). This is likely a bug in React. Please file an issue."),"function"==typeof e)return e.displayName||e.name||null;if("string"==typeof e)return e;switch(e){case l:return"Fragment";case a:return"Portal";case u:return"Profiler";case o:return"StrictMode";case p:return"Suspense";case m:return"SuspenseList"}if("object"==typeof e)switch(e.$$typeof){case f:return"Context.Consumer";case s:return"Context.Provider";case h:return r=e,i=e.render,c="ForwardRef",d=i.displayName||i.name||"",r.displayName||(""!==d?c+"("+d+")":c);case v:return W(e.type);case b:var t=(n=e)._status===V?n._result:null;if(t)return W(t)}var n,r,i,c,d;return null}var q={},Y=null;function B(e){Y=e}q.getCurrentStack=null,q.getStackAddendum=function(){var e="";if(Y){var t=W(Y.type),n=Y._owner;e+=function(e,t,n){var r="";if(t){var i=t.fileName,a=i.replace(Z,"");if(/^index\./.test(a)){var l=i.match(Z);if(l){var o=l[1];o&&(a=o.replace(Z,"")+"/"+a)}}r=" (at "+a+":"+t.lineNumber+")"}else n&&(r=" (created by "+n+")");return"\n in "+(e||"Unknown")+r}(t,Y._source,n&&W(n.type))}var r=q.getCurrentStack;return r&&(e+=r()||""),e};var $={ReactCurrentDispatcher:z,ReactCurrentBatchConfig:H,ReactCurrentOwner:F,IsSomeRendererActing:{current:!1},assign:t};t($,{ReactDebugCurrentFrame:q,ReactComponentTreeHook:{}});var G,Q,K=function(e,t){if(!e){for(var n=$.ReactDebugCurrentFrame.getStackAddendum(),r=arguments.length,i=new Array(r>2?r-2:0),a=2;a1){for(var c=Array(s),f=0;f.")}return t}(t);if(!xe[n]){xe[n]=!0;var r="";e&&e._owner&&e._owner!==F.current&&(r=" It was passed a child from "+W(e._owner.type)+"."),B(e),K(!1,'Each child in a list should have a unique "key" prop.%s%s See https://fb.me/react-warning-keys for more information.',n,r),B(null)}}}function Me(e,t){if("object"==typeof e)if(Array.isArray(e))for(var n=0;n",u=" Did you accidentally export a JSX literal instead of a component?"):s=typeof e,K(!1,"React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",s,u)}var f=re.apply(this,arguments);if(null==f)return f;if(o)for(var d=2;d is not supported and will be removed in a future major release. Did you mean to render instead?")),n.Provider},set:function(e){n.Provider=e}},_currentValue:{get:function(){return n._currentValue},set:function(e){n._currentValue=e}},_currentValue2:{get:function(){return n._currentValue2},set:function(e){n._currentValue2=e}},_threadCount:{get:function(){return n._threadCount},set:function(e){n._threadCount=e}},Consumer:{get:function(){return r||(r=!0,K(!1,"Rendering is not supported and will be removed in a future major release. Did you mean to render instead?")),n.Consumer}}}),n.Consumer=a,n._currentRenderer=null,n._currentRenderer2=null,n},forwardRef:function(e){return null!=e&&e.$$typeof===v?S(!1,"forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."):"function"!=typeof e?S(!1,"forwardRef requires a render function but was given %s.",null===e?"null":typeof e):0!==e.length&&2!==e.length&&S(!1,"forwardRef render functions accept exactly two parameters: props and ref. %s",1===e.length?"Did you forget to use the ref parameter?":"Any additional parameter will be undefined."),null!=e&&(null!=e.defaultProps||null!=e.propTypes)&&S(!1,"forwardRef render functions do not support propTypes or defaultProps. Did you accidentally pass a React component?"),{$$typeof:h,render:e}},lazy:function(e){var t,n,r={$$typeof:b,_ctor:e,_status:-1,_result:null};return Object.defineProperties(r,{defaultProps:{configurable:!0,get:function(){return t},set:function(e){K(!1,"React.lazy(...): It is not supported to assign `defaultProps` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it."),t=e,Object.defineProperty(r,"defaultProps",{enumerable:!0})}},propTypes:{configurable:!0,get:function(){return n},set:function(e){K(!1,"React.lazy(...): It is not supported to assign `propTypes` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it."),n=e,Object.defineProperty(r,"propTypes",{enumerable:!0})}}}),r},memo:function(e,t){return ke(e)||S(!1,"memo: The first argument must be a component. Instead received: %s",null===e?"null":typeof e),{$$typeof:v,type:e,compare:void 0===t?null:t}},useCallback:function(e,t){return we().useCallback(e,t)},useContext:function(e,t){var n=we();if(void 0!==t&&K(!1,"useContext() second argument is reserved for future use in React. Passing it is not supported. You passed: %s.%s",t,"number"==typeof t&&Array.isArray(arguments[2])?"\n\nDid you call array.map(useContext)? Calling Hooks inside a loop is not supported. Learn more at https://fb.me/rules-of-hooks":""),void 0!==e._context){var r=e._context;r.Consumer===e?K(!1,"Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be removed in a future major release. Did you mean to call useContext(Context) instead?"):r.Provider===e&&K(!1,"Calling useContext(Context.Provider) is not supported. Did you mean to call useContext(Context) instead?")}return n.useContext(e,t)},useEffect:function(e,t){return we().useEffect(e,t)},useImperativeHandle:function(e,t,n){return we().useImperativeHandle(e,t,n)},useDebugValue:function(e,t){return we().useDebugValue(e,t)},useLayoutEffect:function(e,t){return we().useLayoutEffect(e,t)},useMemo:function(e,t){return we().useMemo(e,t)},useReducer:function(e,t,n){return we().useReducer(e,t,n)},useRef:function(e){return we().useRef(e)},useState:function(e){return we().useState(e)},Fragment:l,Profiler:u,StrictMode:o,Suspense:p,unstable_SuspenseList:m,createElement:Se,cloneElement:function(e,n,r){for(var i=function(e,n,r){var i;!function(){if(null==e)throw M(Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+"."))}();var a,l=t({},e.props),o=e.key,u=e.ref,s=e._self,c=e._source,f=e._owner;if(null!=n)for(i in ee(n)&&(u=n.ref,f=F.current),te(n)&&(o=""+n.key),e.type&&e.type.defaultProps&&(a=e.type.defaultProps),n)J.call(n,i)&&!X.hasOwnProperty(i)&&(void 0===n[i]&&void 0!==a?l[i]=a[i]:l[i]=n[i]);var d=arguments.length-2;if(1===d)l.children=r;else if(d>1){for(var h=Array(d),p=0;p=_},l=function(){},t.unstable_forceFrameRate=function(e){0>e||125T(l,n))void 0!==u&&0>T(u,l)?(e[r]=u,e[o]=n,r=o):(e[r]=l,e[a]=n,r=a);else{if(!(void 0!==u&&0>T(u,n)))break e;e[r]=u,e[o]=n,r=o}}}return t}return null}function T(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}var N=[],P=[],R=1,L=null,O=3,D=!1,A=!1,I=!1;function U(e){for(var t=E(P);null!==t;){if(null===t.callback)S(P);else{if(!(t.startTime<=e))break;S(P),t.sortIndex=t.expirationTime,M(N,t)}t=E(P)}}function j(e){if(I=!1,U(e),!A)if(null!==E(N))A=!0,n(z);else{var t=E(P);null!==t&&r(j,t.startTime-e)}}function z(e,n){A=!1,I&&(I=!1,i()),D=!0;var l=O;try{for(U(n),L=E(N);null!==L&&(!(L.expirationTime>n)||e&&!a());){var o=L.callback;if(null!==o){L.callback=null,O=L.priorityLevel;var u=o(L.expirationTime<=n);n=t.unstable_now(),"function"==typeof u?L.callback=u:L===E(N)&&S(N),U(n)}else S(N);L=E(N)}if(null!==L)var s=!0;else{var c=E(P);null!==c&&r(j,c.startTime-n),s=!1}return s}finally{L=null,O=l,D=!1}}function H(e){switch(e){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1e4;default:return 5e3}}var F=l;t.unstable_ImmediatePriority=1,t.unstable_UserBlockingPriority=2,t.unstable_NormalPriority=3,t.unstable_IdlePriority=5,t.unstable_LowPriority=4,t.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=O;O=e;try{return t()}finally{O=n}},t.unstable_next=function(e){switch(O){case 1:case 2:case 3:var t=3;break;default:t=O}var n=O;O=t;try{return e()}finally{O=n}},t.unstable_scheduleCallback=function(e,a,l){var o=t.unstable_now();if("object"==typeof l&&null!==l){var u=l.delay;u="number"==typeof u&&0o?(e.sortIndex=u,M(P,e),null===E(N)&&e===E(P)&&(I?i():I=!0,r(j,u-o))):(e.sortIndex=l,M(N,e),A||D||(A=!0,n(z))),e},t.unstable_cancelCallback=function(e){e.callback=null},t.unstable_wrapCallback=function(e){var t=O;return function(){var n=O;O=t;try{return e.apply(this,arguments)}finally{O=n}}},t.unstable_getCurrentPriorityLevel=function(){return O},t.unstable_shouldYield=function(){var e=t.unstable_now();U(e);var n=E(N);return n!==L&&null!==L&&null!==n&&null!==n.callback&&n.startTime<=e&&n.expirationTime=x},a=function(){},t.unstable_forceFrameRate=function(e){e<0||e>125?console.error("forceFrameRate takes a positive int between 0 and 125, forcing framerates higher than 125 fps is not unsupported"):_=e>0?Math.floor(1e3/e):33.33};var C=new MessageChannel,M=C.port2;C.port1.onmessage=function(){if(null!==k){var e=t.unstable_now();x=e+_;try{k(!0,e)?M.postMessage(null):(y=!1,k=null)}catch(e){throw M.postMessage(null),e}}else y=!1},e=function(e){k=e,y||(y=!0,M.postMessage(null))},n=function(e,n){w=p(function(){e(t.unstable_now())},n)},r=function(){m(w),w=-1}}function E(e,t){var n=e.length;e.push(t),function(e,t,n){var r=n;for(;;){var i=Math.floor((r-1)/2),a=e[i];if(!(void 0!==a&&N(a,t)>0))return;e[i]=t,e[r]=a,r=i}}(e,t,n)}function S(e){var t=e[0];return void 0===t?null:t}function T(e){var t=e[0];if(void 0!==t){var n=e.pop();return n!==t&&(e[0]=n,function(e,t,n){var r=n,i=e.length;for(;rY){if((Y*=2)>q)return console.error("Scheduler Profiling: Event log exceeded maximum size. Don't forget to call `stopLoggingProfilingEvents()`."),void ae();var n=new Int32Array(4*Y);n.set($),B=n.buffer,$=n}$.set(e,t)}}function ae(){var e=B;return Y=0,B=null,$=null,G=0,e}function le(e,t){z[V]++,null!==$&&ie([Q,t,e.id,e.priorityLevel])}function oe(e,t){z[H]=P,z[F]=0,z[V]--,null!==$&&ie([K,t,e.id])}function ue(e,t){z[H]=P,z[F]=0,z[Z]=0,null!==$&&ie([te,t,e.id,I])}var se=-1,ce=250,fe=5e3,de=1e4,he=1073741823,pe=[],me=[],ve=1,be=null,ge=O,ye=!1,ke=!1,we=!1;function _e(e){for(var t=S(me);null!==t;){if(null===t.callback)T(me);else{if(!(t.startTime<=e))return;T(me),t.sortIndex=t.expirationTime,E(pe,t),le(t,e),t.isQueued=!0}t=S(me)}}function xe(t){if(we=!1,_e(t),!ke)if(null!==S(pe))ke=!0,e(Ce);else{var r=S(me);null!==r&&n(xe,r.startTime-t)}}function Ce(e,n){var i;i=n,null!==$&&ie([re,i,U]),ke=!1,we&&(we=!1,r()),ye=!0;var a=ge;try{if(!o)return Me(e,n);try{return Me(e,n)}catch(e){if(null!==be){var l=t.unstable_now();!function(e,t){z[H]=P,z[F]=0,z[V]--,null!==$&&ie([J,t,e.id])}(be,l),be.isQueued=!1}throw e}}finally{be=null,ge=a,ye=!1,function(e){U++,null!==$&&ie([ne,e,U])}(t.unstable_now())}}function Me(e,r){var a,o,u=r;for(_e(u),be=S(pe);null!==be&&!l&&(!(be.expirationTime>u)||e&&!i());){var s=be.callback;if(null!==s){be.callback=null,ge=be.priorityLevel;var c=be.expirationTime<=u;a=be,o=u,I++,z[H]=a.priorityLevel,z[F]=a.id,z[Z]=I,null!==$&&ie([ee,o,a.id,I]);var f=s(c);u=t.unstable_now(),"function"==typeof f?(be.callback=f,ue(be,u)):(oe(be,u),be.isQueued=!1,be===S(pe)&&T(pe)),_e(u)}else T(pe);be=S(pe)}if(null!==be)return!0;var d=S(me);return null!==d&&n(xe,d.startTime-u),!1}function Ee(e){switch(e){case R:return se;case L:return ce;case A:return he;case D:return de;case O:default:return fe}}var Se=a,Te={startLoggingProfilingEvents:function(){Y=W,B=new ArrayBuffer(4*Y),$=new Int32Array(B),G=0},stopLoggingProfilingEvents:ae,sharedProfilingBuffer:j};t.unstable_ImmediatePriority=R,t.unstable_UserBlockingPriority=L,t.unstable_NormalPriority=O,t.unstable_IdlePriority=A,t.unstable_LowPriority=D,t.unstable_runWithPriority=function(e,t){switch(e){case R:case L:case O:case D:case A:break;default:e=O}var n=ge;ge=e;try{return t()}finally{ge=n}},t.unstable_next=function(e){var t;switch(ge){case R:case L:case O:t=O;break;default:t=ge}var n=ge;ge=t;try{return e()}finally{ge=n}},t.unstable_scheduleCallback=function(i,a,l){var o,u,s=t.unstable_now();if("object"==typeof l&&null!==l){var c=l.delay;o="number"==typeof c&&c>0?s+c:s,u="number"==typeof l.timeout?l.timeout:Ee(i)}else u=Ee(i),o=s;var f=o+u,d={id:ve++,callback:a,priorityLevel:i,startTime:o,expirationTime:f,sortIndex:-1,isQueued:!1};return o>s?(d.sortIndex=o,E(me,d),null===S(pe)&&d===S(me)&&(we?r():we=!0,n(xe,o-s))):(d.sortIndex=f,E(pe,d),le(d,s),d.isQueued=!0,ke||ye||(ke=!0,e(Ce))),d},t.unstable_cancelCallback=function(e){e.isQueued&&(function(e,t){z[V]--,null!==$&&ie([X,t,e.id])}(e,t.unstable_now()),e.isQueued=!1),e.callback=null},t.unstable_wrapCallback=function(e){var t=ge;return function(){var n=ge;ge=t;try{return e.apply(this,arguments)}finally{ge=n}}},t.unstable_getCurrentPriorityLevel=function(){return ge},t.unstable_shouldYield=function(){var e=t.unstable_now();_e(e);var n=S(pe);return n!==be&&null!==be&&null!==n&&null!==n.callback&&n.startTime<=e&&n.expirationTime