Merge pull request 'fix not found el' (#2) from zelda.fix-some-i-dont-no into main
Reviewed-on: #2
This commit is contained in:
commit
b226c597d1
File diff suppressed because one or more lines are too long
|
|
@ -59,16 +59,15 @@ export class ContentService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _clickToConversation(id: string) {
|
private _clickToConversation(id: string) {
|
||||||
const el = document.getElementById(`chat-list-item_${id}`);
|
// New Teams DOM: find via title element → closest treeitem
|
||||||
|
const titleEl = document.getElementById(`title-chat-list-item_${id}`);
|
||||||
|
const el =
|
||||||
|
titleEl?.closest<HTMLElement>('[data-testid="list-item"]') ??
|
||||||
|
document.getElementById(`chat-list-item_${id}`);
|
||||||
|
|
||||||
if (el) {
|
if (el) {
|
||||||
el.scrollIntoView({
|
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
||||||
behavior: "smooth", // hoặc "auto"
|
setTimeout(() => el.click(), 200);
|
||||||
block: "center", // cuộn sao cho phần tử nằm giữa view
|
|
||||||
});
|
|
||||||
|
|
||||||
// Đợi 1 chút cho scroll xong (nếu cần)
|
|
||||||
setTimeout(() => el.click(), 200); // delay 200ms là đủ mượt
|
|
||||||
}
|
}
|
||||||
return el?.click();
|
return el?.click();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,13 +36,27 @@ export class TeamsChatService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCurrentRoomInfo(): { room_id?: string; room_name?: string } {
|
public getCurrentRoomInfo(): { room_id?: string; room_name?: string } {
|
||||||
// const roomId = document
|
let roomId: string | undefined;
|
||||||
// .querySelector(this.elTags.root_id)
|
|
||||||
// ?.id?.split(":")[1];
|
|
||||||
|
|
||||||
const roomId = document
|
// New Teams DOM: selected treeitem has aria-selected="true" + data-fui-tree-item-value
|
||||||
|
const selectedItem = document.querySelector(
|
||||||
|
'[role="treeitem"][aria-selected="true"][data-item-type="chat"]',
|
||||||
|
);
|
||||||
|
if (selectedItem) {
|
||||||
|
const treeItemValue =
|
||||||
|
selectedItem.getAttribute("data-fui-tree-item-value") || "";
|
||||||
|
const lastSegment = treeItemValue.split("/").pop() || "";
|
||||||
|
roomId = lastSegment.includes("|")
|
||||||
|
? lastSegment.split("|")[1]
|
||||||
|
: undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fallback: old DOM
|
||||||
|
if (!roomId) {
|
||||||
|
roomId = document
|
||||||
.querySelector(this.elTags.root_id)
|
.querySelector(this.elTags.root_id)
|
||||||
?.id?.replace("chat-list-item_", "");
|
?.id?.replace("chat-list-item_", "");
|
||||||
|
}
|
||||||
|
|
||||||
const roomName = (
|
const roomName = (
|
||||||
document.querySelector(this.elTags.room_name) as HTMLElement
|
document.querySelector(this.elTags.room_name) as HTMLElement
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue