+
+
+
diff --git a/src/services/conversationSharedItemsService.js b/src/services/conversationSharedItemsService.js
new file mode 100644
index 00000000000..12922175e75
--- /dev/null
+++ b/src/services/conversationSharedItemsService.js
@@ -0,0 +1,49 @@
+/**
+ * @copyright Copyright (c) 2022 Marco Ambrosini
+ *
+ * @author Marco Ambrosini
+ *
+ * @license AGPL-3.0-or-later
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+import axios from '@nextcloud/axios'
+import { generateOcsUrl } from '@nextcloud/router'
+
+// Returns the last n shared items for each category and for a given conversation
+// (n = limit)
+const getSharedItemsOverview = async function(token, limit) {
+ return axios.get(generateOcsUrl('apps/spreed/api/v1/chat/{token}/share/overview', {
+ token,
+ limit,
+ }))
+}
+
+// Returns the last 200 (or limit) shared items, given a conversation and the type
+// of shared item
+const getSharedItems = async function(token, objectType, lastKnownMessageId, limit,) {
+ return axios.get(generateOcsUrl('apps/spreed/api/v1/chat/{token}/share', {
+ token,
+ objectType,
+ lastKnownMessageId,
+ limit,
+ }))
+}
+
+export {
+ getSharedItems,
+ getSharedItemsOverview,
+}
diff --git a/src/store/conversationSharedItemsStore.js b/src/store/conversationSharedItemsStore.js
new file mode 100644
index 00000000000..9ea68d9c9cf
--- /dev/null
+++ b/src/store/conversationSharedItemsStore.js
@@ -0,0 +1,100 @@
+/**
+ * @copyright Copyright (c) 2022 Marco Ambrosini
+ *
+ * @author Marco Ambrosini
+ *
+ * @license AGPL-3.0-or-later
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+import Vue from 'vue'
+import { getSharedItemsOverview, getSharedItems } from '../services/conversationSharedItemsService'
+
+// Store structure
+// token: {
+// media: {},
+// file: {},
+// voice: {},
+// audio: {},
+// location: {}
+// deckcard: {},
+// other: {},
+
+const state = () => ({
+ state: {},
+})
+
+const getters = {
+ sharedItems: state => token => {
+ const sharedItems = {}
+ if (!state[token]) {
+ return {}
+ }
+ for (const type of Object.keys(state[token])) {
+ if (Object.keys(state[token][type]).length !== 0) {
+ sharedItems[type] = state[token][type]
+ }
+ }
+ return sharedItems
+ },
+}
+
+export const mutations = {
+ addSharedItemsOverview: (state, { token, data }) => {
+ if (!state[token]) {
+ Vue.set(state, token, {})
+ }
+ for (const type of Object.keys(data)) {
+ if (!state[token][type]) {
+ Vue.set(state[token], type, {})
+ for (const message of data[type]) {
+ if (!state[token][type]?.[message.id]) {
+ Vue.set(state[token][type], message.id, message)
+ }
+ }
+ }
+ }
+ },
+}
+
+const actions = {
+ async getSharedItems({ commit }, { token, type, lastKnownMessageId, limit }) {
+ try {
+ const response = await getSharedItems(token, type, lastKnownMessageId, limit)
+ // loop over the response elements and add them to the store
+ for (const sharedItem in response) {
+ commit('addSharedItem', sharedItem)
+ }
+
+ } catch (error) {
+ console.debug(error)
+ }
+ },
+
+ async getSharedItemsOverview({ commit }, { token }) {
+ try {
+ const response = await getSharedItemsOverview(token, 10)
+ commit('addSharedItemsOverview', {
+ token,
+ data: response.data.ocs.data,
+ })
+ } catch (error) {
+ console.debug(error)
+ }
+ },
+}
+
+export default { state, mutations, getters, actions }
diff --git a/src/store/storeConfig.js b/src/store/storeConfig.js
index 8d772fa2683..9f5fbe9c1a1 100644
--- a/src/store/storeConfig.js
+++ b/src/store/storeConfig.js
@@ -39,6 +39,7 @@ import uiModeStore from './uiModeStore'
import windowVisibilityStore from './windowVisibilityStore'
import messageActionsStore from './messageActionsStore'
import reactionsStore from './reactionsStore'
+import conversationSharedItemStore from './conversationSharedItemsStore'
export default {
modules: {
@@ -61,6 +62,7 @@ export default {
windowVisibilityStore,
messageActionsStore,
reactionsStore,
+ conversationSharedItemStore,
},
mutations: {},