Skip to content

Commit e36cd58

Browse files
lint all the things
1 parent 66cbcfa commit e36cd58

File tree

3 files changed

+56
-41
lines changed

3 files changed

+56
-41
lines changed

src/__tests__/background.test.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,10 @@ describe("Background Script", () => {
123123
// Verify storage state was saved correctly
124124
expect(chrome.storage.local.set).toHaveBeenCalledWith({
125125
processingState: {
126-
status: "Your emojis have been uploaded - please allow 20 minutes for Teams to sync",
127-
type: "success"
128-
}
126+
status:
127+
"Your emojis have been uploaded - please allow 20 minutes for Teams to sync",
128+
type: "success",
129+
},
129130
});
130131
});
131132

@@ -163,8 +164,8 @@ describe("Background Script", () => {
163164
expect(chrome.storage.local.set).toHaveBeenCalledWith({
164165
processingState: {
165166
status: "Could not find required tokens",
166-
type: "error"
167-
}
167+
type: "error",
168+
},
168169
});
169170
});
170171

@@ -211,16 +212,16 @@ describe("Background Script", () => {
211212
expect(chrome.storage.local.set).toHaveBeenCalledWith({
212213
processingState: {
213214
status: "Upload failed",
214-
type: "error"
215-
}
215+
type: "error",
216+
},
216217
});
217218
});
218219

219220
// Test that setting initial processing state works
220221
it("should set initial processing state on file processing", async () => {
221222
// Reset the mocks
222223
jest.clearAllMocks();
223-
224+
224225
// Create test data
225226
const mockFiles: FileDetails[] = [
226227
{
@@ -230,26 +231,26 @@ describe("Background Script", () => {
230231
base64: "dGVzdA==", // test in base64
231232
},
232233
];
233-
234+
234235
const mockTokens = {
235236
chatsvcagg: "chat-token",
236237
ic3: "ic3-token",
237238
permissionsId: "permissions-id",
238239
};
239-
240+
240241
// Setup a mock for uploadFiles
241242
const mockUploadFiles = jest.fn().mockResolvedValue({
242243
success: true,
243-
status: "Test status"
244+
status: "Test status",
244245
});
245-
246+
246247
MsTeamsClient.mockImplementation(() => ({
247248
uploadFiles: mockUploadFiles,
248249
}));
249-
250+
250251
// Call handleFileProcessing
251252
await handleFileProcessing(mockFiles, mockTokens);
252-
253+
253254
// Check if chrome.storage.local.set was called with the initial state
254255
// This verifies our state storage logic works properly
255256
expect(chrome.storage.local.set).toHaveBeenCalledWith(
@@ -258,7 +259,7 @@ describe("Background Script", () => {
258259
status: expect.any(String),
259260
type: expect.any(String),
260261
}),
261-
})
262+
}),
262263
);
263264
});
264265
});

src/background.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
55
if (message.action === "processFiles") {
66
const files = JSON.parse(message.files) as FileDetails[];
77
// Set initial processing state
8-
chrome.storage.local.set({ processingState: { status: "Processing...", type: "processing" } });
8+
chrome.storage.local.set({
9+
processingState: { status: "Processing...", type: "processing" },
10+
});
911
handleFileProcessing(files, message.tokens)
1012
.then(sendResponse)
1113
.catch((error) => {
1214
const errorMessage = formatErrorMessage(error);
1315
// Store error state
14-
chrome.storage.local.set({ processingState: { status: errorMessage, type: "error" } });
16+
chrome.storage.local.set({
17+
processingState: { status: errorMessage, type: "error" },
18+
});
1519
sendResponse({ success: false, error: errorMessage });
1620
});
1721
return true;
@@ -59,7 +63,9 @@ export async function handleFileProcessing(
5963
try {
6064
if (!tokens.chatsvcagg || !tokens.ic3 || !tokens.permissionsId) {
6165
const errorMsg = "Could not find required tokens";
62-
chrome.storage.local.set({ processingState: { status: errorMsg, type: "error" } });
66+
chrome.storage.local.set({
67+
processingState: { status: errorMsg, type: "error" },
68+
});
6369
throw new Error(errorMsg);
6470
}
6571
const teams = new MsTeamsClient(
@@ -70,11 +76,11 @@ export async function handleFileProcessing(
7076
const result = await teams.uploadFiles(files);
7177

7278
// Store processing result state
73-
chrome.storage.local.set({
74-
processingState: {
75-
status: result.status || "",
76-
type: result.success ? "success" : "error"
77-
}
79+
chrome.storage.local.set({
80+
processingState: {
81+
status: result.status || "",
82+
type: result.success ? "success" : "error",
83+
},
7884
});
7985

8086
chrome.runtime.sendMessage({
@@ -90,7 +96,9 @@ export async function handleFileProcessing(
9096
const errorResult = { success: false, error: errorMessage };
9197

9298
// Store error state
93-
chrome.storage.local.set({ processingState: { status: errorMessage, type: "error" } });
99+
chrome.storage.local.set({
100+
processingState: { status: errorMessage, type: "error" },
101+
});
94102

95103
chrome.runtime.sendMessage({
96104
type: "processUpdate",

src/popup.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@ document.addEventListener("DOMContentLoaded", async () => {
77
const state = await chrome.storage.local.get("processingState");
88
if (state.processingState) {
99
updateStatus(
10-
state.processingState.status,
11-
state.processingState.type as "ready" | "success" | "error" | "processing"
10+
state.processingState.status,
11+
state.processingState.type as
12+
| "ready"
13+
| "success"
14+
| "error"
15+
| "processing",
1216
);
1317
}
14-
18+
1519
const tabs = await chrome.tabs.query({ active: true, currentWindow: true });
1620
const tab = tabs[0];
1721

@@ -185,7 +189,7 @@ document
185189
async function refreshTeams() {
186190
try {
187191
updateStatus("Refreshing Teams...", "processing");
188-
192+
189193
await chrome.browsingData.remove(
190194
{
191195
origins: ["https://teams.microsoft.com"],
@@ -198,7 +202,7 @@ async function refreshTeams() {
198202
indexedDB: true,
199203
cache: true,
200204
appcache: true,
201-
}
205+
},
202206
);
203207

204208
await chrome.storage.local.clear();
@@ -218,27 +222,29 @@ async function refreshTeams() {
218222
}
219223
}
220224

221-
document
222-
.getElementById("resetButton")
223-
?.addEventListener("click", refreshTeams);
225+
document.getElementById("resetButton")?.addEventListener("click", refreshTeams);
224226

225227
chrome.runtime.onMessage.addListener(
226228
(message: { type: string; error: any; status: any; success: any }) => {
227229
if (message.type === "processUpdate") {
228230
const status = message.error || message.status;
229-
const type = message.success ? "success" : (message.error ? "error" : "processing");
230-
231+
const type = message.success
232+
? "success"
233+
: message.error
234+
? "error"
235+
: "processing";
236+
231237
// Update the UI
232238
updateStatus(status, type as "success" | "error" | "processing");
233-
239+
234240
// Ensure we store the state in case it was sent directly from background.ts
235241
// Background should be storing the state, but this is a good fallback
236-
chrome.storage.local.set({
237-
processingState: {
238-
status: status,
239-
type: type
240-
}
242+
chrome.storage.local.set({
243+
processingState: {
244+
status: status,
245+
type: type,
246+
},
241247
});
242248
}
243-
}
249+
},
244250
);

0 commit comments

Comments
 (0)