From d8a30856f1dcda74984d06844efc757b5b18f3cc Mon Sep 17 00:00:00 2001 From: Steven Nguyen Date: Thu, 29 Feb 2024 20:26:23 -0800 Subject: [PATCH] fix(messaging): localize the subscribers columns When it was global, the state (show values) would persist when switching between different projects rather than resetting back to the default. --- .../messaging/topics/topic-[topic]/+page.svelte | 13 +++++++++++-- .../messaging/topics/topic-[topic]/store.ts | 11 +---------- .../messaging/topics/topic-[topic]/table.svelte | 9 +++++---- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/routes/console/project-[project]/messaging/topics/topic-[topic]/+page.svelte b/src/routes/console/project-[project]/messaging/topics/topic-[topic]/+page.svelte index cf086e081..7b977d1ee 100644 --- a/src/routes/console/project-[project]/messaging/topics/topic-[topic]/+page.svelte +++ b/src/routes/console/project-[project]/messaging/topics/topic-[topic]/+page.svelte @@ -23,12 +23,21 @@ import UserTargetsModal from '../../userTargetsModal.svelte'; import { onMount } from 'svelte'; import { Filters, hasPageQueries } from '$lib/components/filters'; - import { columns } from './store'; import { View } from '$lib/helpers/load'; + import { writable } from 'svelte/store'; + import type { Column } from '$lib/helpers/types'; export let data: PageData; let showAdd = false; let subscribersByTargetId: Record = {}; + const columns = writable([ + { id: '$id', title: 'Subscriber ID', type: 'string', show: true, width: 140 }, + { id: 'userName', title: 'Name', type: 'string', show: true, filter: false, width: 100 }, + { id: 'targetId', title: 'Target ID', type: 'string', show: true, width: 140 }, + { id: 'target', title: 'Target', type: 'string', show: true, filter: false, width: 140 }, + { id: 'type', title: 'Type', type: 'string', show: true, width: 80 }, + { id: '$createdAt', title: 'Created', type: 'datetime', show: true, width: 100 } + ]); onMount(() => { $targetsById = {}; @@ -121,7 +130,7 @@ {#if data.subscribers.total} - +
$topic.emailTotal + $topic.smsTotal + $topic.pushTotal ); -export const columns = writable([ - { id: '$id', title: 'Subscriber ID', type: 'string', show: true, width: 140 }, - { id: 'userName', title: 'Name', type: 'string', show: true, filter: false, width: 100 }, - { id: 'targetId', title: 'Target ID', type: 'string', show: true, width: 140 }, - { id: 'target', title: 'Target', type: 'string', show: true, filter: false, width: 140 }, - { id: 'type', title: 'Type', type: 'string', show: true, width: 80 }, - { id: '$createdAt', title: 'Created', type: 'datetime', show: true, width: 100 } -]); \ No newline at end of file diff --git a/src/routes/console/project-[project]/messaging/topics/topic-[topic]/table.svelte b/src/routes/console/project-[project]/messaging/topics/topic-[topic]/table.svelte index 56ccf7cec..e469b7991 100644 --- a/src/routes/console/project-[project]/messaging/topics/topic-[topic]/table.svelte +++ b/src/routes/console/project-[project]/messaging/topics/topic-[topic]/table.svelte @@ -18,7 +18,6 @@ } from '$lib/elements/table'; import { addNotification } from '$lib/stores/notifications'; import type { PageData } from './$types'; - import { columns } from './store'; import ProviderType from '../../providerType.svelte'; import { toLocaleDateTime } from '$lib/helpers/date'; import { project } from '$routes/console/project-[project]/store'; @@ -26,7 +25,9 @@ import { page } from '$app/stores'; import { targetsById } from '../../store'; import { MessagingProviderType, type Models } from '@appwrite.io/console'; + import type { Column } from '$lib/helpers/types'; + export let columns: Column[]; export let data: PageData; let subscribers: Record = {}; @@ -84,7 +85,7 @@ d.$id)} /> - {#each $columns as column} + {#each columns as column} {#if column.show} {column.title} {/if} @@ -97,10 +98,10 @@ href={`${base}/console/project-${$project.$id}/auth/user-${subscriber.target.userId}`}> - {#each $columns as column} + {#each columns as column} {#if column.show} {#if column.id === '$id'} - {#key $columns} + {#key column.id} {subscriber.$id}