@@ -115,6 +132,16 @@ class PopupApp extends Component<{}, PopupAppState> {
& ReceiverSelectorMediaType.Screen) }>
{ _("popupMediaTypeScreen") }
+
+
{ _("popupMediaSelectToLabel") }
@@ -140,13 +167,45 @@ class PopupApp extends Component<{}, PopupAppState> {
, data: {
receiver
, mediaType: this.state.mediaType
+ , filePath: this.state.filePath
}
});
}
private onSelectChange (ev: React.ChangeEvent
) {
+ const mediaType = parseInt(ev.target.value);
+
+ if (mediaType === ReceiverSelectorMediaType.File) {
+ try {
+ const filePath = window.prompt();
+
+ // Validate URL
+ const fileUrl = new URL(filePath.startsWith("file://")
+ ? filePath
+ : `file://${filePath}`);
+
+ this.setState({
+ mediaType
+ , filePath
+ });
+
+ return;
+ } catch (err) {
+ // Don't need to handle any errors
+ }
+
+ // Set media type to default if failed to set filePath
+ this.setState({
+ mediaType: this.defaultMediaType
+ });
+ } else {
+ this.setState({
+ mediaType
+ });
+ }
+
this.setState({
- mediaType: parseInt(ev.target.value)
+ filePath: null
});
}
}