Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Commit

Permalink
fix: fix group message push error
Browse files Browse the repository at this point in the history
  • Loading branch information
Crazyokd committed Apr 30, 2023
1 parent 42dfde5 commit a03877b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/mixins/socketMixin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { wsType2messageType } from "@/utils/common";
import { wsType2messageType, wsType2type } from "@/utils/common";

export default {
mounted() {
Expand All @@ -10,7 +10,7 @@ export default {
message: m.content,
});
m["contentType"] = wsType2messageType(m.ws_type);
this.$store.state.messages["user" + m.fromId].push(m);
this.$store.state.messages[wsType2type(m)].push(m);
this.$bus.$emit("scrollToBottom");
}
};
Expand Down
6 changes: 5 additions & 1 deletion src/utils/common.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
export function wsType2messageType(wsType) {
return (wsType - 3) / 2;
return parseInt((wsType - 3) / 2);
}

export function messageType2wsType(messageType, isGroup) {
return messageType * 2 + 3 + isGroup;
}

export function wsType2type(m) {
return m.ws_type % 2 === 0 ? "group" + m.toId : "user" + m.fromId;
}

import { audioExtensions, videoExtensions } from "@/config/file-extensions";
export function getFileSpecificType(fileName) {
if (isIncludeExtension(audioExtensions, fileName)) {
Expand Down

0 comments on commit a03877b

Please sign in to comment.