-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initial commit for show badge issue #149
Conversation
src/controllers/notes.js
Outdated
@@ -22,6 +23,8 @@ class NotesController { | |||
* Setup event handlers | |||
*/ | |||
constructor() { | |||
this.visits = new Visits(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
комментарий
src/controllers/notes.js
Outdated
@@ -96,6 +102,18 @@ class NotesController { | |||
let list = new NotesList(folderId); | |||
let notesInFolder = await list.get(); | |||
|
|||
await this.visits.syncVisits(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
комментарий
src/controllers/notes.js
Outdated
* set up note visits | ||
*/ | ||
notesInFolder.forEach( async (note) => { | ||
if ( this.visits.visitedNotes[note._id] >= note.dtModify ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.visits.getDate(note._id)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не обрабатывается отсутствие статьи в visits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
перенести в модель NotesList в свойство isSeen
src/controllers/notes.js
Outdated
*/ | ||
notesInFolder.forEach( async (note) => { | ||
if ( this.visits.visitedNotes[note._id] >= note.dtModify ) { | ||
note.visited = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note.is_read = true
src/models/visits.js
Outdated
const db = require('../utils/database'), | ||
Time = require('../utils/time'); | ||
|
||
class Visits { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SeenStateObserver
src/controllers/notes.js
Outdated
/** | ||
* set up note visits | ||
*/ | ||
notesInFolder.forEach( async (note) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
подгружать индикаторы isSeen отдельным запросом после открытия папки, передав ids статей
# Conflicts: # public/build/bundle.js.map
public/javascripts/folder.js
Outdated
* "once" automatically removes listener | ||
*/ | ||
window.ipcRenderer.send('notes - seen', { noteIds }); | ||
window.ipcRenderer.once('notes - seen', (event, {data}) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
надо описать {data}
src/controllers/notes.js
Outdated
}); | ||
|
||
ipcMain.on('note - delete', (event, {id}) => { | ||
this.deleteNote(id, event); | ||
}); | ||
|
||
ipcMain.on('notes - seen', async (event, {noteIds}) => { | ||
let seenNotes = await this.SeenStateObserver.getSeenNotes(noteIds); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
вынести логику в обработчик this.markAsSeen();
src/controllers/notes.js
Outdated
ipcMain.on('note - save', (event, {note}) => { | ||
this.saveNote(note, event); | ||
this.SeenStateObserver.touch(note.data.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
перенести логику в обработчик this.saveNote
src/controllers/notes.js
Outdated
@@ -32,11 +36,21 @@ class NotesController { | |||
|
|||
ipcMain.on('note - get', (event, {id}) => { | |||
this.getNote(id, event); | |||
|
|||
// set note as visited | |||
this.SeenStateObserver.touch(id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
перенести логику в обработчик
public/javascripts/folder.js
Outdated
* @todo asynchronous notes load | ||
*/ | ||
this.notesListWrapper = document.querySelector('[name="js-folder-notes-menu"]'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зачем убран todo? он еще актуален
public/javascripts/folder.js
Outdated
setNoteSeenStatus() { | ||
let noteIds = []; | ||
|
||
this.notes.forEach( (note) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let noteIds = this.notes.map(note => note._id);
public/javascripts/folder.js
Outdated
|
||
/** | ||
* @type {Object} data - "note - seen" event responses object of "seen" states | ||
* Ex: data[ noteId ] = lastSeen - timestamp of last seen |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
эти две строчки комментов оформлены не по jsdoc
src/controllers/notes.js
Outdated
@@ -78,6 +85,10 @@ class NotesController { | |||
note: newNote, | |||
isRootFolder: !noteData.folderId | |||
}); | |||
|
|||
// make "seen" edited note |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mark edited Note as seen
src/controllers/notes.js
Outdated
@@ -149,6 +163,19 @@ class NotesController { | |||
event.returnValue = false; | |||
} | |||
} | |||
|
|||
/** | |||
* Get's information about note visits and emits the event |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
about note visits
about seen-state of passed notes
src/controllers/notes.js
Outdated
async markAsSeen(event, noteIds) { | ||
let seenNotes = await this.seenStateObserver.getSeenNotes(noteIds); | ||
event.sender.send('notes - seen', { | ||
data: seenNotes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data не лучшее название в данном случае (я долго пытался понять код клиента), лучше назвать seenIds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
и вообще data — всегда плохое название
src/models/seenStateObserver.js
Outdated
@@ -0,0 +1,70 @@ | |||
/** | |||
* @module SeenStateObserver | |||
* Checks seen notes or makes notes "seen" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manipulates seen-state of Notes
src/models/seenStateObserver.js
Outdated
* @class SeenStateObserver | ||
* Class can "touch" note (mark as seen) or get information about visited notes | ||
* | ||
* @property this.getSeenNotes {Function} - returns information about passed note |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this не нужно. тип ставится перед названием 😟
src/models/seenStateObserver.js
Outdated
|
||
/** | ||
* Sets new last seen time to mark note as read | ||
* @param noteId {Number} - note id |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тип перед названием
src/models/seenStateObserver.js
Outdated
let response = {}; | ||
|
||
notes.forEach( (note) => { | ||
response[note.noteId] = note.lastSeen; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
есть подозрение, что у тебя не работает линтер
src/models/seenStateObserver.js
Outdated
lastSeen : Time.now | ||
}; | ||
|
||
await db.update(db.VISITS, query, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
из параметров нужно вынести объекты в переменные
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зачем создавать лишние переменные и выделять для них память, когда после вызова тут же уничтожаются
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
close #72