@@ -1,6 +1,4 @@
1−import ob from 'urbit-ob';
2−
3−import { ensurePatFormat } from 'form/formatters';
1+import { useMemo } from 'react';
42
53// looks into the GET parameters and attempts to construct a "flow" object,
64// which would indicate bridge is to be used for one specific flow.
@@ -17,28 +15,33 @@ const COMMANDS = {
1715};
1816
1917const useFlowCommand = () => {
20− let flow = {};
21− window.location.search
22− .substr(1)
23− .split('&')
24− .forEach(arg => {
25− if ('' === arg) return;
26− const pam = arg.split('=');
27− flow[pam[0]] = pam.length <= 1 ? true : decodeURIComponent(pam[1]);
28− });
29−
30− if (typeof flow === 'object') {
31− switch (flow.kind) {
32− default:
33− console.log('unrecognized kind of flow:', flow.kind);
34− // eslint-disable-next-line no-fallthrough
35− case undefined:
36− flow = null;
37− break;
18+ const flow = useMemo(() => {
19+ let flow = {};
20+
21+ window.location.search
22+ .substr(1)
23+ .split('&')
24+ .forEach(arg => {
25+ if ('' === arg) return;
26+ const pam = arg.split('=');
27+ flow[pam[0]] = pam.length <= 1 ? true : decodeURIComponent(pam[1]);
28+ });
29+
30+ if (typeof flow === 'object') {
31+ switch (flow.kind) {
32+ default:
33+ console.log('unrecognized kind of flow:', flow.kind);
34+ // eslint-disable-next-line no-fallthrough
35+ case undefined:
36+ flow = null;
37+ break;
38+ }
39+ } else {
40+ flow = null;
3841 }
39− } else {
40− flow = null;
41− }
42+
43+ return flow;
44+ }, []);
4245
4346 return flow;
4447};