From c7c21c5383d355458065a0671ef845854ea09776 Mon Sep 17 00:00:00 2001 From: supertiger1234 Date: Mon, 22 Apr 2019 10:58:49 +0100 Subject: [PATCH] bug fixes with notification --- src/components/app/MyMiniInformation.vue | 1 - src/components/app/RightPanel.vue | 123 +++++++++++------- .../app/relationships/OnlineFriends.vue | 12 +- .../app/relationships/RecentFriends.vue | 2 +- src/store/modules/socketIOModule.js | 4 +- src/views/App.vue | 8 +- 6 files changed, 100 insertions(+), 50 deletions(-) diff --git a/src/components/app/MyMiniInformation.vue b/src/components/app/MyMiniInformation.vue index d7c4161..46f83b4 100644 --- a/src/components/app/MyMiniInformation.vue +++ b/src/components/app/MyMiniInformation.vue @@ -55,7 +55,6 @@ export default { }, async changeStatus (status){ // emit to server to change their status. - console.log(status) const {ok, error, result} = await settingsService.setStatus(status); if (ok && result.data.status == true) { this.$store.dispatch('changeStatus', result.data.set) diff --git a/src/components/app/RightPanel.vue b/src/components/app/RightPanel.vue index ecf2f10..f394bf5 100644 --- a/src/components/app/RightPanel.vue +++ b/src/components/app/RightPanel.vue @@ -2,12 +2,15 @@
- menu + menu
- Welcome back, {{user.username}}! + Welcome back, {{user.username}}! -
+
{{channelName}}
@@ -37,10 +40,9 @@
Select a person to message!
- -
+
- +
@@ -62,12 +64,14 @@ >
@@ -98,7 +102,7 @@ import uploadsQueue from "@/components/app/uploadsQueue.vue"; import emojiSuggestions from "@/components/app/emojiSuggestions.vue"; import emojiPanel from "@/components/app/emojiPanel.vue"; import emojiParser from "@/utils/emojiParser.js"; -import statuses from '@/utils/statuses'; +import statuses from "@/utils/statuses"; export default { components: { @@ -116,7 +120,7 @@ export default { postTimerID: null, getTimerID: null, typing: false, - whosTyping: "", + whosTyping: "" }; }, methods: { @@ -143,7 +147,7 @@ export default { if (this.message == "") return; if (this.message.length > 5000) return; - (this.$store.dispatch('setEmojiArray', null)); + this.$store.dispatch("setEmojiArray", null); clearInterval(this.postTimerID); this.postTimerID = null; this.messageLength = 0; @@ -248,15 +252,16 @@ export default { ); if (cursorLetter.trim() == "" || cursorWord.endsWith(":")) - return (this.$store.dispatch('setEmojiArray', null)); + return this.$store.dispatch("setEmojiArray", null); if (!cursorWord.startsWith(":") || cursorWord.length <= 2) - return (this.$store.dispatch('setEmojiArray', null)); + return this.$store.dispatch("setEmojiArray", null); const searchArr = emojiParser.searchEmoji(cursorWord.slice(1, -1)); - if (searchArr.length <= 0) return (this.$store.dispatch('setEmojiArray', null)); + if (searchArr.length <= 0) + return this.$store.dispatch("setEmojiArray", null); - (this.$store.dispatch('setEmojiArray', searchArr)); + this.$store.dispatch("setEmojiArray", searchArr); }, async onInput(event) { this.resize(event); @@ -271,25 +276,31 @@ export default { this.resize(event); this.showEmojiPopout(event); }, - enterEmojiSuggestion(){ + enterEmojiSuggestion() { const emoji = this.emojiArray[this.emojiIndex]; - this.$store.dispatch('settingsModule/addRecentEmoji', emoji.name || emoji.shortcodes[0]) + this.$store.dispatch( + "settingsModule/addRecentEmoji", + emoji.name || emoji.shortcodes[0] + ); this.$refs["input-box"].focus(); - const emojiShortCode = `:${emoji.name || emoji.shortcodes[0]}: ` - const cursorPosition = this.$refs['input-box'].selectionStart; + const emojiShortCode = `:${emoji.name || emoji.shortcodes[0]}: `; + const cursorPosition = this.$refs["input-box"].selectionStart; const cursorWord = this.ReturnWord(this.message, cursorPosition); const start = cursorPosition - cursorWord.length; const end = cursorPosition; - this.message = this.message.substring(0, start) + emojiShortCode + this.message.substring(end); - this.$store.dispatch('setEmojiArray', null); + this.message = + this.message.substring(0, start) + + emojiShortCode + + this.message.substring(end); + this.$store.dispatch("setEmojiArray", null); }, - enterEmojiPanel(shortcode){ + enterEmojiPanel(shortcode) { const target = this.$refs["input-box"]; target.focus(); - document.execCommand('insertText', false, `:${shortcode}: `); - this.$store.dispatch('settingsModule/addRecentEmoji', shortcode) + document.execCommand("insertText", false, `:${shortcode}: `); + this.$store.dispatch("settingsModule/addRecentEmoji", shortcode); }, keyDown(event) { this.resize(event); @@ -299,7 +310,7 @@ export default { // and the shift key is not held if (!event.shiftKey) { event.preventDefault(); - if (this.emojiArray){ + if (this.emojiArray) { this.enterEmojiSuggestion(); return; } @@ -374,8 +385,8 @@ export default { }, 2500); }; bus.$on("newMessage", this.hideTypingStatus); - bus.$on("emojiSuggestions:Selected", this.enterEmojiSuggestion) - bus.$on("emojiPanel:Selected", this.enterEmojiPanel) + bus.$on("emojiSuggestions:Selected", this.enterEmojiSuggestion); + bus.$on("emojiPanel:Selected", this.enterEmojiPanel); //dismiss notification on focus window.onfocus = () => { bus.$emit("title:change", "Nertivia"); @@ -392,8 +403,8 @@ export default { }, beforeDestroy() { bus.$off("newMessage", this.hideTypingStatus); - bus.$off("emojiSuggestions:Selected", this.enterEmojiSuggestion) - bus.$on("emojiPanel:Selected", this.enterEmojiPanel) + bus.$off("emojiSuggestions:Selected", this.enterEmojiSuggestion); + bus.$on("emojiPanel:Selected", this.enterEmojiPanel); delete this.$options.sockets.typingStatus; }, computed: { @@ -431,18 +442,32 @@ export default { return this.$store.getters.emojiArray; }, emojiPanelShow() { - return this.$store.getters.popouts.emojiPanel + return this.$store.getters.popouts.emojiPanel; }, emojiIndex() { return this.$store.getters.getEmojiIndex; }, userStatusColor() { - const allFriends = this.$store.getters.user.friends; + const selectedChannel = this.$store.getters.selectedChannelID; - const arr = Object.keys(allFriends).map(el => allFriends[el]); - const find = arr.find(el => el.channelID === selectedChannel); - if (!find) return statuses[0].color; - return statuses[find.recipient.status || 0].color + const channel = this.$store.getters.channels[selectedChannel]; + + let status = 0; + if (!channel) { + status = 0; + }else if (this.$store.getters.user.friends[channel.recipients[0].uniqueID]) { + status = this.$store.getters.user.friends[channel.recipients[0].uniqueID].recipient.status || 0 + } + return statuses[status].color + + + // const allFriends = this.$store.getters.user.friends; + // const selectedChannel = this.$store.getters.selectedChannelID; + // const arr = Object.keys(allFriends).map(el => allFriends[el]); + // const find = arr.find(el => el.channelID === selectedChannel); + // console.log(find) + // if (!find) return statuses[0].color; + // return statuses[find.recipient.status || 0].color; } } }; @@ -451,9 +476,7 @@ export default {