Skip to content

Commit

Permalink
remove projections (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
ticruz38 authored Nov 20, 2024
1 parent 6da38bb commit 851304d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 30 deletions.
1 change: 0 additions & 1 deletion src/engine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ export * from "src/engine/utils"
export * from "src/engine/state"
export * from "src/engine/requests"
export * from "src/engine/commands"
export * from "src/engine/projections"
29 changes: 0 additions & 29 deletions src/engine/projections.ts

This file was deleted.

17 changes: 17 additions & 0 deletions src/engine/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
subscribe as baseSubscribe,
db,
displayProfileByPubkey,
ensurePlaintext,
followsByPubkey,
freshness,
getDefaultAppContext,
Expand Down Expand Up @@ -71,6 +72,7 @@ import {
HANDLER_RECOMMENDATION,
LABEL,
LOCAL_RELAY_URL,
MUTES,
NAMED_BOOKMARKS,
SEEN_CONTEXT,
SEEN_CONVERSATION,
Expand Down Expand Up @@ -156,6 +158,21 @@ export const projections = new Worker<TrustedEvent>({
getKey: prop("kind"),
})

projections.addGlobalHandler(ensurePlaintext)

const decryptKinds = [SEEN_GENERAL, SEEN_CONTEXT, SEEN_CONVERSATION, APP_DATA, FOLLOWS, MUTES]

// Synchronize repository with projections. All events should be published to the
// repository, and when accepted, be propagated to projections. This avoids processing
// the same event multiple times, since repository deduplicates
repository.on("update", ({added}: {added: TrustedEvent[]}) => {
for (const event of added) {
if (decryptKinds.includes(event.kind)) {
projections.push(event)
}
}
})

// Plaintext

export const ensureMessagePlaintext = async (e: TrustedEvent) => {
Expand Down

0 comments on commit 851304d

Please sign in to comment.