forked from coracle/flotilla
Add classified listings
This commit is contained in:
@@ -40,6 +40,7 @@ import {
|
||||
ZAP_GOAL,
|
||||
EVENT_TIME,
|
||||
THREAD,
|
||||
CLASSIFIED,
|
||||
COMMENT,
|
||||
DELETE,
|
||||
getTagValue,
|
||||
@@ -56,6 +57,7 @@ import {
|
||||
makeChatPath,
|
||||
makeGoalPath,
|
||||
makeThreadPath,
|
||||
makeClassifiedPath,
|
||||
makeCalendarPath,
|
||||
makeSpaceChatPath,
|
||||
makeRoomPath,
|
||||
@@ -106,12 +108,14 @@ export const setChecked = (key: string) => checked.update(state => ({...state, [
|
||||
|
||||
const goalCommentFilters = [{kinds: [COMMENT], "#K": [String(ZAP_GOAL)]}]
|
||||
const threadCommentFilters = [{kinds: [COMMENT], "#K": [String(THREAD)]}]
|
||||
const classifiedCommentFilters = [{kinds: [COMMENT], "#K": [String(CLASSIFIED)]}]
|
||||
const calendarCommentFilters = [{kinds: [COMMENT], "#K": [String(EVENT_TIME)]}]
|
||||
const messageFilters = [{kinds: MESSAGE_KINDS}]
|
||||
const dmFilters = [{kinds: DM_KINDS}]
|
||||
const allFilters = flatten([
|
||||
goalCommentFilters,
|
||||
threadCommentFilters,
|
||||
classifiedCommentFilters,
|
||||
calendarCommentFilters,
|
||||
messageFilters,
|
||||
dmFilters,
|
||||
@@ -129,6 +133,7 @@ export const notifications = derived(
|
||||
relaysByUrl,
|
||||
deriveEventsByIdByUrl({tracker, repository, filters: goalCommentFilters}),
|
||||
deriveEventsByIdByUrl({tracker, repository, filters: threadCommentFilters}),
|
||||
deriveEventsByIdByUrl({tracker, repository, filters: classifiedCommentFilters}),
|
||||
deriveEventsByIdByUrl({tracker, repository, filters: calendarCommentFilters}),
|
||||
deriveEventsByIdByUrl({tracker, repository, filters: messageFilters}),
|
||||
],
|
||||
@@ -143,6 +148,7 @@ export const notifications = derived(
|
||||
$relaysByUrl,
|
||||
goalCommentsByUrl,
|
||||
threadCommentsByUrl,
|
||||
classifiedCommentsByUrl,
|
||||
calendarCommentsByUrl,
|
||||
messagesByUrl,
|
||||
]) => {
|
||||
@@ -181,10 +187,12 @@ export const notifications = derived(
|
||||
const spacePathMobile = spacePath + ":mobile"
|
||||
const goalPath = makeGoalPath(url)
|
||||
const threadPath = makeThreadPath(url)
|
||||
const classifiedPath = makeClassifiedPath(url)
|
||||
const calendarPath = makeCalendarPath(url)
|
||||
const messagesPath = makeSpaceChatPath(url)
|
||||
const goalComments = sortEventsDesc(goalCommentsByUrl.get(url)?.values() || [])
|
||||
const threadComments = sortEventsDesc(threadCommentsByUrl.get(url)?.values() || [])
|
||||
const classifiedComments = sortEventsDesc(classifiedCommentsByUrl.get(url)?.values() || [])
|
||||
const calendarComments = sortEventsDesc(calendarCommentsByUrl.get(url)?.values() || [])
|
||||
const messages = sortEventsDesc(messagesByUrl.get(url)?.values() || [])
|
||||
|
||||
@@ -224,6 +232,24 @@ export const notifications = derived(
|
||||
}
|
||||
}
|
||||
|
||||
const commentsByClassifiedId = groupBy(
|
||||
e => getTagValue("E", e.tags),
|
||||
classifiedComments.filter(spec({kind: COMMENT})),
|
||||
)
|
||||
|
||||
for (const [classifiedId, [comment]] of commentsByClassifiedId.entries()) {
|
||||
const classifiedItemPath = makeClassifiedPath(url, classifiedId)
|
||||
|
||||
if (hasNotification(classifiedPath, comment)) {
|
||||
paths.add(spacePathMobile)
|
||||
paths.add(classifiedPath)
|
||||
}
|
||||
|
||||
if (hasNotification(classifiedItemPath, comment)) {
|
||||
paths.add(classifiedItemPath)
|
||||
}
|
||||
}
|
||||
|
||||
const commentsByEventId = groupBy(
|
||||
e => getTagValue("E", e.tags),
|
||||
calendarComments.filter(spec({kind: COMMENT})),
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
DIRECT_MESSAGE_FILE,
|
||||
MESSAGE,
|
||||
THREAD,
|
||||
CLASSIFIED,
|
||||
ZAP_GOAL,
|
||||
EVENT_TIME,
|
||||
getPubkeyTagValues,
|
||||
@@ -66,6 +67,9 @@ export const makeGoalPath = (url: string, eventId?: string) => makeSpacePath(url
|
||||
export const makeThreadPath = (url: string, eventId?: string) =>
|
||||
makeSpacePath(url, "threads", eventId)
|
||||
|
||||
export const makeClassifiedPath = (url: string, eventId?: string) =>
|
||||
makeSpacePath(url, "classifieds", eventId)
|
||||
|
||||
export const makeCalendarPath = (url: string, eventId?: string) =>
|
||||
makeSpacePath(url, "calendar", eventId)
|
||||
|
||||
@@ -121,6 +125,10 @@ export const getEventPath = async (event: TrustedEvent, urls: string[]) => {
|
||||
return makeThreadPath(url, event.id)
|
||||
}
|
||||
|
||||
if (event.kind === CLASSIFIED) {
|
||||
return makeClassifiedPath(url, event.id)
|
||||
}
|
||||
|
||||
if (event.kind === EVENT_TIME) {
|
||||
return makeCalendarPath(url, event.id)
|
||||
}
|
||||
@@ -141,6 +149,10 @@ export const getEventPath = async (event: TrustedEvent, urls: string[]) => {
|
||||
return makeThreadPath(url, id)
|
||||
}
|
||||
|
||||
if (parseInt(kind) === CLASSIFIED) {
|
||||
return makeClassifiedPath(url, id)
|
||||
}
|
||||
|
||||
if (parseInt(kind) === EVENT_TIME) {
|
||||
return makeCalendarPath(url, id)
|
||||
}
|
||||
@@ -158,6 +170,8 @@ export const getRoomItemPath = (url: string, event: TrustedEvent) => {
|
||||
switch (event.kind) {
|
||||
case THREAD:
|
||||
return makeThreadPath(url, event.id)
|
||||
case CLASSIFIED:
|
||||
return makeClassifiedPath(url, event.id)
|
||||
case ZAP_GOAL:
|
||||
return makeGoalPath(url, event.id)
|
||||
case EVENT_TIME:
|
||||
|
||||
@@ -8,12 +8,8 @@ import {
|
||||
ALERT_WEB,
|
||||
APP_DATA,
|
||||
BLOSSOM_SERVERS,
|
||||
DIRECT_MESSAGE_FILE,
|
||||
DIRECT_MESSAGE,
|
||||
EVENT_TIME,
|
||||
FOLLOWS,
|
||||
MESSAGING_RELAYS,
|
||||
MESSAGE,
|
||||
MUTES,
|
||||
PROFILE,
|
||||
RELAY_ADD_MEMBER,
|
||||
@@ -30,8 +26,6 @@ import {
|
||||
ROOM_DELETE,
|
||||
ROOM_REMOVE_MEMBER,
|
||||
ROOMS,
|
||||
THREAD,
|
||||
ZAP_GOAL,
|
||||
verifiedSymbol,
|
||||
} from "@welshman/util"
|
||||
import type {Zapper, TrustedEvent, RelayProfile} from "@welshman/util"
|
||||
@@ -53,6 +47,7 @@ import {
|
||||
} from "@welshman/app"
|
||||
import {isMobile} from "@lib/html"
|
||||
import type {IDBTable} from "@lib/indexeddb"
|
||||
import {MESSAGE_KINDS, DM_KINDS} from "@app/core/state"
|
||||
|
||||
const kinds = {
|
||||
meta: [PROFILE, FOLLOWS, MUTES, RELAYS, BLOSSOM_SERVERS, MESSAGING_RELAYS, APP_DATA, ROOMS],
|
||||
@@ -67,7 +62,7 @@ const kinds = {
|
||||
ROOM_REMOVE_MEMBER,
|
||||
ROOM_CREATE_PERMISSION,
|
||||
],
|
||||
content: [EVENT_TIME, THREAD, MESSAGE, ZAP_GOAL, DIRECT_MESSAGE, DIRECT_MESSAGE_FILE],
|
||||
content: [...MESSAGE_KINDS, ...DM_KINDS],
|
||||
}
|
||||
|
||||
const rankEvent = (event: TrustedEvent) => {
|
||||
|
||||
Reference in New Issue
Block a user