@@ -3,7 +3,7 @@ import { SolidConnectedPlugin, SolidContainer, SolidContainerUri, SolidLeaf, Sol
33import { ChatMessageShape , ChatShape } from "./.ldo/longChat.typings.js" ;
44import { scheduleNewDayTrigger } from "./util/scheduleNewDayTrigger.js" ;
55import { ChatMessageListShapeShapeType , ChatMessageShapeShapeType , ChatShapeShapeType } from "./.ldo/longChat.shapeTypes.js" ;
6- import { getResource , throwIfErr } from "./util/resultHelpers.js" ;
6+ import { getResource , throwIfErr , throwIfErrOrAbsent } from "./util/resultHelpers.js" ;
77import { v4 } from "uuid" ;
88import { namedNode } from "@ldo/rdf-utils" ;
99export class Chat {
@@ -126,7 +126,7 @@ export class Chat {
126126 container : SolidContainer
127127 ) : Promise < SolidLeaf | undefined > => {
128128 const indexResource = container . child ( "index.ttl" ) ;
129- throwIfErr ( await indexResource . readIfUnfetched ( ) ) ;
129+ throwIfErrOrAbsent ( await indexResource . readIfUnfetched ( ) ) ;
130130 return indexResource ;
131131 } ;
132132
@@ -135,7 +135,7 @@ export class Chat {
135135 levels : number
136136 ) : Promise < SolidLeaf | undefined > => {
137137 if ( levels === 0 ) return getIndexIfExists ( container ) ;
138- throwIfErr ( await container . readIfUnfetched ( ) ) ;
138+ throwIfErrOrAbsent ( await container . readIfUnfetched ( ) ) ;
139139 const mostRecent = getMostRecentContainer ( container . children ( ) ) ;
140140 if ( ! mostRecent ) return undefined ;
141141 return drillDownMostRecent ( mostRecent , levels - 1 ) ;
@@ -145,10 +145,10 @@ export class Chat {
145145 const levelNames = [ "Month" , "Year" , "Eternity" ] ; // Logical structure
146146 for ( let depth = 0 ; depth < levelNames . length ; depth ++ ) {
147147 const parent = await container . getParentContainer ( ) as SolidContainer ;
148- throwIfErr ( await parent . readIfUnfetched ( ) ) ;
148+ throwIfErrOrAbsent ( await parent . readIfUnfetched ( ) ) ;
149149 const previous = getPreviousContainer ( parent . children ( ) , container ) ;
150150 if ( previous ) {
151- throwIfErr ( await previous . readIfUnfetched ( ) ) ;
151+ throwIfErrOrAbsent ( await previous . readIfUnfetched ( ) ) ;
152152 return drillDownMostRecent ( previous , depth ) ; // Drill into [day, month, year]
153153 }
154154 container = parent ;
@@ -236,10 +236,11 @@ export class Chat {
236236 * @returns
237237 */
238238 public async getChatInfo ( ) : Promise < ChatShape > {
239- throwIfErr ( await this . chatResource . readIfUnfetched ( ) ) ;
239+ const result = throwIfErrOrAbsent ( await this . chatResource . readIfUnfetched ( ) ) ;
240+ console . log ( result ) ;
240241
241242 return this . dataset . usingType ( ChatShapeShapeType )
242- . fromSubject ( this . chatResource . uri ) ;
243+ . fromSubject ( ` ${ this . chatResource . uri } #this` ) ;
243244 }
244245
245246 public async setChatInfo ( chatInfo : Partial < ChatShape > ) : Promise < void > {
@@ -250,7 +251,7 @@ export class Chat {
250251 const cChatInfo = chatInfoTransaction
251252 . usingType ( ChatShapeShapeType )
252253 . write ( this . chatResource . uri )
253- . fromSubject ( this . chatResource . uri ) ;
254+ . fromSubject ( ` ${ this . chatResource . uri } #this` ) ;
254255 Object . assign ( cChatInfo , chatInfo ) ;
255256 throwIfErr ( await chatInfoTransaction . commitToRemote ( ) ) ;
256257 }
0 commit comments