Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarco Ambrosini <marcoambrosini@pm.me>2022-06-22 18:18:48 +0300
committerJoas Schilling <coding@schilljs.com>2022-08-31 09:15:36 +0300
commitbb67c6f9a0ab0a0c14c9e37a72799cd44fc6d68e (patch)
tree26712e171c3c9044005d60603d802371ece62b96 /src
parentac49d7b8c995dc1f00a9514a99be6bfeea8cce4a (diff)
Add service and ability to create and share a text file
Signed-off-by: Marco Ambrosini <marcoambrosini@pm.me>
Diffstat (limited to 'src')
-rw-r--r--src/components/NewMessageForm/NewMessageForm.vue11
-rw-r--r--src/services/filesSharingServices.js19
2 files changed, 26 insertions, 4 deletions
diff --git a/src/components/NewMessageForm/NewMessageForm.vue b/src/components/NewMessageForm/NewMessageForm.vue
index 3a4a9383d..5223159cd 100644
--- a/src/components/NewMessageForm/NewMessageForm.vue
+++ b/src/components/NewMessageForm/NewMessageForm.vue
@@ -59,7 +59,7 @@
</NcActionButton>
<NcActionButton v-if="canShareFiles"
:close-after-click="true"
- @click.prevent="createTextFile">
+ @click.prevent="handleCreateTextFile">
<TextBox slot="icon" :size="20" />
{{ t('spreed', 'Create text file') }}
</NcActionButton>
@@ -163,7 +163,7 @@ import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcEmojiPicker from '@nextcloud/vue/dist/Components/NcEmojiPicker.js'
import { EventBus } from '../../services/EventBus.js'
-import { shareFile } from '../../services/filesSharingServices.js'
+import { shareFile, createTextFile } from '../../services/filesSharingServices.js'
import { CONVERSATION, PARTICIPANT } from '../../constants.js'
import Paperclip from 'vue-material-design-icons/Paperclip.vue'
import EmoticonOutline from 'vue-material-design-icons/EmoticonOutline.vue'
@@ -584,8 +584,11 @@ export default {
this.showSimplePollsEditor = value
},
- createTextFile() {
- console.log('asdfsadfsd')
+ // Create text file and share it to a conversation
+ async handleCreateTextFile() {
+ const filePath = 'somesdsaddfsalkjnaasdasdme.md'
+ await createTextFile(filePath)
+ shareFile(filePath, this.token)
},
},
}
diff --git a/src/services/filesSharingServices.js b/src/services/filesSharingServices.js
index 2b9b2f1fd..26008a1a7 100644
--- a/src/services/filesSharingServices.js
+++ b/src/services/filesSharingServices.js
@@ -55,6 +55,25 @@ const shareFile = async function(path, token, referenceId, metadata) {
}
}
+/**
+ * Share a text file to a conversation
+ *
+ * @param { string } filePath the file path
+ * @return { object } the file object
+ */
+const createTextFile = async function(filePath) {
+ try {
+ return axios.post(
+ generateOcsUrl('apps/files/api/v1/templates/create'),
+ {
+ filePath,
+ })
+ } catch (error) {
+ console.debug(error)
+ }
+}
+
export {
shareFile,
+ createTextFile,
}