@@ -2,28 +2,32 @@ import ob from 'urbit-ob';
3import { ensurePatFormat } from 'form/formatters';
3import { ensurePatFormat } from 'form/formatters';
5−// looks into the window context to find a "flow command", an object indicating
5+// looks into the GET parameters and attempts to construct a "flow" object,
6−// if bridge is to be used for one specific flow.
6+// which would indicate bridge is to be used for one specific flow.
7−// expects to find objects of the following shape, varying by kind:
7+// expects to find any of the following sets of parameters, varying by kind.
9−// { kind: 'invite',
9+// ? kind = invite
10−// as: '~ship', // who to send the invite as
10+// & as = ~ship // who to send the invite as
11−// ship: '~ship', // what planet to send as the invite
11+// & ship = ~ship // what planet to send as the invite
12−// email: 'ex@amp.le' // email to send the invite code to
12+// & email = ex@amp.le // email to send the invite code to
15−// you may optionally include .success() and .failure(reason) callbacks.
17const COMMANDS = {
15const COMMANDS = {
18 INVITE: 'invite',
16 INVITE: 'invite',
21const useFlowCommand = () => {
19const useFlowCommand = () => {
22− let flow = window.flow;
20+ let flow = {};
21+ window.location.search
25+ if ('' === arg) return;
26+ const pam = arg.split('=');
27+ flow[pam[0]] = pam.length <= 1 ? true : decodeURIComponent(pam[1]);
24 if (typeof flow === 'object') {
30 if (typeof flow === 'object') {
25− flow.success = flow.success || (() => {});
26− flow.failure = flow.failure || (() => {});
27 switch (flow.kind) {
31 switch (flow.kind) {
28 case COMMANDS.INVITE:
32 case COMMANDS.INVITE:
29 flow.as = ensurePatFormat(flow.as);
33 flow.as = ensurePatFormat(flow.as);
@@ -36,6 +40,8 @@ const useFlowCommand = () => {
38 console.log('unrecognized kind of flow:', flow.kind);
42 console.log('unrecognized kind of flow:', flow.kind);
43+ // eslint-disable-next-line no-fallthrough
39 flow = null;
45 flow = null;