2023-05-20 00:37:21 +02:00
|
|
|
import Builtin from "@structs/builtin";
|
|
|
|
|
|
|
|
import IPC from "@modules/ipc";
|
|
|
|
import DataStore from "@modules/datastore";
|
2023-03-04 19:14:00 +01:00
|
|
|
|
|
|
|
const DISCORD_MIN_HEIGHT = 500;
|
|
|
|
const DISCORD_MIN_WIDTH = 940;
|
2021-04-03 06:17:55 +02:00
|
|
|
|
|
|
|
export default new class RemoveMinimumSize extends Builtin {
|
|
|
|
get name() {return "RemoveMinimumSize";}
|
2021-04-12 07:07:00 +02:00
|
|
|
get category() {return "window";}
|
2021-04-03 06:17:55 +02:00
|
|
|
get id() {return "removeMinimumSize";}
|
|
|
|
|
|
|
|
enabled() {
|
|
|
|
IPC.setMinimumSize(1, 1);
|
2023-03-04 19:14:00 +01:00
|
|
|
window.addEventListener("resize", this.onResize);
|
|
|
|
|
|
|
|
const winprefs = DataStore.getData("windowprefs");
|
|
|
|
if (!winprefs.height || !winprefs.width) return; // If the values don't exist exit
|
|
|
|
if ((winprefs.height >= DISCORD_MIN_HEIGHT) && (winprefs.width >= DISCORD_MIN_WIDTH)) return; // If both values are normally valid don't touch
|
|
|
|
IPC.setWindowSize(winprefs.width, winprefs.height);
|
2021-04-03 06:17:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
disabled() {
|
2023-03-04 19:14:00 +01:00
|
|
|
IPC.setMinimumSize(DISCORD_MIN_WIDTH, DISCORD_MIN_HEIGHT);
|
|
|
|
window.removeEventListener("resize", this.onResize);
|
|
|
|
}
|
|
|
|
|
|
|
|
onResize() {
|
|
|
|
const winprefs = DataStore.getData("windowprefs");
|
|
|
|
winprefs.width = window.outerWidth;
|
|
|
|
winprefs.height = window.outerHeight;
|
|
|
|
DataStore.setData("windowprefs", winprefs);
|
2021-04-03 06:17:55 +02:00
|
|
|
}
|
|
|
|
};
|