4 Commits

Author SHA1 Message Date
89c4ee229a 1.0.1 2017-10-24 17:04:21 +02:00
990b081b3d Use standard logger instead of RS.log 2017-10-24 17:03:54 +02:00
4ce2b90351 1.0.0 2017-10-24 16:51:45 +02:00
2a22d0f399 Update to new RS module API 2017-10-24 16:51:37 +02:00
4 changed files with 16 additions and 22 deletions

2
dist/build.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,4 @@
var RemoteStorage = require('remotestoragejs'); var ChatMessages = function (privateClient, publicClient) {
RemoteStorage.defineModule("chat-messages", function (privateClient, publicClient) {
/** /**
* Schema: chat-messages/daily * Schema: chat-messages/daily
@@ -362,7 +360,7 @@ RemoteStorage.defineModule("chat-messages", function (privateClient, publicClien
* Updates and writes an existing archive document * Updates and writes an existing archive document
*/ */
_updateDocument: function(archive, messages) { _updateDocument: function(archive, messages) {
RemoteStorage.log('[chat-messages] Updating archive document', archive); console.debug('[chat-messages] Updating archive document', archive);
if (Array.isArray(messages)) { if (Array.isArray(messages)) {
messages.forEach(function(message) { messages.forEach(function(message) {
@@ -381,7 +379,7 @@ RemoteStorage.defineModule("chat-messages", function (privateClient, publicClien
* Creates and writes a new archive document * Creates and writes a new archive document
*/ */
_createDocument: function(messages) { _createDocument: function(messages) {
RemoteStorage.log('[chat-messages] Creating new archive document'); console.debug('[chat-messages] Creating new archive document');
let archive = this._buildArchiveObject(); let archive = this._buildArchiveObject();
if (Array.isArray(messages)) { if (Array.isArray(messages)) {
@@ -456,11 +454,11 @@ RemoteStorage.defineModule("chat-messages", function (privateClient, publicClien
let path = this.path.substring(0, this.path.length-this.dateId.length)+archive.today['@id']; let path = this.path.substring(0, this.path.length-this.dateId.length)+archive.today['@id'];
return this.client.storeObject('daily-archive', path, archive).then(() => { return this.client.storeObject('daily-archive', path, archive).then(() => {
RemoteStorage.log('[chat-messages] Previous archive written to remote storage', path, archive); console.debug('[chat-messages] Previous archive written to remote storage', path, archive);
return archive; return archive;
}); });
} else { } else {
RemoteStorage.log('[chat-messages] Previous archive not found'); console.debug('[chat-messages] Previous archive not found');
return false; return false;
} }
}); });
@@ -536,13 +534,13 @@ RemoteStorage.defineModule("chat-messages", function (privateClient, publicClien
* Write archive document * Write archive document
*/ */
_sync: function(obj) { _sync: function(obj) {
RemoteStorage.log('[chat-messages] Writing archive object', obj); console.debug('[chat-messages] Writing archive object', obj);
return this.client.storeObject('daily-archive', this.path, obj).then(function(){ return this.client.storeObject('daily-archive', this.path, obj).then(function(){
RemoteStorage.log('[chat-messages] Archive written to remote storage'); console.debug('[chat-messages] Archive written to remote storage');
return true; return true;
},function(error){ },function(error){
console.log('[chat-messages] Error trying to store object', error); console.warn('[chat-messages] Error trying to store object', error);
return error; return error;
}); });
} }
@@ -570,4 +568,7 @@ RemoteStorage.defineModule("chat-messages", function (privateClient, publicClien
// Return public functions // Return public functions
return { exports: exports }; return { exports: exports };
});
};
export default { name: 'chat-messages', builder: ChatMessages };

View File

@@ -1,12 +1,13 @@
{ {
"name": "remotestorage-module-chat-messages", "name": "remotestorage-module-chat-messages",
"version": "0.8.0", "version": "1.0.1",
"description": "Stores chat messages in daily archive files", "description": "Stores chat messages in daily archive files",
"main": "./dist/build.js", "main": "./dist/build.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack -w", "dev": "webpack -w",
"build": "NODE_ENV=production webpack" "build": "NODE_ENV=production webpack -p",
"version": "npm run build && git add dist/"
}, },
"author": "Kosmos Developers <mail@kosmos.org> (https://kosmos.org)", "author": "Kosmos Developers <mail@kosmos.org> (https://kosmos.org)",
"contributors": [ "contributors": [

View File

@@ -12,14 +12,6 @@ module.exports = {
filename: __dirname + '/dist/build.js', filename: __dirname + '/dist/build.js',
libraryTarget: 'umd' libraryTarget: 'umd'
}, },
externals: {
"remotestoragejs": {
root: "RemoteStorage", // <script src='remotestorage.js'> will resolve in this.RemoteStorage
commonjs2: "remotestoragejs", // require('remotestoragejs')
commonjs: "remotestoragejs", // require('remotestoragejs')
amd: "remotestoragejs" // define(['remotestoragejs'], ...)
}
},
module: { module: {
loaders: [ loaders: [
{ test: /\.js$/, exclude: '/node_modules|dist/', loader: 'babel?presets[]=es2015' }, { test: /\.js$/, exclude: '/node_modules|dist/', loader: 'babel?presets[]=es2015' },