197 lines
5.8 KiB
JavaScript
197 lines
5.8 KiB
JavaScript
import privatesContextMenu from "@chat/json/privatesContextMenu.json";
|
|
import groupsContextMenu from "@chat/json/groupsContextMenu.json";
|
|
import lobbiesChildContextMenu from "@chat/json/lobbiesChildContextMenu.json";
|
|
import lobbiesParentContextMenu from "@chat/json/lobbiesParentContextMenu.json";
|
|
|
|
export default {
|
|
mounted() {
|
|
const vm = this;
|
|
this.closeForwardModal();
|
|
|
|
// dynamic import : method two
|
|
// import(`~/chat/json/messagesContextMenu.json`)
|
|
// .then((obj) => {
|
|
// this.contextMenu = obj.default;
|
|
// })
|
|
// .catch((err) => {});
|
|
if (this.$route.name == "privates")
|
|
this.commonContextMenu = privatesContextMenu;
|
|
|
|
if (this.$route.name == "groups")
|
|
this.commonContextMenu = groupsContextMenu;
|
|
|
|
if (this.$route.name == "lobbies") {
|
|
if (this.listGetter?.parent_id)
|
|
this.commonContextMenu = lobbiesChildContextMenu;
|
|
else this.commonContextMenu = lobbiesParentContextMenu;
|
|
}
|
|
if (this.$route.name == "unReads")
|
|
this.commonContextMenu = groupsContextMenu;
|
|
|
|
this.pagination.offset = 0;
|
|
this.pagination.pageBottom = 1;
|
|
this.pagination.pageTop = 0;
|
|
this.pagination.page = 1;
|
|
this.pagination.seen_date = 0;
|
|
|
|
// check if redirected from other systems.
|
|
// or clicked on a copy link.
|
|
if (this.$route.query["group-id"] && this.$route.query["message-id"]) {
|
|
this.groupId = this.$route.query["group-id"];
|
|
this.messageId = this.$route.query["message-id"];
|
|
this.isRedirectedFromOtherSystems = true;
|
|
}
|
|
|
|
// when user forward a message from the search-modal component.
|
|
if (this.getForwardItem) {
|
|
this.userId = this.getForwardItem?.message.user.id;
|
|
// this.messageId = this.getForwardItem.forwardFrom.id;
|
|
this.isRedirectedFromOtherSystems = false;
|
|
this.isForward = true;
|
|
this.mainCommentor = this.getForwardItem?.message;
|
|
this.isMainEditMode = true;
|
|
this.pagination.offset = 0;
|
|
this.direction = -1;
|
|
this.seenDate = -1;
|
|
}
|
|
|
|
if (this.listGetter) {
|
|
// this.pagination.offset = 0;
|
|
this.pagination.seen_date = this.listGetter?.seen_messages?.seen_date;
|
|
this.pagination.page = 1;
|
|
this.pagination.pageBottom = 1;
|
|
this.pagination.pageTop = 0;
|
|
|
|
if (
|
|
this.pagination.seen_date == undefined ||
|
|
this.pagination.seen_date == ""
|
|
) {
|
|
this.pagination.seen_date = -1;
|
|
this.pagination.page = -1;
|
|
this.pagination.pageBottom = 0;
|
|
this.pagination.pageTop = -1;
|
|
}
|
|
|
|
if (this.listGetter?.is_group == 0) {
|
|
this.limit = 100;
|
|
if (this.listGetter.replyto) {
|
|
this.pagination.seen_date = this.listGetter.p_date_c;
|
|
}
|
|
}
|
|
|
|
// first page request
|
|
this.getMessages(true, true).then((response) => {
|
|
this.localComments = response.data; //this.localComments.concat(response.data);
|
|
this.pagination.seen_date = response.pagination.new_seen_date;
|
|
|
|
// when user searching.
|
|
setTimeout(() => {
|
|
this.jumpSpecialMessage();
|
|
}, 1000);
|
|
});
|
|
|
|
// if user is not joined, dont get members.
|
|
// if (!this.listGetter?.show_joined) {
|
|
this.getGroupMembers();
|
|
// }
|
|
}
|
|
|
|
document
|
|
.getElementById("paste-section")
|
|
.addEventListener("paste", async (e) => {
|
|
vm.pasting = true;
|
|
vm.handlePasteEvent(e);
|
|
});
|
|
if (this.isIssueGroup() || this.isAnswerGroup()) {
|
|
if (this.isIssueGroup()) {
|
|
this.buttonTitle = "مشاهده مساله";
|
|
this.buttonName = "issues";
|
|
} else if (this.isAnswerGroup()) {
|
|
this.buttonTitle = "مشاهده پاسخ";
|
|
this.buttonName = "answers";
|
|
}
|
|
}
|
|
|
|
// events fired from Auth.vue and authMixin.js
|
|
// event fired from authMixin.js
|
|
this.$root.$on("authenticated-by-modal", () => {
|
|
// this.$route.query["invite-id"] = undefined;
|
|
this.$set(this.$route.query, "invite-id", undefined);
|
|
this.getUserPermissionTags();
|
|
|
|
this.initServices();
|
|
this.closeAuthModal();
|
|
this.getGroupMembers();
|
|
this.toLastItem();
|
|
});
|
|
},
|
|
methods: {
|
|
jumpSpecialMessage(){
|
|
|
|
let jumpMessageId = 0;
|
|
let jumpMessageIndex = 0;
|
|
|
|
// if listgetter contains a message or replay item.
|
|
if (this.listGetter?.is_group == 0) {
|
|
|
|
if (this.listGetter.replyto) {
|
|
const index = this.localComments.findIndex(
|
|
(item) => item.id == this.listGetter.replyto
|
|
);
|
|
const res = this.localComments.find(
|
|
(item) => item.id == this.listGetter.replyto
|
|
);
|
|
this.openReplays(res, index);
|
|
|
|
jumpMessageId = res.id;
|
|
|
|
} else {
|
|
const index = this.localComments.findIndex(
|
|
(item) => item.id == this.listGetter.id
|
|
);
|
|
jumpMessageIndex = index;
|
|
jumpMessageId = this.listGetter?.id;
|
|
|
|
}
|
|
}
|
|
// if listgetter contains group item
|
|
else {
|
|
if (this.$route.query["message-id"]) {
|
|
|
|
const index = this.localComments.findIndex(
|
|
(item) => item.id == this.$route.query["message-id"]
|
|
);
|
|
const res = this.localComments.find(
|
|
(item) => item.id == this.$route.query["message-id"]
|
|
);
|
|
|
|
jumpMessageIndex = index;
|
|
jumpMessageId = res.id;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
if(jumpMessageId)
|
|
document.getElementById("chat-item-" + jumpMessageId).scrollIntoView({
|
|
top: 100,
|
|
behavior: "smooth",
|
|
block: "center",
|
|
});
|
|
|
|
if(jumpMessageIndex)
|
|
this.markActive(this.localComments, jumpMessageIndex);
|
|
},
|
|
|
|
isIssueGroup() {
|
|
return this.listGetter?.type == 2;
|
|
},
|
|
isAnswerGroup() {
|
|
return this.listGetter?.type == 3;
|
|
},
|
|
isPrivate() {
|
|
return this.listGetter?.type == 0;
|
|
},
|
|
},
|
|
};
|