Skip to content

Commit

Permalink
- fix read notification infinite loop
Browse files Browse the repository at this point in the history
- move notifications.ts to /engine/
  • Loading branch information
ticruz38 committed Dec 12, 2024
1 parent bd87a47 commit 3cbe593
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/app/MenuDesktop.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import {slowConnections} from "src/app/state"
import {router} from "src/app/util/router"
import {env, hasNewMessages} from "src/engine"
import {hasNewNotifications} from "src/domain/notifications"
import {hasNewNotifications} from "src/engine/notifications"
const {page} = router
Expand Down
2 changes: 1 addition & 1 deletion src/app/MenuMobile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import {slowConnections, menuIsOpen} from "src/app/state"
import {router} from "src/app/util/router"
import {env, hasNewMessages} from "src/engine"
import {hasNewNotifications} from "src/domain/notifications"
import {hasNewNotifications} from "src/engine/notifications"
const closeSubMenu = () => {
subMenu = null
Expand Down
2 changes: 1 addition & 1 deletion src/app/Nav.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import {menuIsOpen, searchTerm} from "src/app/state"
import {router} from "src/app/util/router"
import {hasNewMessages} from "src/engine"
import {hasNewNotifications} from "src/domain/notifications"
import {hasNewNotifications} from "src/engine/notifications"
let innerWidth = 0
let searching = false
Expand Down
2 changes: 1 addition & 1 deletion src/app/views/ChannelsDetail.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import {router} from "src/app/util/router"
import {markChannelRead, getChannelIdFromEvent, listenForMessages} from "src/engine"
import Popover from "src/partials/Popover.svelte"
import {setChecked} from "src/domain/notifications"
import {setChecked} from "src/engine/notifications"
export let pubkeys
export let channelId
Expand Down
2 changes: 1 addition & 1 deletion src/app/views/ChannelsList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import ChannelsListItem from "src/app/views/ChannelsListItem.svelte"
import {router} from "src/app/util/router"
import {channels, hasNewMessages} from "src/engine"
import {setChecked} from "src/domain/notifications"
import {setChecked} from "src/engine/notifications"
const activeTab = window.location.pathname.slice(1) === "channels" ? "conversations" : "requests"
const setActiveTab = tab => {
Expand Down
9 changes: 5 additions & 4 deletions src/app/views/NotificationSectionMain.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import NotificationList from "src/app/views/NotificationList.svelte"
import NotificationMention from "src/app/views/NotificationMention.svelte"
import NotificationReplies from "src/app/views/NotificationReplies.svelte"
import {mainNotifications, setChecked, unreadMainNotifications} from "src/domain/notifications"
import {mainNotifications, setChecked, unreadMainNotifications} from "src/engine/notifications"
export let limit
Expand Down Expand Up @@ -45,12 +45,13 @@
for (const id of untracked) {
tracked.add(id)
}
setChecked(["replies", "mentions"])
}
})
return unsub
return () => {
unsub()
setChecked(["replies", "mentions"])
}
})
</script>

Expand Down
9 changes: 5 additions & 4 deletions src/app/views/NotificationSectionReactions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
reactionNotifications,
setChecked,
unreadReactionNotifications,
} from "src/domain/notifications"
} from "src/engine/notifications"
export let limit
Expand Down Expand Up @@ -47,12 +47,13 @@
for (const id of untracked) {
tracked.add(id)
}
setChecked(["reactions", "zaps"])
}
})
return unsub
return () => {
unsub()
setChecked(["reactions", "zaps"])
}
})
</script>

Expand Down
2 changes: 1 addition & 1 deletion src/app/views/Notifications.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import NotificationSectionReactions from "src/app/views/NotificationSectionReactions.svelte"
import {router} from "src/app/util/router"
import {sessionWithMeta, loadNotifications} from "src/engine"
import {unreadMainNotifications, unreadReactionNotifications} from "src/domain/notifications"
import {unreadMainNotifications, unreadReactionNotifications} from "src/engine/notifications"
const allTabs = ["Mentions & Replies", "Reactions"]
Expand Down
2 changes: 1 addition & 1 deletion src/app/views/Onboarding.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
broadcastUserData,
} from "src/engine"
import {router} from "src/app/util/router"
import {setChecked} from "src/domain/notifications"
import {setChecked} from "src/engine/notifications"
export let stage = "intro"
export let invite = null
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion src/engine/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
take,
uniq,
uniqBy,
max,
} from "@welshman/lib"
import type {Connection, PublishRequest, Target} from "@welshman/net"
import {
Expand Down Expand Up @@ -376,7 +377,7 @@ export const deriveChecked = (key: string) => derived(checked, prop(key))
export const getSeenAt = derived([checked], ([$checked]) => (key: string, event: TrustedEvent) => {
const match = $checked[key]
const fallback = $checked["*"]
const ts = Math.max(match || 0, fallback || 0)
const ts = max([match, fallback])

if (ts >= event.created_at) return ts

Expand Down

0 comments on commit 3cbe593

Please sign in to comment.