From 70e71cbc2a7779889c321f3853b2122c196aab5b Mon Sep 17 00:00:00 2001 From: ebayer Date: Fri, 12 Oct 2018 21:30:00 +0300 Subject: [PATCH] Mobile: Fixes #856: Add option to open source url (#872) * Mobile: Fixes #856: Add option to open source url * Mobile: Fixes #856: Change menu wording for opening source url --- ReactNativeClient/lib/components/screens/note.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ReactNativeClient/lib/components/screens/note.js b/ReactNativeClient/lib/components/screens/note.js index 0c8d208f49..de8d153d0b 100644 --- a/ReactNativeClient/lib/components/screens/note.js +++ b/ReactNativeClient/lib/components/screens/note.js @@ -463,6 +463,17 @@ class NoteScreenComponent extends BaseScreenComponent { } } + async showSource_onPress() { + if (!this.state.note.id) return; + + let note = await Note.load(this.state.note.id); + try { + Linking.openURL(note.source_url); + } catch (error) { + await dialogs.error(this, error.message); + } + } + copyMarkdownLink_onPress() { const note = this.state.note; Clipboard.setString(Note.markdownTag(note)); @@ -472,6 +483,7 @@ class NoteScreenComponent extends BaseScreenComponent { const note = this.state.note; const isTodo = note && !!note.is_todo; const isSaved = note && note.id; + const hasSource = note && note.source_url; let output = []; @@ -496,6 +508,7 @@ class NoteScreenComponent extends BaseScreenComponent { output.push({ isDivider: true }); if (this.props.showAdvancedOptions) output.push({ title: this.state.showNoteMetadata ? _('Hide metadata') : _('Show metadata'), onPress: () => { this.showMetadata_onPress(); } }); output.push({ title: _('View on map'), onPress: () => { this.showOnMap_onPress(); } }); + if (hasSource) output.push({ title: _('Go to source URL'), onPress: () => { this.showSource_onPress(); } }); output.push({ isDivider: true }); output.push({ title: _('Delete'), onPress: () => { this.deleteNote_onPress(); } });