forgot about functions, still LET'S GO (test req)

This commit is contained in:
Crazypersonalph
2023-12-04 20:39:13 +08:00
parent aaca124ff0
commit 8af59e58d6
11 changed files with 67 additions and 58 deletions
+4 -4
View File
@@ -5,7 +5,7 @@
* @returns {Promise} A promise that resolves to the response from the server.
* @throws {Error} If no file is provided or if there is an error during upload.
*/
export async function UploadImage(file) {
export async function UploadImage(file: any) {
// Ensuring that file is provided
if (!file) {
throw new Error("No file provided");
@@ -28,12 +28,12 @@ export async function UploadImage(file) {
};
// Making the fetch request and returning the promise
return fetch('/seqta/student/file/upload/xhr2', requestOptions)
.then(response => {
return await fetch('/seqta/student/file/upload/xhr2', requestOptions)
.then(async response => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const json = response.json();
const json = await response.json();
return `/seqta/student/load/file?type=message&file=${json.uuid}`;
})
.catch(error => {
+1 -1
View File
@@ -8,7 +8,7 @@ export class MessageHandler {
browser.runtime.onMessage.addListener(this.routeMessage.bind(this));
}
routeMessage(request, sender, sendResponse) {
routeMessage(request: any, sender: any, sendResponse: any) {
switch (request.info) {
case 'EditSidebar':
+14 -12
View File
@@ -12,13 +12,15 @@ import {
import { updateBgDurations } from '../ui/Animation.js';
import { getDarkMode, updateAllColors } from '../ui/colors/Manager.js';
export default class StorageListener {
darkMode: any;
constructor() {
this.darkMode = getDarkMode();
browser.storage.onChanged.addListener(this.handleStorageChanges.bind(this));
}
handleStorageChanges(changes) {
handleStorageChanges(changes: any) {
Object.keys(changes).forEach((changeKey) => {
switch (changeKey) {
@@ -60,7 +62,7 @@ export default class StorageListener {
CreateBackground();
} else {
RemoveBackground();
document.getElementById('container').style.background = 'var(--background-secondary)';
document.getElementById('container')!.style.background = 'var(--background-secondary)';
}
break;
@@ -80,7 +82,7 @@ export default class StorageListener {
});
}
handleSelectedColorChange(newColor) {
handleSelectedColorChange(newColor: any) {
try {
updateAllColors(this.darkMode, newColor);
} catch (err) {
@@ -88,7 +90,7 @@ export default class StorageListener {
}
}
handleNotificationCollectorChange(details) {
handleNotificationCollectorChange(details: any) {
if (details.newValue) {
enableNotificationCollector();
} else {
@@ -96,7 +98,7 @@ export default class StorageListener {
}
}
handleCustomShortcutsChange(oldValue, newValue) {
handleCustomShortcutsChange(oldValue: any, newValue: any) {
// Check for addition
if (newValue.length > oldValue.length) {
CreateCustomShortcutDiv(newValue[oldValue.length]);
@@ -104,9 +106,9 @@ export default class StorageListener {
// Check for removal
else if (newValue.length < oldValue.length) {
const removedElement = oldValue.find(
(oldItem) =>
(oldItem: any) =>
!newValue.some(
(newItem) => JSON.stringify(oldItem) === JSON.stringify(newItem)
(newItem: any) => JSON.stringify(oldItem) === JSON.stringify(newItem)
)
);
@@ -116,10 +118,10 @@ export default class StorageListener {
}
}
handleShortcutsChange(oldValue, newValue) {
handleShortcutsChange(oldValue: any, newValue: any) {
// Find Added Shortcuts
const addedShortcuts = newValue.filter(newItem => {
const isAdded = oldValue.some(oldItem => {
const addedShortcuts = newValue.filter((newItem: any) => {
const isAdded = oldValue.some((oldItem: any) => {
const match = oldItem.name === newItem.name;
const wasDisabled = !oldItem.enabled;
const isEnabled = newItem.enabled;
@@ -130,8 +132,8 @@ export default class StorageListener {
});
// Find Removed Shortcuts
const removedShortcuts = newValue.filter(newItem => {
const isRemoved = oldValue.some(oldItem => {
const removedShortcuts = newValue.filter((newItem: any) => {
const isRemoved = oldValue.some((oldItem: any) => {
const match = oldItem.name === newItem.name;
const wasEnabled = oldItem.enabled; // Was enabled in the old array
const isDisabled = !newItem.enabled; // Is disabled in the new array
+1 -1
View File
@@ -1 +1 @@
export function onError (error) { console.log(`Error: ${error}`) }
export function onError (error: string) { console.log(`Error: ${error}`) }