Skip to content

Commit

Permalink
Fix set toolbar promise. (#208)
Browse files Browse the repository at this point in the history
Mistakenly did not handle the promise for set toolbar and therefore it was never fired. Same is true for the error.
  • Loading branch information
nickwinder authored Apr 8, 2019
1 parent be86e31 commit 6215cea
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-pspdfkit",
"version": "1.23.4",
"version": "1.23.5",
"description": "A React Native module for the PSPDFKit library.",
"keywords": [
"react native",
Expand Down
4 changes: 3 additions & 1 deletion samples/Catalog/Catalog.windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,9 @@ class PdfViewToolbarCustomizationScreen extends Component<{}> {
</View>
<View style={styles.button}>
<Button onPress={() =>
this.refs.pdfView.setToolbarItems([{type: "ink"}])} title="Set Toolbar Items"/>
this.refs.pdfView.setToolbarItems([{type: "ink"}]).then(() => {
alert("Toolbar Items set.");
})} title="Set Toolbar Items"/>
</View>
</View>
<Image
Expand Down
2 changes: 1 addition & 1 deletion samples/Catalog/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Catalog",
"version": "1.23.4",
"version": "1.23.5",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,14 @@ internal void GetToolbarItems(int requestId)

internal async Task SetToolbarItems(int requestId, string toolbarItemsJson)
{
try
{
var toolbarItems =
PSPDFKit.UI.ToolbarComponents.Factory.FromJsonArray(JsonArray.Parse(toolbarItemsJson));
await Pdfview.Controller.SetToolbarItemsAsync(toolbarItems.ToList());
}
catch (Exception e)
{
this.GetReactContext().GetNativeModule<UIManagerModule>().EventDispatcher.DispatchEvent(
new PdfViewDataReturnedEvent(this.GetTag(), requestId, e.Message)
);
}
await RunOperationAndFireEvent(requestId,
async () =>
{
var toolbarItems =
PSPDFKit.UI.ToolbarComponents.Factory.FromJsonArray(JsonArray.Parse(toolbarItemsJson));
await Pdfview.Controller.SetToolbarItemsAsync(toolbarItems.ToList());
}
);
}

internal async Task CreateAnnotation(int requestId, string annotationJsonString)
Expand Down

0 comments on commit 6215cea

Please sign in to comment.