Resruiin
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
import { Button, Input } from "$lib/components/ui";
|
||||
import { createRoom } from "$lib/matrix";
|
||||
import { toasts } from "$lib/stores/ui";
|
||||
import { createLogger, getErrorMessage } from "$lib/utils/logger";
|
||||
|
||||
const log = createLogger('matrix:room');
|
||||
import { syncRoomsFromEvent, selectRoom } from "$lib/stores/matrix";
|
||||
|
||||
interface Props {
|
||||
@@ -35,9 +38,9 @@
|
||||
roomName = "";
|
||||
isDirect = false;
|
||||
onClose();
|
||||
} catch (e: any) {
|
||||
console.error("Failed to create room:", e);
|
||||
toasts.error(e.message || "Failed to create room");
|
||||
} catch (e: unknown) {
|
||||
log.error('Failed to create room', { error: e });
|
||||
toasts.error(getErrorMessage(e, 'Failed to create room'));
|
||||
} finally {
|
||||
isCreating = false;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
import { Button, Input } from "$lib/components/ui";
|
||||
import { createSpace, getSpaces } from "$lib/matrix";
|
||||
import { toasts } from "$lib/stores/ui";
|
||||
import { createLogger, getErrorMessage } from "$lib/utils/logger";
|
||||
|
||||
const log = createLogger('matrix:space');
|
||||
import { syncRoomsFromEvent } from "$lib/stores/matrix";
|
||||
|
||||
interface Props {
|
||||
@@ -45,9 +48,9 @@
|
||||
spaceTopic = "";
|
||||
isPublic = false;
|
||||
onClose();
|
||||
} catch (e: any) {
|
||||
console.error("Failed to create space:", e);
|
||||
toasts.error(e.message || "Failed to create space");
|
||||
} catch (e: unknown) {
|
||||
log.error('Failed to create space', { error: e });
|
||||
toasts.error(getErrorMessage(e, 'Failed to create space'));
|
||||
} finally {
|
||||
isCreating = false;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
import EmojiPicker from "$lib/components/ui/EmojiPicker.svelte";
|
||||
import { convertEmojiShortcodes } from "$lib/utils/emojiData";
|
||||
import { getTwemojiUrl } from "$lib/utils/twemoji";
|
||||
import { createLogger, getErrorMessage } from "$lib/utils/logger";
|
||||
|
||||
const log = createLogger('matrix:input');
|
||||
|
||||
// Emoji detection regex
|
||||
const emojiRegex =
|
||||
@@ -134,11 +137,11 @@
|
||||
}
|
||||
|
||||
// Send typing indicator
|
||||
setTyping(roomId, true).catch(console.error);
|
||||
setTyping(roomId, true).catch((e) => log.error('Failed to send typing', { error: e }));
|
||||
|
||||
// Stop typing after 3 seconds of no input
|
||||
typingTimeout = setTimeout(() => {
|
||||
setTyping(roomId, false).catch(console.error);
|
||||
setTyping(roomId, false).catch((e) => log.error('Failed to stop typing', { error: e }));
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
@@ -416,7 +419,7 @@
|
||||
clearTimeout(typingTimeout);
|
||||
typingTimeout = null;
|
||||
}
|
||||
setTyping(roomId, false).catch(console.error);
|
||||
setTyping(roomId, false).catch((e) => log.error('Failed to stop typing', { error: e }));
|
||||
|
||||
// Create a temporary event ID for the pending message
|
||||
const tempEventId = `pending-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
||||
@@ -462,11 +465,11 @@
|
||||
// If no event ID returned, just mark as not pending
|
||||
confirmPendingMessage(roomId, tempEventId, tempEventId);
|
||||
}
|
||||
} catch (e: any) {
|
||||
console.error("Failed to send message:", e);
|
||||
} catch (e: unknown) {
|
||||
log.error('Failed to send message', { error: e });
|
||||
// Remove the pending message on failure
|
||||
removePendingMessage(roomId, tempEventId);
|
||||
toasts.error(e.message || "Failed to send message");
|
||||
toasts.error(getErrorMessage(e, 'Failed to send message'));
|
||||
} finally {
|
||||
isSending = false;
|
||||
// Refocus after DOM settles from optimistic update
|
||||
@@ -497,9 +500,9 @@
|
||||
const contentUri = await uploadFile(file);
|
||||
await sendFileMessage(roomId, file, contentUri);
|
||||
toasts.success("File sent!");
|
||||
} catch (e: any) {
|
||||
console.error("Failed to upload file:", e);
|
||||
toasts.error(e.message || "Failed to upload file");
|
||||
} catch (e: unknown) {
|
||||
log.error('Failed to upload file', { error: e });
|
||||
toasts.error(getErrorMessage(e, 'Failed to upload file'));
|
||||
} finally {
|
||||
isUploading = false;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
import { Avatar } from "$lib/components/ui";
|
||||
import { setRoomName, setRoomTopic, setRoomAvatar } from "$lib/matrix";
|
||||
import { toasts } from "$lib/stores/ui";
|
||||
import { createLogger } from "$lib/utils/logger";
|
||||
|
||||
const log = createLogger('matrix:settings');
|
||||
import { syncRoomsFromEvent } from "$lib/stores/matrix";
|
||||
import type { RoomSummary } from "$lib/matrix/types";
|
||||
|
||||
@@ -55,7 +58,7 @@
|
||||
toasts.success("Room settings updated");
|
||||
onClose();
|
||||
} catch (e) {
|
||||
console.error("Failed to update room settings:", e);
|
||||
log.error('Failed to update room settings', { error: e });
|
||||
toasts.error("Failed to update room settings");
|
||||
} finally {
|
||||
isSaving = false;
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
import { Avatar } from '$lib/components/ui';
|
||||
import { searchUsers, createDirectMessage } from '$lib/matrix';
|
||||
import { toasts } from '$lib/stores/ui';
|
||||
import { createLogger, getErrorMessage } from '$lib/utils/logger';
|
||||
|
||||
const log = createLogger('matrix:dm');
|
||||
|
||||
interface Props {
|
||||
onClose: () => void;
|
||||
@@ -29,7 +32,7 @@
|
||||
try {
|
||||
searchResults = await searchUsers(searchQuery);
|
||||
} catch (e) {
|
||||
console.error('Search failed:', e);
|
||||
log.error('Search failed', { error: e });
|
||||
} finally {
|
||||
isSearching = false;
|
||||
}
|
||||
@@ -43,9 +46,9 @@
|
||||
toasts.success('Direct message started!');
|
||||
onDMCreated(roomId);
|
||||
onClose();
|
||||
} catch (e: any) {
|
||||
console.error('Failed to create DM:', e);
|
||||
toasts.error(e.message || 'Failed to start direct message');
|
||||
} catch (e: unknown) {
|
||||
log.error('Failed to create DM', { error: e });
|
||||
toasts.error(getErrorMessage(e, 'Failed to start direct message'));
|
||||
} finally {
|
||||
isCreating = false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<script lang="ts">
|
||||
import { syncState, syncError, clearState } from "$lib/stores/matrix";
|
||||
import { clearAllCache } from "$lib/cache";
|
||||
import { createLogger } from "$lib/utils/logger";
|
||||
|
||||
const log = createLogger('matrix:sync');
|
||||
|
||||
interface Props {
|
||||
onHardRefresh?: () => void;
|
||||
@@ -43,7 +46,7 @@
|
||||
// Reload the page for clean state
|
||||
window.location.reload();
|
||||
} catch (error) {
|
||||
console.error("[SyncRecovery] Hard refresh failed:", error);
|
||||
log.error('Hard refresh failed', { error });
|
||||
isRefreshing = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
import { createDirectMessage } from '$lib/matrix';
|
||||
import { userPresence } from '$lib/stores/matrix';
|
||||
import { toasts } from '$lib/stores/ui';
|
||||
import { createLogger } from '$lib/utils/logger';
|
||||
|
||||
const log = createLogger('matrix:profile');
|
||||
import type { RoomMember } from '$lib/matrix/types';
|
||||
|
||||
interface Props {
|
||||
@@ -35,7 +38,7 @@
|
||||
onStartDM?.(roomId);
|
||||
onClose();
|
||||
} catch (e) {
|
||||
console.error('Failed to start DM:', e);
|
||||
log.error('Failed to start DM', { error: e });
|
||||
toasts.error('Failed to start direct message');
|
||||
} finally {
|
||||
isStartingDM = false;
|
||||
|
||||
@@ -318,7 +318,7 @@
|
||||
{#if showAddItemModal}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div class="fixed inset-0 z-[60] bg-black/60 flex items-center justify-center p-4" onclick={() => (showAddItemModal = false)} onkeydown={(e) => e.key === 'Escape' && (showAddItemModal = false)}>
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions a11y_click_events_have_key_events -->
|
||||
<div class="bg-surface rounded-2xl border border-light/10 p-5 w-full max-w-md space-y-4" onclick={(e) => e.stopPropagation()}>
|
||||
<h3 class="text-body font-heading text-white">{editingItem ? 'Edit' : 'Add'} Budget Item</h3>
|
||||
|
||||
@@ -384,7 +384,7 @@
|
||||
{#if showAddCategoryModal}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div class="fixed inset-0 z-[60] bg-black/60 flex items-center justify-center p-4" onclick={() => (showAddCategoryModal = false)} onkeydown={(e) => e.key === 'Escape' && (showAddCategoryModal = false)}>
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions a11y_click_events_have_key_events -->
|
||||
<div class="bg-surface rounded-2xl border border-light/10 p-5 w-full max-w-sm space-y-4" onclick={(e) => e.stopPropagation()}>
|
||||
<h3 class="text-body font-heading text-white">Add Category</h3>
|
||||
|
||||
@@ -399,10 +399,11 @@
|
||||
<div class="flex gap-1.5">
|
||||
{#each CATEGORY_COLORS as color}
|
||||
<button
|
||||
class="w-6 h-6 rounded-full border-2 transition-all {newCategoryColor === color ? 'border-white scale-110' : 'border-transparent'}"
|
||||
style="background-color: {color}"
|
||||
onclick={() => (newCategoryColor = color)}
|
||||
></button>
|
||||
class="w-6 h-6 rounded-full border-2 transition-all {newCategoryColor === color ? 'border-white scale-110' : 'border-transparent'}"
|
||||
style="background-color: {color}"
|
||||
onclick={() => (newCategoryColor = color)}
|
||||
aria-label="Select color {color}"
|
||||
></button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -422,7 +422,7 @@
|
||||
{#if showAddSponsorModal}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div class="fixed inset-0 z-[60] bg-black/60 flex items-center justify-center p-4" onclick={() => (showAddSponsorModal = false)} onkeydown={(e) => e.key === 'Escape' && (showAddSponsorModal = false)}>
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions a11y_click_events_have_key_events -->
|
||||
<div class="bg-surface rounded-2xl border border-light/10 p-5 w-full max-w-md space-y-4 max-h-[80vh] overflow-auto" onclick={(e) => e.stopPropagation()}>
|
||||
<h3 class="text-body font-heading text-white">{editingSponsor ? 'Edit' : 'Add'} Sponsor</h3>
|
||||
|
||||
@@ -508,7 +508,7 @@
|
||||
{#if showAddTierModal}
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<div class="fixed inset-0 z-[60] bg-black/60 flex items-center justify-center p-4" onclick={() => (showAddTierModal = false)} onkeydown={(e) => e.key === 'Escape' && (showAddTierModal = false)}>
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions a11y_click_events_have_key_events -->
|
||||
<div class="bg-surface rounded-2xl border border-light/10 p-5 w-full max-w-sm space-y-4" onclick={(e) => e.stopPropagation()}>
|
||||
<h3 class="text-body font-heading text-white">Manage Tiers</h3>
|
||||
|
||||
@@ -528,10 +528,11 @@
|
||||
<div class="flex gap-1.5">
|
||||
{#each TIER_COLORS as color}
|
||||
<button
|
||||
class="w-6 h-6 rounded-full border-2 transition-all {tierColor === color ? 'border-white scale-110' : 'border-transparent'}"
|
||||
style="background-color: {color}"
|
||||
onclick={() => (tierColor = color)}
|
||||
></button>
|
||||
class="w-6 h-6 rounded-full border-2 transition-all {tierColor === color ? 'border-white scale-110' : 'border-transparent'}"
|
||||
style="background-color: {color}"
|
||||
onclick={() => (tierColor = color)}
|
||||
aria-label="Select color {color}"
|
||||
></button>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user