summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmelia Yukii <amelia.yukii@shourai.de>2024-03-04 18:47:47 +0000
committerAmelia Yukii <amelia.yukii@shourai.de>2024-03-04 18:47:47 +0000
commit421f1d46a294871e4ade83f35cb6b0435e343b72 (patch)
tree97c40e3e90f68d0a3613adb7e1660921a34b758a
parentmerge: put back the readme (!447) (diff)
parentFixed startup crash with seasonal effects (diff)
downloadsharkey-421f1d46a294871e4ade83f35cb6b0435e343b72.tar.gz
sharkey-421f1d46a294871e4ade83f35cb6b0435e343b72.tar.bz2
sharkey-421f1d46a294871e4ade83f35cb6b0435e343b72.zip
merge: Fixed startup crash with seasonal effects (!459)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/459 Approved-by: dakkar <dakkar@thenautilus.net> Approved-by: Amelia Yukii <amelia.yukii@shourai.de>
-rw-r--r--packages/frontend/src/boot/main-boot.ts44
-rw-r--r--packages/frontend/src/scripts/snowfall-effect.ts4
2 files changed, 27 insertions, 21 deletions
diff --git a/packages/frontend/src/boot/main-boot.ts b/packages/frontend/src/boot/main-boot.ts
index fbb4baebdc..34612fee73 100644
--- a/packages/frontend/src/boot/main-boot.ts
+++ b/packages/frontend/src/boot/main-boot.ts
@@ -73,27 +73,31 @@ export async function mainBoot() {
mainRouter.push('/search');
},
};
-
- if (defaultStore.state.enableSeasonalScreenEffect) {
- const month = new Date().getMonth() + 1;
- if (defaultStore.state.hemisphere === 'S') {
- // ▼南半球
- if (month === 7 || month === 8) {
- const SnowfallEffect = (await import('@/scripts/snowfall-effect.js')).SnowfallEffect;
- new SnowfallEffect({}).render();
- }
- } else {
- // ▼北半球
- if (month === 12 || month === 1) {
- const SnowfallEffect = (await import('@/scripts/snowfall-effect.js')).SnowfallEffect;
- new SnowfallEffect({}).render();
- } else if (month === 3 || month === 4) {
- const SakuraEffect = (await import('@/scripts/snowfall-effect.js')).SnowfallEffect;
- new SakuraEffect({
- sakura: true,
- }).render();
+ try {
+ if (defaultStore.state.enableSeasonalScreenEffect) {
+ const month = new Date().getMonth() + 1;
+ if (defaultStore.state.hemisphere === 'S') {
+ // ▼南半球
+ if (month === 7 || month === 8) {
+ const SnowfallEffect = (await import('@/scripts/snowfall-effect.js')).SnowfallEffect;
+ new SnowfallEffect({}).render();
+ }
+ } else {
+ // ▼北半球
+ if (month === 12 || month === 1) {
+ const SnowfallEffect = (await import('@/scripts/snowfall-effect.js')).SnowfallEffect;
+ new SnowfallEffect({}).render();
+ } else if (month === 3 || month === 4) {
+ const SakuraEffect = (await import('@/scripts/snowfall-effect.js')).SnowfallEffect;
+ new SakuraEffect({
+ sakura: true,
+ }).render();
+ }
}
- }
+ }
+ } catch (error) {
+ // console.error(error);
+ console.error('Failed to initialise the seasonal screen effect canvas context:', error);
}
if ($i) {
diff --git a/packages/frontend/src/scripts/snowfall-effect.ts b/packages/frontend/src/scripts/snowfall-effect.ts
index 11fcaa0716..d88bdb6660 100644
--- a/packages/frontend/src/scripts/snowfall-effect.ts
+++ b/packages/frontend/src/scripts/snowfall-effect.ts
@@ -155,7 +155,9 @@ export class SnowfallEffect {
max: 0.125,
easing: 0.0005,
};
-
+ /**
+ * @throws {Error} - Thrown when it fails to get WebGL context for the canvas
+ */
constructor(options: {
sakura?: boolean;
}) {