Skip to content

Commit

Permalink
Remove groups tab from notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Staab authored and ticruz38 committed Nov 4, 2024
1 parent b7f5c2e commit 147987c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 134 deletions.
61 changes: 0 additions & 61 deletions src/app/views/NotificationSectionGroups.svelte

This file was deleted.

17 changes: 2 additions & 15 deletions src/app/views/Notifications.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import OnboardingTasks from "src/app/shared/OnboardingTasks.svelte"
import NotificationSectionMain from "src/app/views/NotificationSectionMain.svelte"
import NotificationSectionReactions from "src/app/views/NotificationSectionReactions.svelte"
import NotificationSectionGroups from "src/app/views/NotificationSectionGroups.svelte"
import {router} from "src/app/util/router"
import {
sessionWithMeta,
Expand All @@ -14,10 +13,9 @@
loadCircleMessages,
unreadMainNotifications,
unreadReactionNotifications,
unreadGroupNotifications,
} from "src/engine"
const allTabs = ["Mentions & Replies", "Reactions", "Groups"]
const allTabs = ["Mentions & Replies", "Reactions"]
const setActiveTab = tab => router.at("notifications").at(tab).push()
Expand All @@ -31,11 +29,6 @@
let innerWidth = 0
let element = null
$: displayTabs =
innerWidth <= 640 || !$userSettings.note_actions.includes("reactions")
? [allTabs[0], allTabs[2]]
: allTabs
document.title = "Notifications"
onMount(() => {
Expand All @@ -52,7 +45,7 @@

<svelte:window bind:innerWidth />

<Tabs tabs={displayTabs} {activeTab} {setActiveTab}>
<Tabs tabs={allTabs} {activeTab} {setActiveTab}>
<div slot="tab" let:tab class="flex gap-2">
<div>{tab}</div>
{#if activeTab !== tab}
Expand All @@ -64,10 +57,6 @@
<div class="h-6 rounded-full bg-neutral-700 px-2">
{$unreadReactionNotifications.length}
</div>
{:else if tab === allTabs[2] && $unreadGroupNotifications.length > 0}
<div class="h-6 rounded-full bg-neutral-700 px-2">
{$unreadGroupNotifications.length}
</div>
{/if}
{/if}
</div>
Expand All @@ -82,7 +71,5 @@
<NotificationSectionMain {limit} />
{:else if activeTab === allTabs[1]}
<NotificationSectionReactions {limit} />
{:else if activeTab === allTabs[2]}
<NotificationSectionGroups {limit} />
{/if}
</div>
58 changes: 0 additions & 58 deletions src/engine/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -693,64 +693,6 @@ export const unreadReactionNotifications = derived(
([$isSeen, events]) => events.filter(e => !$isSeen("reactions", e) && !$isSeen("zaps", e)),
)

// -- Group Notifications

export const groupNotifications = derived(
[
sessionWithMeta,
isEventMuted,
groupRequests,
groupAlerts,
groupAdminKeys,
throttled(3000, repositoryStore),
],
([$session, $isMuted, $requests, $alerts, $adminKeys, $repository]) => {
const admins = new Set($adminKeys.map(k => k.pubkey))
const addresses = getUserCircles($session)
const kinds = [...noteKinds, ...repostKinds]
const events = $repository.query([{"#a": addresses, kinds}])

return sortBy(
e => -e.created_at,
[
...$requests.filter(r => !r.resolved && !$repository.deletes.has(r.group)),
...$alerts.filter(a => !admins.has(a.pubkey) && !$repository.deletes.has(a.group)),
...events
.map(e => {
// Unwrap reposts, add community tags so we know where stuff was posted to
if (repostKinds.includes(e.kind)) {
const contextTags = getAddressTags(e.tags)

e = unwrapRepost(e)

for (const tag of contextTags) {
if (isContextAddress(tag[1])) {
e?.tags.push(tag)
}
}
}

return e
})
.filter(
e =>
e &&
e.pubkey !== $session.pubkey &&
// Skip mentions since they're covered in normal notifications
!e.tags.some(t => t[0] === "p" && t[1] === $session.pubkey) &&
!$isMuted(e),
),
],
) as (TrustedEvent | GroupRequest | GroupAlert)[]
},
)

export const unreadGroupNotifications = derived(
[isSeen, groupNotifications],
([$isSeen, $groupNotifications]) =>
$groupNotifications.filter(e => !getContextTagValues(e.tags).every(a => $isSeen(a, e))),
)

// Channels

export const getChannelId = (pubkeys: string[]) => sort(uniq(pubkeys)).join(",")
Expand Down

0 comments on commit 147987c

Please sign in to comment.