\n \n
\n {{ index }} {{ message }}\n \n \n \n\n\n\n","import mod from \"-!../../../../../../node_modules/cache-loader/dist/cjs.js??ref--12-0!../../../../../../node_modules/thread-loader/dist/cjs.js!../../../../../../node_modules/babel-loader/lib/index.js!../../../../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./MessageList.vue?vue&type=script&lang=js&\"; export default mod; export * from \"-!../../../../../../node_modules/cache-loader/dist/cjs.js??ref--12-0!../../../../../../node_modules/thread-loader/dist/cjs.js!../../../../../../node_modules/babel-loader/lib/index.js!../../../../../../node_modules/cache-loader/dist/cjs.js??ref--0-0!../../../../../../node_modules/vue-loader/lib/index.js??vue-loader-options!./MessageList.vue?vue&type=script&lang=js&\"","import { render, staticRenderFns } from \"./MessageList.vue?vue&type=template&id=3946dcbb&\"\nimport script from \"./MessageList.vue?vue&type=script&lang=js&\"\nexport * from \"./MessageList.vue?vue&type=script&lang=js&\"\n\n\n/* normalize component */\nimport normalizer from \"!../../../../../../node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n null,\n null\n \n)\n\nexport default component.exports","import Vue from \"vue\";\nimport { getNewUnreadMessage } from \"./index\";\n\nexport default Vue.observable({\n clickNotClose: true,\n isLeftSidebarActive: true,\n isMessageContentActive: false,\n newChatUnread: [],\n newPM: [],\n newWebboardReply: [],\n selectedPanel: 0,\n panels: ['pm', 'chat', 'webboard'],\n currentMessage: null,\n currentTopic: null,\n currentViewingMessages: [],\n currentViewingMessageCursor: 0,\n currentViewingMessageType: \"pm\",\n messagePool: {\n pm: [],\n webboard: [],\n chat: []\n },\n activeListType: \"recent\",\n unread: {\n pm: getNewUnreadMessage(\"pm\"),\n chat: getNewUnreadMessage(\"chat\"),\n webboard: getNewUnreadMessage(\"webboard\"),\n }\n });\n","import Vue from \"vue\";\n\nexport default Vue.observable({\n \n});\n","import Datastore from \"@/developing/datastore\";\nimport store from '@/store'; // Vuex store for import the module's states.\nimport local from \"./data-local\";\nimport dev from \"./data-dev\";\n\n//\nexport const state = { Datastore, store: store.state, local, dev }\n\n//\nexport const createList = async function (channel, list_type, topics) {\n // Get ID of Topics to Generate A List\n // with condition of list (All, Recent, )\n // console.log(channel, list_type, topics);\n if (!channel || !list_type || !topics) { return }\n\n}\n\n//\nexport const constructTopicsFromList = async function (channel, list_type) {\n // console.log(\"constructTopicFromList\");\n\n // const limit = 10;\n // const cursor = 0;\n\n let storedList = await Datastore.Message.getList(channel, list_type);\n let list = null;\n let topics = [];\n\n // console.log(\"storedList\", storedList);\n\n if (typeof storedList === \"undefined\") {\n // console.log(\"Request server to generate and send back a new list\");\n // list = createNewList(channel, type);\n } else {\n list = storedList.data;\n }\n\n // console.log(\"Check constructTopicsFromList\", list);\n\n if (Array.isArray(list)) {\n let diff = [...list];\n for (let i = list.length - 1; i >= 0; i -= 1) {\n const item = list[i];\n const topic = await Datastore.Message.load(\"topic\", channel, item.id);\n if (topic) {\n diff.splice(i, 1);\n topics.push(topic);\n }\n }\n\n // console.log(\"diff\", diff);\n\n if (diff.length > 0) {\n diff = diff.map(({ id }) => ({ id }));\n const { status, data } = await store.dispatch(\"Communication/getMessageTopicsByIds\", { channel, list: diff });\n // console.log(\"Check\", status, data);\n\n if (status.success && data[channel]) {\n topics = [...topics, ...data[channel]];\n topics.map(topic => Datastore.Message.save(\"topic\", channel, topic.id, topic));\n }\n }\n }\n\n return topics\n}\n\n// Construct Messages to Show on UI\nexport const constructMessagesFromList = function (channel, list_id) {\n if (!channel || !list_id) {\n return // Return error\n }\n\n const topics = [];\n const messages = [];\n\n const list = Datastore.Message.load(`list/${channel}`, list_id);\n // console.log(\"List in constructMessageFromList\", list, channel, list_id);\n\n if (list && Array.isArray(list.list)) {\n\n // console.log(\"Load topics and messages to create a new list\")\n for (let topicItem of list.list) {\n const topic = Datastore.Message.load(\"topic/pm\", topicItem.id);\n\n\n if (topic) {\n topics.push(topic);\n\n if (topic.messageIndex.length > 0) {\n\n for (let messageItem of topic.messageIndex) {\n const message = Datastore.Message.load(\"message/pm\", messageItem.id);\n messages.push(message);\n }\n }\n }\n }\n }\n\n return { topics, messages };\n}\n\n//\nexport async function loadTopicList(channel = \"all\", type = \"recent\") {\n\n const data = { list: {} };\n\n switch (channel) {\n case \"pm\":\n data.list.pm = await getPMTopicList(type);\n break;\n case \"chat\":\n data.list.pm = await getChatTopicList(type);\n break;\n case \"webboard\":\n data.list.pm = await getWebboardTopicList(type);\n break;\n default:\n data.list.pm = await getPMTopicList(type);\n data.list.chat = await getChatTopicList(type);\n data.list.webboard = await getWebboardTopicList(type);\n break;\n }\n\n return data;\n /*\n // Create Message\n storeMessagesToCache({ channel: \"pm\", messageKey: \"privateMessageReplies\", data: pm });\n storeMessagesToCache({ channel: \"chat\", messageKey: \"chatMessage\", data: chat });\n storeMessagesToCache({ channel: \"webboard\", messageKey: \"webBoardReplies\", data: webboard });\n\n */\n}\n\n//\nexport function getNewUnreadMessage(channel) {\n return Datastore.Message.getState(channel, \"unread\") || 0;\n // if (channel && this.$data.$local.messagePool[channel]) {\n // const unreadMessages = this.$data.$local.messagePool[channel].filter(message => message.unread === true);\n // return unreadMessages.length;\n // }\n}\n\n\n//////////////////////////\n//* Private Functions */\n//////////////////////////\n\n//\nasync function getPMTopicList(type) {\n // console.log(\"getPMTopicList\", type);\n\n const pool = Datastore.Message.list.has(`pm/${type}`);\n // console.log(\"PM Pool\", pool);\n if (pool) {\n // Send cache key to check/get update, if exists\n } else {\n // const idb_pm_recent_list = null;\n const idb = await Datastore.Message.idb.list.get(`pm/${type}`);\n // console.log(\"PM IDB\", idb);\n\n if (idb) {\n Datastore.Message.list.set(`pm/recent`, idb);\n return idb;\n } else {\n const response = await store.dispatch(\"Communication/getRecentMessageList\", { channel: \"pm\", type });\n // console.log(\"Check\", response);\n\n const { status, data } = response;\n if (!status) {\n // console.log(\"Error on Communication/getRecentMessageList\");\n return\n }\n\n if (status.success && data) {\n const { pm } = data;\n if (pm) {\n await Datastore.Message.save(\"list\", \"pm\", type, pm);\n return pm;\n }\n }\n }\n }\n}\n\n//\nasync function getChatTopicList(type) {\n // console.log(\"getChatTopicList\", type);\n\n const pool = Datastore.Message.list.has(`chat/${type}`);\n // console.log(\"Chat Pool\", pool);\n if (pool) {\n // Send cache key to check/get update, if exists\n } else {\n // const idb_pm_recent_list = null;\n const idb = await Datastore.Message.idb.list.get(`chat/${type}`);\n // console.log(\"Chat IDB\", idb);\n\n if (idb) {\n Datastore.Message.list.set(`chat/recent`, idb);\n return idb;\n } else {\n const response = await store.dispatch(\"Communication/getRecentMessageList\", { channel: \"chat\", type });\n const { status, data } = response;\n if (status.success && data) {\n const { chat } = data;\n if (chat) {\n await Datastore.Message.save(\"list\", \"chat\", type, chat);\n return chat;\n }\n }\n }\n }\n}\n\n//\nasync function getWebboardTopicList(type) {\n // console.log(\"getWebboardTopicList\", type);\n\n const pool = Datastore.Message.list.has(`webboard/${type}`);\n // console.log(\"Webboard Pool\", pool);\n if (pool) {\n // Send cache key to check/get update, if exists\n } else {\n // const idb_webboard_recent_list = null;\n const idb = await Datastore.Message.idb.list.get(`webboard/${type}`);\n // console.log(\"Webboard IDB\", idb);\n\n if (idb) {\n Datastore.Message.list.set(`webboard/recent`, idb);\n return idb;\n } else {\n const response = await store.dispatch(\"Communication/getRecentMessageList\", { channel: \"webboard\", type });\n const { status, data } = response;\n if (status.success && data) {\n const { webboard } = data;\n if (webboard) {\n await Datastore.Message.save(\"list\", \"webboard\", type, webboard);\n return webboard;\n }\n }\n }\n }\n}\n\n/*\nfunction storeMessagesToCache({ channel, messageKey, data } ) {\n // const list = [];\n\n // Message.saveList(channel, data);\n\n // for (let topic of data) {\n // topic.messageIndex = [];\n\n // // // Save all message to flatmap\n // if (topic[messageKey]) {\n // for (let message of topic[messageKey]) {\n // Message.save(`message/${channel}`, message.id, message);\n // // console.log(message);\n // topic.messageIndex.push({ id: message.id, timestamp: new Date(message[\"sendDate\"]).getTime(), read: message.readDate ? true : false });\n // }\n // // delete topic[messageKey];\n // }\n\n // // console.log(topic);\n // list.push({ id: topic.id, timestamp: new Date(topic[\"sendDate\"]).getTime(), read: topic.readDate ? true : false });\n // Message.save(`topic/${channel}`, topic.id, topic);\n\n // }\n\n // Message.save(`list/${channel}`, \"all\", { list });\n}\n*/\n\n//\n/* function createNewList (channel, type) {\n const listOfAll = Message.getList(channel, \"all\");\n let list = null;\n if ((listOfAll) && listOfAll.list) {\n if (listOfAll.list.length > 1) {\n list = [ ...listOfAll.list ];\n if (type === \"recent\") {\n list = listOfAll.list.sort((a, b) => b.timestamp - a.timestamp);\n } else if (type === \"unread\") {\n list = listOfAll.list.filter(x => !x[\"read\"]).sort((a, b) => b.timestamp - a.timestamp);\n }\n\n Message.save(`list/${channel}`, type, { list });\n }\n }\n return list\n}\n*/\n"],"sourceRoot":""}