Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
RocketChat
Rocket.Chat.ReactNative
Commits
ebe36cdc
Unverified
Commit
ebe36cdc
authored
Feb 11, 2020
by
Djorkaeff Alexandre
Committed by
GitHub
Feb 11, 2020
Browse files
[FIX] Unhandled action on UIKit (#1703)
parent
83668359
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/containers/UIKit/utils.js
View file @
ebe36cdc
...
...
@@ -29,13 +29,17 @@ export const useBlockContext = ({
loading
,
setLoading
,
error
,
value
,
language
},
async
({
value
})
=>
{
setLoading
(
true
);
await
action
({
blockId
,
appId
:
appId
||
appIdFromContext
,
actionId
,
value
,
viewId
});
try
{
await
action
({
blockId
,
appId
:
appId
||
appIdFromContext
,
actionId
,
value
,
viewId
});
}
catch
(
e
)
{
// do nothing
}
setLoading
(
false
);
}];
}
...
...
@@ -44,12 +48,16 @@ export const useBlockContext = ({
loading
,
setLoading
,
value
,
error
,
language
},
async
({
value
})
=>
{
setLoading
(
true
);
await
state
({
blockId
,
appId
,
actionId
,
value
});
try
{
await
state
({
blockId
,
appId
,
actionId
,
value
});
}
catch
(
e
)
{
// do nothing
}
setLoading
(
false
);
}];
};
app/lib/methods/actions.js
View file @
ebe36cdc
import
random
from
'
../../utils/random
'
;
import
EventEmitter
from
'
../../utils/events
'
;
import
Navigation
from
'
../Navigation
'
;
import
{
showErrorAlert
}
from
'
../../utils/info
'
;
import
I18n
from
'
../../i18n
'
;
const
TRIGGER_TIMEOUT
=
5000
;
...
...
@@ -112,43 +110,41 @@ export function triggerAction({
const
{
userId
,
authToken
}
=
this
.
sdk
.
currentLogin
;
const
{
host
}
=
this
.
sdk
.
client
;
// we need to use fetch because this.sdk.post add /v1 to url
const
result
=
await
fetch
(
`
${
host
}
/api/apps/ui.interaction/
${
appId
}
/`
,
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
'
X-Auth-Token
'
:
authToken
,
'
X-User-Id
'
:
userId
},
body
:
JSON
.
stringify
({
type
,
actionId
,
payload
,
container
,
mid
,
rid
,
triggerId
,
viewId
})
});
try
{
const
{
type
:
interactionType
,
...
data
}
=
await
result
.
json
();
handlePayloadUserInteraction
(
interactionType
,
data
);
if
(
data
.
success
)
{
return
resolve
();
// we need to use fetch because this.sdk.post add /v1 to url
const
result
=
await
fetch
(
`
${
host
}
/api/apps/ui.interaction/
${
appId
}
/`
,
{
method
:
'
POST
'
,
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
'
X-Auth-Token
'
:
authToken
,
'
X-User-Id
'
:
userId
},
body
:
JSON
.
stringify
({
type
,
actionId
,
payload
,
container
,
mid
,
rid
,
triggerId
,
viewId
})
});
try
{
const
{
type
:
interactionType
,
...
data
}
=
await
result
.
json
();
return
resolve
(
handlePayloadUserInteraction
(
interactionType
,
data
));
}
catch
(
e
)
{
// modal.close has no body, so result.json will fail
// but it returns ok status
if
(
result
.
ok
)
{
return
resolve
();
}
}
return
reject
();
}
catch
(
e
)
{
if
(
result
.
status
!==
200
)
{
showErrorAlert
(
I18n
.
t
(
'
Oops
'
));
return
reject
();
}
// do nothing
}
return
resolve
();
return
reject
();
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment