Skip to content

Commit

Permalink
Fix use of observeChanges to observeChangesAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
StorytellerCZ committed Aug 10, 2024
1 parent e9ad824 commit 20d04c4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## v2.0.2 - 2024-08-10

- Fix use of `observeChanges` to `observeChangesAsync`
- Updated `zodern:types` to v1.0.13

## v2.0.1 - 2024-07-16

- Added option to depend on the latest v2 of `aldeed:simple-schema` as well as v1.13.1
Expand Down
4 changes: 2 additions & 2 deletions package.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global Package */
Package.describe({
name: 'freedombase:legal-management',
version: '2.0.1',
version: '2.0.2',
summary: 'Manage your legal documents and user consent.',
git: 'https://github.com/freedombase/meteor-legal-management',
documentation: 'README.md',
Expand All @@ -17,7 +17,7 @@ Package.onUse(function (api) {
'ddp',
'typescript',
'callback-hook',
'zodern:[email protected].11',
'zodern:[email protected].13',
])
api.use([
'aldeed:[email protected]',
Expand Down
22 changes: 13 additions & 9 deletions server/legal-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@ LegalCollection.createIndexAsync({ documentId: 1 })
*/
Meteor.publish(
'freedombase:legal.getLatest',
function (documentAbbr, language) {
async function (documentAbbr, language) {
check(documentAbbr, String)
check(language, Match.Maybe(String))
const sub = this
const options = { limit: 1, sort: { effectiveAt: -1 } }

const handle = LegalCollection.find(
const cursor = LegalCollection.find(
{ documentAbbr, effectiveAt: { $lte: new Date() } },
options,
).observeChanges({
)

const handle = await cursor.observeChangesAsync({
added(id: string, doc: LegalDocument) {
if (
language &&
Expand Down Expand Up @@ -92,15 +94,16 @@ Meteor.publish('freedombase:legal.getLatestTiny', (documentAbbr) => {
*/
Meteor.publish(
'freedombase:legal.getAll',
function (documentAbbr: string, language: string) {
async function (documentAbbr: string, language: string) {
check(documentAbbr, String)
check(language, Match.Maybe(String))
const sub = this

const handle = LegalCollection.find(
const cursor = LegalCollection.find(
{ documentAbbr },
{ sort: { effectiveAt: -1 } },
).observeChanges({
)
const handle = await cursor.observeChangesAsync({
added(id: string, doc: LegalDocument) {
if (language && doc.language !== language && doc.i18n) {
if (doc.i18n[language].title) doc.title = doc.i18n[language].title
Expand Down Expand Up @@ -136,16 +139,17 @@ Meteor.publish(
*/
Meteor.publish(
'freedombase:legal.get',
function (documentAbbr: string, version: string, language: string) {
async function (documentAbbr: string, version: string, language: string) {
check(documentAbbr, String)
check(version, String)
check(language, Match.Maybe(String))
const sub = this

const handle = LegalCollection.find(
const cursor = LegalCollection.find(
{ documentAbbr, version },
{ limit: 1, sort: { effectiveAt: -1 } },
).observeChanges({
)
const handle = await cursor.observeChangesAsync({
added(id: string, doc: LegalDocument) {
if (
language &&
Expand Down

0 comments on commit 20d04c4

Please sign in to comment.