Repository navigation
initial commit for show badge issue - #149
Conversation
| * Setup event handlers | ||
| */ | ||
| constructor() { | ||
| this.visits = new Visits(); |
| let list = new NotesList(folderId); | ||
| let notesInFolder = await list.get(); | ||
|
|
||
| await this.visits.syncVisits(); |
| * set up note visits | ||
| */ | ||
| notesInFolder.forEach( async (note) => { | ||
| if ( this.visits.visitedNotes[note._id] >= note.dtModify ) { |
There was a problem hiding this comment.
не обрабатывается отсутствие статьи в visits
There was a problem hiding this comment.
перенести в модель NotesList в свойство isSeen
| */ | ||
| notesInFolder.forEach( async (note) => { | ||
| if ( this.visits.visitedNotes[note._id] >= note.dtModify ) { | ||
| note.visited = true; |
| const db = require('../utils/database'), | ||
| Time = require('../utils/time'); | ||
|
|
||
| class Visits { |
| /** | ||
| * set up note visits | ||
| */ | ||
| notesInFolder.forEach( async (note) => { |
There was a problem hiding this comment.
подгружать индикаторы isSeen отдельным запросом после открытия папки, передав ids статей
# Conflicts: # public/build/bundle.js.map
| * "once" automatically removes listener | ||
| */ | ||
| window.ipcRenderer.send('notes - seen', { noteIds }); | ||
| window.ipcRenderer.once('notes - seen', (event, {data}) => { |
| }); | ||
|
|
||
| ipcMain.on('notes - seen', async (event, {noteIds}) => { | ||
| let seenNotes = await this.SeenStateObserver.getSeenNotes(noteIds); |
There was a problem hiding this comment.
вынести логику в обработчик this.markAsSeen();
|
|
||
| ipcMain.on('note - save', (event, {note}) => { | ||
| this.saveNote(note, event); | ||
| this.SeenStateObserver.touch(note.data.id); |
There was a problem hiding this comment.
перенести логику в обработчик this.saveNote
| this.getNote(id, event); | ||
|
|
||
| // set note as visited | ||
| this.SeenStateObserver.touch(id); |
| * @todo asynchronous notes load | ||
| */ | ||
| this.notesListWrapper = document.querySelector('[name="js-folder-notes-menu"]'); | ||
|
|
There was a problem hiding this comment.
зачем убран todo? он еще актуален
| setNoteSeenStatus() { | ||
| let noteIds = []; | ||
|
|
||
| this.notes.forEach( (note) => { |
There was a problem hiding this comment.
let noteIds = this.notes.map(note => note._id);|
|
||
| /** | ||
| * @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.
эти две строчки комментов оформлены не по jsdoc
| isRootFolder: !noteData.folderId | ||
| }); | ||
|
|
||
| // make "seen" edited note |
| } | ||
|
|
||
| /** | ||
| * Get's information about note visits and emits the event |
There was a problem hiding this comment.
about note visits
about seen-state of passed notes
| 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.
data не лучшее название в данном случае (я долго пытался понять код клиента), лучше назвать seenIds.
There was a problem hiding this comment.
и вообще data — всегда плохое название
| @@ -0,0 +1,70 @@ | |||
| /** | |||
| * @module SeenStateObserver | |||
| * Checks seen notes or makes notes "seen" | |||
There was a problem hiding this comment.
Manipulates seen-state of Notes
| * @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.
this не нужно. тип ставится перед названием 😟
|
|
||
| /** | ||
| * Sets new last seen time to mark note as read | ||
| * @param noteId {Number} - note id |
| let response = {}; | ||
|
|
||
| notes.forEach( (note) => { | ||
| response[note.noteId] = note.lastSeen; |
There was a problem hiding this comment.
есть подозрение, что у тебя не работает линтер
| lastSeen : Time.now | ||
| }; | ||
|
|
||
| await db.update(db.VISITS, query, { |
There was a problem hiding this comment.
из параметров нужно вынести объекты в переменные
There was a problem hiding this comment.
зачем создавать лишние переменные и выделять для них память, когда после вызова тут же уничтожаются
close #72