Skip to content

Commit 31c6fec

Browse files
committed
fix tray icon
fix tray icon tray icon fix fix tray icon replace convs with chats
1 parent b634473 commit 31c6fec

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

source/browser/conversation-list.ts

+33-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ const padding = {
1414
bottom: 3,
1515
left: 0,
1616
};
17+
18+
const translationDict = {
19+
en : {markRead : 'Mark as read',
20+
chats : 'Chats',
21+
},
22+
el : {markRead : 'Τα έχω διαβάσει',
23+
chats : 'Συνομιλίες',
24+
},
25+
};
26+
27+
let translatedStrings = {
28+
markRead : "",
29+
chats : "",
30+
}
1731

1832
function drawIcon(size: number, img?: HTMLImageElement): HTMLCanvasElement {
1933
const canvas = document.createElement('canvas');
@@ -131,7 +145,7 @@ async function createConversationNewDesign(element: HTMLElement): Promise<Conver
131145
*/
132146

133147
conversation.selected = Boolean(element.querySelector('[role=row] [role=link] > div:only-child'));
134-
conversation.unread = Boolean(element.querySelector('[aria-label="Mark as Read"]'));
148+
conversation.unread = Boolean(element.querySelector(`[aria-label="${translatedStrings.markRead}"]`));
135149

136150
const unparsedLabel = element.querySelector<HTMLElement>('.a8c37x1j.ni8dbmo4.stjgntxs.l9j0dhe7 > span > span')!;
137151
conversation.label = await getLabel(unparsedLabel);
@@ -154,7 +168,14 @@ async function createConversationList(): Promise<Conversation[]> {
154168
return [];
155169
}
156170

157-
const elements: HTMLElement[] = [...list.children] as HTMLElement[];
171+
const convList = list.querySelector('div[class=x1n2onr6]');
172+
173+
if (!convList) {
174+
console.error('No conversations found');
175+
return [];
176+
}
177+
178+
const elements: HTMLElement[] = [...convList.children] as HTMLElement[];
158179

159180
// Remove last element from childer list
160181
elements.splice(-1, 1);
@@ -213,9 +234,17 @@ function countUnread(mutationsList: MutationRecord[]): void {
213234
}
214235
}
215236

216-
window.addEventListener('load', async () => {
217-
const sidebar = await elementReady('[role=navigation]', {stopOnDomReady: false});
237+
function transDictLookUp(){
238+
let locale = document.documentElement.lang;
239+
let currDict = translationDict[locale as keyof typeof translationDict];
218240

241+
translatedStrings.chats = currDict['chats'];
242+
translatedStrings.markRead = currDict['markRead'];
243+
}
244+
245+
window.addEventListener('load', async () => {
246+
transDictLookUp();
247+
const sidebar = await elementReady(`[aria-label=${translatedStrings.chats}]`, {stopOnDomReady: false});
219248
if (sidebar) {
220249
const conversationListObserver = new MutationObserver(async () => sendConversationList());
221250
const conversationCountObserver = new MutationObserver(countUnread);

0 commit comments

Comments
 (0)