src/lib/Services/BaseService.js
/**
     * This method checks an inbox for new notifications.
     * @param inboxUrl: the url of the inbox.
     * @returns {Promise}: a promise that resolves with an array containing the urls of all new notifications since the last time
     * this method was called.
     * Credits to https://github.com/pheyvaer/solid-chess
     */
This method checks an inbox for new notifications.
@param inboxUrl: the url of the inbox.
@returns {Promise}: a promise that resolves with an array containing the urls of all new notifications since the last time
this method was called.
This method checks an inbox for new notifications . @param inboxUrl : the url of the inbox . @returns { Promise } : a promise that resolves with an array containing the urls of all new notifications since the last time this method was called .
async checkUserInboxForUpdates(inboxUrl) {
        const deferred = this.Q.defer();
        const newResources = [];
        const rdfjsSource = await this.rdfjsSourceFromUrl(inboxUrl, this.fetch);
        const self = this;
        const engine = this.newEngine();
        engine.query(`SELECT ?resource {
      ?resource a <http://www.w3.org/ns/ldp#Resource>.
    }`, {
                sources: [{
                    type: "rdfjsSource",
                    value: rdfjsSource
                }]
            })
            .then(function(result) {
                result.bindingsStream.on("data", (data) => {
                    data = data.toObject();
                    const resource = data["?resource"].value;
                    if (self.alreadyCheckedResources.indexOf(resource) === -1) {
                        newResources.push(resource);
                        self.alreadyCheckedResources.push(resource);
                    }
                });
                result.bindingsStream.on("end", function() {
                    deferred.resolve(newResources);
                });
            });
        return deferred.promise;
    }
async checkUserInboxForUpdates ( inboxUrl ) { const deferred = this . Q . defer ( ) ; const newResources = [ ] ; const rdfjsSource = await this . rdfjsSourceFromUrl ( inboxUrl , this . fetch ) ; const self = this ; const engine = this . newEngine ( ) ; engine . query ( ` ` , { sources : [ { type : "rdfjsSource" , value : rdfjsSource } ] } ) . then ( function ( result ) { result . bindingsStream . on ( "data" , ( data ) => { data = data . toObject ( ) ; const resource = data [ "?resource" ] . value ; if ( self . alreadyCheckedResources . indexOf ( resource ) === - 1 ) { newResources . push ( resource ) ; self . alreadyCheckedResources . push ( resource ) ; } } ) ; result . bindingsStream . on ( "end" , function ( ) { deferred . resolve ( newResources ) ; } ) ; } ) ; return deferred . promise ; }
This method checks an inbox for new notifications.
This method checks an inbox for new notifications .