diff --git a/api/BaseAPI.js b/api/BaseAPI.js index ae9bfc001..446a6b84e 100644 --- a/api/BaseAPI.js +++ b/api/BaseAPI.js @@ -85,7 +85,7 @@ export default class BaseAPI { // - POSTs to session can return errors we want to handle. // - 999 can happen if people double-click, and we should just quietly drop it because the first click will // probably do the right thing. - // - otherwise pop up an error. + // - otherwise throw an exception. if ( status !== 200 || !data || @@ -97,7 +97,14 @@ export default class BaseAPI { const retstr = data && data.ret ? data.ret : 'Unknown' const statusstr = data && data.status ? data.status : 'Unknown' - if (logError) { + // Whether or not we log this error to Sentry depends. Most errors are worth logging, because they're unexpected. + // But some API calls are expected to fail, and throw an exception which is then handled in the code. We don't + // want to log those, otherwise we will spend time investigating them in Sentry. So we have a parameter which + // indicates whether we want to log this to Sentry - which can be a boolean or a function for more complex + // decisions. + const log = typeof logError === 'function' ? logError(data) : logError + + if (log) { Sentry.captureException( 'API request failed ' + path + diff --git a/api/ChatAPI.js b/api/ChatAPI.js index ba642cf2e..ab939e3d8 100644 --- a/api/ChatAPI.js +++ b/api/ChatAPI.js @@ -40,4 +40,8 @@ export default class ChatAPI extends BaseAPI { blockChat(chatid) { return this.$post('/chatrooms', { id: chatid, status: 'Blocked' }) } + + unseenCount(chatid) { + return this.$get('/chatrooms', { count: true }) + } } diff --git a/api/GroupAPI.js b/api/GroupAPI.js index ba603b537..142100f30 100644 --- a/api/GroupAPI.js +++ b/api/GroupAPI.js @@ -6,8 +6,8 @@ export default class GroupAPI extends BaseAPI { return groups } - async fetch(id) { - const { group } = await this.$get('/group', { id }) + async fetch(id, log) { + const { group } = await this.$get('/group', { id }, log) return group } } diff --git a/components/ChatButton.vue b/components/ChatButton.vue index 0b5564053..b4a4d00d7 100644 --- a/components/ChatButton.vue +++ b/components/ChatButton.vue @@ -59,15 +59,17 @@ export default { this.openChat(null, null, null, popup) }, - async openChat(event, firstmessage, firstmsgid, popup) { + async openChat(event, firstmessage, firstmsgid, popup, route = true) { this.$emit('click') console.log( 'Open chat', firstmessage, firstmsgid, this.groupid, - this.userid + this.userid, + popup ) + console.trace() if (this.groupid > 0) { // Open a chat to the mods @@ -103,8 +105,8 @@ export default { await this.$store.dispatch('popupchats/popup', { id: chatid }) - } else { - this.$router.go('/chats/' + chatid) + } else if (route) { + this.$router.push('/chats/' + chatid) } } } diff --git a/components/ChatMessageText.vue b/components/ChatMessageText.vue index 26d6c98a7..cb9d13056 100644 --- a/components/ChatMessageText.vue +++ b/components/ChatMessageText.vue @@ -2,13 +2,13 @@
-
+
-
+
{{ emessage }} {{ emessage }} @@ -16,8 +16,8 @@
-
-
+
+
{{ emessage }} {{ emessage }} @@ -37,6 +37,9 @@ + + diff --git a/components/Viewed.vue b/components/Viewed.vue new file mode 100644 index 000000000..2acabb57b --- /dev/null +++ b/components/Viewed.vue @@ -0,0 +1,29 @@ + + diff --git a/components/VolunteerOpportunitySidebar.vue b/components/VolunteerOpportunitySidebar.vue index 52f3adb11..8d6a7383b 100644 --- a/components/VolunteerOpportunitySidebar.vue +++ b/components/VolunteerOpportunitySidebar.vue @@ -1,5 +1,5 @@