Fix promise wrapping.
This commit is contained in:
parent
e249e3d622
commit
c93faf7de7
1 changed files with 11 additions and 18 deletions
|
@ -22,7 +22,6 @@ limitations under the License.
|
||||||
import URL from 'url';
|
import URL from 'url';
|
||||||
import dis from './dispatcher';
|
import dis from './dispatcher';
|
||||||
import MatrixPostMessageApi from './MatrixPostMessageApi';
|
import MatrixPostMessageApi from './MatrixPostMessageApi';
|
||||||
import Promise from 'bluebird';
|
|
||||||
|
|
||||||
const WIDGET_API_VERSION = '0.0.1'; // Current API version
|
const WIDGET_API_VERSION = '0.0.1'; // Current API version
|
||||||
const SUPPORTED_WIDGET_API_VERSIONS = [
|
const SUPPORTED_WIDGET_API_VERSIONS = [
|
||||||
|
@ -251,32 +250,26 @@ export default class WidgetMessaging extends MatrixPostMessageApi {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request a screenshot from a widget
|
* Request a screenshot from a widget
|
||||||
* @return {Promise} To be resolved when screenshot has been generated
|
* @return {Promise} To be resolved with screenshot data when it has been generated
|
||||||
*/
|
*/
|
||||||
getScreenshot() {
|
getScreenshot() {
|
||||||
return new Promise((resolve, reject) => {
|
return this.exec({
|
||||||
this.exec({
|
|
||||||
api: OUTBOUND_API_NAME,
|
api: OUTBOUND_API_NAME,
|
||||||
action: "screenshot",
|
action: "screenshot",
|
||||||
}).then(function(response) {
|
}).then((response) => response.screenshot)
|
||||||
resolve(response.screenshot);
|
.catch((error) => new Error("Failed to get screenshot: " + error.message));
|
||||||
}).catch((error) => {
|
|
||||||
reject(Error("Failed to get screenshot: " + error.message));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request capabilities required by the widget
|
||||||
|
* @return {Promise} To be resolved with an array of requested widget capabilities
|
||||||
|
*/
|
||||||
getCapabilities() {
|
getCapabilities() {
|
||||||
return new Promise((resolve, reject) => {
|
return this.exec({
|
||||||
this.exec({
|
|
||||||
api: OUTBOUND_API_NAME,
|
api: OUTBOUND_API_NAME,
|
||||||
action: "capabilities",
|
action: "capabilities",
|
||||||
}).then(function(response) {
|
}).then((response) => response.capabilities)
|
||||||
resolve(response.capabilities);
|
.catch((error) => new Error("Failed to get capabilities: " + error.message));
|
||||||
}).catch((error) => {
|
|
||||||
reject(Error("Failed to get capabilities: " + error.message));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue