Skip to content

Commit

Permalink
Merge pull request #1524 from appwrite/fix-unnecessary-fetches-and-bu…
Browse files Browse the repository at this point in the history
…ild-warnings

fix: unnecessary fetches and build warnings
  • Loading branch information
TorstenDittmann authored Nov 19, 2024
2 parents 6b5eb67 + a88ab15 commit f2bd3cb
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 84 deletions.
38 changes: 2 additions & 36 deletions src/lib/components/backupRestoreBox.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { sdk } from '$lib/stores/sdk';
import { type Payload, Query } from '@appwrite.io/console';
import { type Payload } from '@appwrite.io/console';
import { onMount } from 'svelte';
import { isCloud, isSelfHosted } from '$lib/system';
import { organization } from '$lib/stores/organization';
Expand Down Expand Up @@ -52,39 +52,6 @@
}
}
async function fetchBackupRestores() {
try {
const query = [
Query.equal('status', 'pending'),
Query.equal('status', 'uploading'),
Query.equal('status', 'processing')
];
const [archivesResponse, restorationsResponse] = await Promise.all([
sdk.forProject.backups.listArchives([
...query,
// only manual backups
Query.isNull('policyId')
]),
sdk.forProject.backups.listRestorations(query)
]);
// this is a one time op.
backupRestoreItems.archives = new Map(
archivesResponse.archives.map((item) => [item.$id, item])
);
backupRestoreItems.restorations = new Map(
restorationsResponse.restorations.map((item) => [item.$id, item])
);
} catch (e) {
// ignore?
}
}
// fresh fetch.
fetchBackupRestores();
function updateOrAddItem(payload: Payload) {
const { $id, status, $collection, policyId } = payload;
if ($collection === 'archives' && policyId !== null) {
Expand Down Expand Up @@ -155,8 +122,7 @@
// fast path: don't subscribe if org is on a free plan or is self-hosted.
if (isSelfHosted || (isCloud && $organization.billingPlan === BillingPlan.FREE)) return;
sdk.forConsole.client.subscribe('console', (response) => {
// nice!
return sdk.forConsole.client.subscribe('console', (response) => {
if (!response.channels.includes(`projects.${getProjectId()}`)) return;
if (
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/consent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
</Modal>

<style lang="scss">
@import '@appwrite.io/pink/src/abstract/variables/_devices.scss';
@use '@appwrite.io/pink/src/abstract/variables/devices';
.card {
position: fixed;
Expand All @@ -133,7 +133,7 @@
max-width: 600px;
}
@media #{$break1} {
@media #{devices.$break1} {
.card {
bottom: 0.5rem;
left: 0.5rem;
Expand Down
18 changes: 6 additions & 12 deletions src/lib/components/migrationBox.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts" context="module">
import { last } from '$lib/helpers/array';
import { debounce } from '$lib/helpers/debounce';
import { parseIfString } from '$lib/helpers/object';
import { getProjectId } from '$lib/helpers/project';
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@appwrite.io/console';
import { onMount } from 'svelte';
Expand Down Expand Up @@ -49,17 +48,12 @@
return Number.isNaN(res) ? 0 : res;
})();
const fetchMigrations = debounce(async () => {
const { migrations } = await sdk.forProject.migrations.list();
migration = last(migrations);
}, 1000);
fetchMigrations();
onMount(async () => {
sdk.forConsole.client.subscribe(['project', 'console'], async (response) => {
onMount(() => {
return sdk.forConsole.client.subscribe<Models.Migration>(['console'], async (response) => {
if (!response.channels.includes(`projects.${getProjectId()}`)) return;
if (response.events.includes('migrations.*')) {
fetchMigrations();
if (response.payload.source === 'Backup') return;
migration = response.payload;
}
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/modalSideCol.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</ModalWrapper>

<style lang="scss">
@import '@appwrite.io/pink/src/abstract/mixins/_scroll.scss';
@use '@appwrite.io/pink/src/abstract/mixins/scroll';
.mk-grid {
overflow: hidden;
Expand All @@ -60,7 +60,7 @@
}
&-item-2 {
overflow: auto;
@include scroll;
@include scroll.scroll;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/modalWrapper.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@
</dialog>

<style lang="scss">
@import '@appwrite.io/pink/src/abstract/variables/_devices.scss';
@use '@appwrite.io/pink/src/abstract/variables/devices';
.modal.is-huge {
block-size: 100%;
min-block-size: 80vh;
@media #{$break1}, #{$break2} {
@media #{devices.$break1}, #{devices.$break2} {
min-inline-size: 100%;
min-block-size: 100%;
border-radius: 0;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/elements/forms/inputDigits.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
</FormItem>

<style lang="scss">
@import '@appwrite.io/pink/src/abstract/variables/_devices.scss';
@use '@appwrite.io/pink/src/abstract/variables/devices';
/* Default (including mobile) */
ol {
Expand All @@ -99,7 +99,7 @@
}
/* for smaller screens */
@media #{$break2open} {
@media #{devices.$break2open} {
ol {
gap: 1rem;
Expand Down
19 changes: 9 additions & 10 deletions src/lib/layout/unauthenticated.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@
</main>

<style lang="scss">
@import '@appwrite.io/pink/src/abstract/variables/_devices.scss';
@import '@appwrite.io/pink/src/abstract/variables/_common.scss';
@use '@appwrite.io/pink/src/abstract/variables/devices';
.side-bg {
position: relative;
Expand Down Expand Up @@ -251,7 +250,7 @@
block-size: 32%;
background: radial-gradient(49.55% 43.54% at 47% 50.69%, #e7f8f7 0%, #85dbd8 100%);
filter: blur(150px);
@media #{$break1} {
@media #{devices.$break1} {
filter: blur(100px);
}
}
Expand All @@ -270,18 +269,18 @@
);
filter: blur(200px);
@media #{$break1} {
@media #{devices.$break1} {
filter: blur(100px);
}
}
}
&-img {
padding-inline: 6.25rem;
max-width: 40rem;
@media #{$break2} {
@media #{devices.$break2} {
max-width: 28rem;
}
@media #{$break1} {
@media #{devices.$break1} {
margin-block-start: 3rem;
max-inline-size: 23rem;
padding-inline: 4rem;
Expand Down Expand Up @@ -326,7 +325,7 @@
}
/* for smaller screens */
@media #{$break2open} {
@media #{devices.$break2open} {
.side-default {
background: var(--url);
background-repeat: no-repeat;
Expand All @@ -344,7 +343,7 @@
}
/* for larger screens */
@media #{$break3open} {
@media #{devices.$break3open} {
.side-default {
div {
padding-inline-start: 5.625rem;
Expand Down Expand Up @@ -379,7 +378,7 @@
.logo-variation {
padding-block-start: 2rem;
@media #{$break1} {
@media #{devices.$break1} {
padding-block-start: 0rem;
& img {
scale: 0.7;
Expand All @@ -389,7 +388,7 @@
.review-footer-container {
padding-block-start: 10rem;
@media #{$break1} {
@media #{devices.$break1} {
padding-block-start: 5rem;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/routes/(authenticated)/mfa/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
</Unauthenticated>

<style lang="scss">
@import '@appwrite.io/pink/src/abstract/variables/_devices.scss';
@use '@appwrite.io/pink/src/abstract/variables/devices';
.top {
inset-block-start: 5.85rem;
inline-size: 100%;
Expand All @@ -89,7 +90,7 @@
}
/* for smaller screens */
@media #{$break2open} {
@media #{devices.$break2open} {
.top {
inset-block-start: 5.85rem;
padding-inline: 0;
Expand Down
4 changes: 2 additions & 2 deletions src/routes/(console)/account/updateMfa.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@
factors={$factors} />

<style lang="scss">
@import '@appwrite.io/pink/src/abstract/variables/_devices.scss';
@use '@appwrite.io/pink/src/abstract/variables/devices';
/* Default (including mobile) */
.method {
Expand All @@ -329,7 +329,7 @@
}
/* for smaller screens */
@media #{$break2open} {
@media #{devices.$break2open} {
.method {
align-items: center;
}
Expand Down
1 change: 0 additions & 1 deletion src/routes/(console)/project-[project]/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
<div class="layout-level-progress-bars">
<UploadBox />
<MigrationBox />

<BackupRestoreBox />
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@
</CardGrid>

<style lang="scss">
@import '@appwrite.io/pink/src/abstract/variables/_devices.scss';
@use '@appwrite.io/pink/src/abstract/variables/devices';
.stats-grid-box {
display: grid;
grid-template-columns: repeat(2, 1fr);
}
@media #{$break3open} {
@media #{devices.$break3open} {
.stats-grid-box {
grid-template-columns: repeat(4, 1fr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
alt="statistics" />

<style lang="scss">
@import '@appwrite.io/pink/src/abstract/variables/_devices.scss';
@use '@appwrite.io/pink/src/abstract/variables/devices';
.card {
:global(.theme-dark) & {
Expand Down Expand Up @@ -215,7 +215,7 @@
margin-inline: 4rem;
}
@media #{$break2open} {
@media #{devices.$break2open} {
.card-header {
background-image: var(--url);
background-repeat: no-repeat;
Expand All @@ -234,11 +234,11 @@
z-index: 1;
position: absolute;
@media #{$break1} {
@media #{devices.$break1} {
margin-block-start: 15%;
}
@media #{$break2open} {
@media #{devices.$break2open} {
margin-block-start: 2rem;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/routes/(public)/auth/oauth2/failure/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
{/await}

<style lang="scss">
@import '@appwrite.io/pink/src/abstract/variables/_devices.scss';
@use '@appwrite.io/pink/src/abstract/variables/devices';
// override padding for screens bigger than mobile
@media #{$break2open} {
@media #{devices.$break2open} {
article.card {
padding: 2rem !important;
}
Expand Down
4 changes: 2 additions & 2 deletions src/routes/(public)/auth/oauth2/success/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
{/await}

<style lang="scss">
@import '@appwrite.io/pink/src/abstract/variables/_devices.scss';
@use '@appwrite.io/pink/src/abstract/variables/devices';
// override padding for screens bigger than mobile
@media #{$break2open} {
@media #{devices.$break2open} {
article.card {
padding: 2rem !important;
}
Expand Down
6 changes: 3 additions & 3 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@

<Progress />

<!-- svelte-ignore css-unused-selector -->
<style lang="scss" global>
@import '@appwrite.io/pink/src/abstract/variables/_devices.scss';
@use '@appwrite.io/pink/src/abstract/variables/devices';
.tippy-box {
--p-tooltip-text-color: var(--color-neutral-10);
--p-tooltip--bg-color: var(--color-neutral-80);
Expand Down Expand Up @@ -186,7 +186,7 @@
.is-cloud {
--heading-font: 'Aeonik Pro', arial, sans-serif;
.heading-level {
@media #{$break3open} {
@media #{devices.$break3open} {
&-1,
&-2,
&-3,
Expand Down

0 comments on commit f2bd3cb

Please sign in to comment.