Remove LZString compression for data storage

This commit is contained in:
Wu Cheng-Han 2017-01-02 10:59:53 +08:00
parent c904083d1f
commit f6d8e3ab00
5 changed files with 28 additions and 37 deletions

View file

@ -152,12 +152,10 @@ function finishUpdateNote(note, _note, callback) {
if (!note || !note.server) return callback(null, null);
var body = note.server.document;
var title = note.title = models.Note.parseNoteTitle(body);
title = LZString.compressToBase64(title);
body = LZString.compressToBase64(body);
var values = {
title: title,
content: body,
authorship: LZString.compressToBase64(JSON.stringify(note.authorship)),
authorship: note.authorship,
lastchangeuserId: note.lastchangeuser,
lastchangeAt: Date.now()
};
@ -459,7 +457,7 @@ function startConnection(socket) {
var lastchangeuser = note.lastchangeuserId;
var lastchangeuserprofile = note.lastchangeuser ? models.User.getProfile(note.lastchangeuser) : null;
var body = LZString.decompressFromBase64(note.content);
var body = note.content;
var createtime = note.createdAt;
var updatetime = note.lastchangeAt;
var server = new ot.EditorSocketIOServer(body, [], noteId, ifMayEdit, operationCallback);
@ -479,7 +477,7 @@ function startConnection(socket) {
notes[noteId] = {
id: noteId,
alias: note.alias,
title: LZString.decompressFromBase64(note.title),
title: note.title,
owner: owner,
ownerprofile: ownerprofile,
permission: note.permission,
@ -491,7 +489,7 @@ function startConnection(socket) {
updatetime: moment(updatetime).valueOf(),
server: server,
authors: authors,
authorship: note.authorship ? JSON.parse(LZString.decompressFromBase64(note.authorship)) : []
authorship: note.authorship
};
return finishConnection(socket, notes[noteId], users[socket.id]);