Browse Source

Only leave and join real conversations

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/2965/head
Joas Schilling 6 years ago
parent
commit
c029e39586
No known key found for this signature in database GPG Key ID: 7076EA9751AACDDA
  1. 21
      src/FilesSidebarTabApp.vue
  2. 6
      src/mainFilesSidebarLoader.js
  3. 8
      src/services/filesIntegrationServices.js

21
src/FilesSidebarTabApp.vue

@ -163,7 +163,12 @@ export default {
methods: {
async joinConversation() {
await this.getFileConversation()
try {
await this.getFileConversation()
} catch (error) {
console.debug('Could not get file conversation. Is it a file and shared?')
return
}
await joinConversation(this.token)
@ -231,7 +236,7 @@ export default {
if (Axios.isCancel(exception)) {
console.debug('The request has been canceled', exception)
} else {
console.debug(exception)
throw exception
}
}
},
@ -294,7 +299,11 @@ export default {
// FileInfo it is necessary to query the server.
// FIXME If the file is shared this will create the conversation
// if it does not exist yet.
this.isTalkSidebarSupportedForFile = (await getFileConversation({ fileId: fileInfo.id })) || false
try {
this.isTalkSidebarSupportedForFile = (await getFileConversation({ fileId: fileInfo.id })) || false
} catch (error) {
this.isTalkSidebarSupportedForFile = false
}
return
}
@ -318,7 +327,11 @@ export default {
// FileInfo it is necessary to query the server.
// FIXME If the file is shared this will create the conversation
// if it does not exist yet.
this.isTalkSidebarSupportedForFile = (await getFileConversation({ fileId: fileInfo.id })) || false
try {
this.isTalkSidebarSupportedForFile = (await getFileConversation({ fileId: fileInfo.id })) || false
} catch (error) {
this.isTalkSidebarSupportedForFile = false
}
return
}

6
src/mainFilesSidebarLoader.js

@ -29,10 +29,14 @@ const isEnabled = function(fileInfo) {
return true
}
const token = OCA.Talk.store.getters.getToken()
// If the Talk tab can not be displayed then the current conversation is
// left; this must be done here because "setFileInfo" will not get
// called with the new file if the tab can not be displayed.
leaveConversation(OCA.Talk.store.getters.getToken())
if (token) {
leaveConversation(token)
}
OCA.Talk.store.dispatch('updateTokenAndFileIdForToken', {
newToken: null,

8
src/services/filesIntegrationServices.js

@ -31,12 +31,8 @@ import { generateOcsUrl } from '@nextcloud/router'
* @returns {String} the conversation token
*/
const getFileConversation = async function({ fileId }, options) {
try {
const response = await axios.get(generateOcsUrl('apps/spreed/api/v1', 2) + `file/${fileId}`)
return response
} catch (error) {
console.debug('Error while getting the token: ', error)
}
const response = await axios.get(generateOcsUrl('apps/spreed/api/v1', 2) + `file/${fileId}`)
return response
}
/**

Loading…
Cancel
Save