11import { Chat , ChatsModule , CreateChatCommand } from "../index.js" ;
2- import {
3- Fetcher ,
4- IndexedFormula ,
5- NamedNode ,
6- Node ,
7- sym ,
8- UpdateManager ,
9- } from "rdflib" ;
2+ import { Fetcher , IndexedFormula , NamedNode , sym , UpdateManager } from "rdflib" ;
103
114import {
125 ContainerQuery ,
@@ -18,7 +11,7 @@ import {
1811import { generateId } from "@solid-data-modules/rdflib-utils/identifier" ;
1912import { createChat } from "./update-operations/index.js" ;
2013import { ChatQuery } from "./queries/index.js" ;
21- import { wf } from "./namespaces .js" ;
14+ import { MessagesDocumentQuery } from './queries/MessagesDocumentQuery .js' ;
2215
2316interface ModuleConfig {
2417 store : IndexedFormula ;
@@ -70,22 +63,13 @@ export class ChatsModuleRdfLib implements ChatsModule {
7063
7164 const latestMonth = await this . fetchLatestSubContainer ( latestYear ) ;
7265 const latestDay = await this . fetchLatestSubContainer ( latestMonth ) ;
73- const chatDocument = await this . fetchLatestDocument ( latestDay ) ;
66+ const messagesDocument = await this . fetchLatestDocument ( latestDay ) ;
7467
75- const messages : Node [ ] = this . store . each (
68+ return new MessagesDocumentQuery (
7669 chatNode ,
77- wf ( "message" ) ,
78- undefined ,
79- chatDocument ,
80- ) ;
81-
82- // TODO query actual message
83- const latestMessages = messages . map ( ( it ) => ( {
84- text : "Hello visitor, welcome to my public chat lobby!" ,
85- date : new Date ( "2024-07-01T17:47:14Z" ) ,
86- authorWebId : "http://localhost:3000/alice/profile/card#me" ,
87- } ) ) ;
88- return latestMessages ;
70+ messagesDocument ,
71+ this . store ,
72+ ) . queryMessages ( ) ;
8973 }
9074
9175 private async fetchLatestSubContainer ( container : NamedNode ) {
0 commit comments