Skip to content

initial commit for show badge issue - #149

Merged
neSpecc merged 23 commits into
version2.0from
show-badge
Mar 20, 2018
Merged

neSpecc merged 23 commits into
version2.0from
show-badge

Conversation

@khaydarov

@khaydarov khaydarov commented Feb 27, 2018 •

Copy link
Copy Markdown
Member

close #72

Comment thread src/controllers/notes.js Outdated
* Setup event handlers
*/
constructor() {
this.visits = new Visits();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

комментарий

Comment thread src/controllers/notes.js Outdated
let list = new NotesList(folderId);
let notesInFolder = await list.get();

await this.visits.syncVisits();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

комментарий

Comment thread src/controllers/notes.js Outdated
* set up note visits
*/
notesInFolder.forEach( async (note) => {
if ( this.visits.visitedNotes[note._id] >= note.dtModify ) {

Copy link
Copy Markdown
Member

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не обрабатывается отсутствие статьи в visits

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

перенести в модель NotesList в свойство isSeen

Comment thread src/controllers/notes.js Outdated
*/
notesInFolder.forEach( async (note) => {
if ( this.visits.visitedNotes[note._id] >= note.dtModify ) {
note.visited = true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note.is_read = true

Comment thread src/models/visits.js
const db = require('../utils/database'),
Time = require('../utils/time');

class Visits {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SeenStateObserver

Comment thread src/controllers/notes.js Outdated
/**
* set up note visits
*/
notesInFolder.forEach( async (note) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

подгружать индикаторы isSeen отдельным запросом после открытия папки, передав ids статей

Comment thread public/javascripts/folder.js Outdated
* "once" automatically removes listener
*/
window.ipcRenderer.send('notes - seen', { noteIds });
window.ipcRenderer.once('notes - seen', (event, {data}) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

надо описать {data}

Comment thread src/controllers/notes.js Outdated
});

ipcMain.on('notes - seen', async (event, {noteIds}) => {
let seenNotes = await this.SeenStateObserver.getSeenNotes(noteIds);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вынести логику в обработчик this.markAsSeen();

Comment thread src/controllers/notes.js Outdated

ipcMain.on('note - save', (event, {note}) => {
this.saveNote(note, event);
this.SeenStateObserver.touch(note.data.id);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

перенести логику в обработчик this.saveNote

Comment thread src/controllers/notes.js Outdated
this.getNote(id, event);

// set note as visited
this.SeenStateObserver.touch(id);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

перенести логику в обработчик

* @todo asynchronous notes load
*/
this.notesListWrapper = document.querySelector('[name="js-folder-notes-menu"]');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем убран todo? он еще актуален

Comment thread public/javascripts/folder.js Outdated
setNoteSeenStatus() {
let noteIds = [];

this.notes.forEach( (note) => {

Copy link
Copy Markdown
Member

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);

Comment thread public/javascripts/folder.js Outdated

/**
* @type {Object} data - "note - seen" event responses object of "seen" states
* Ex: data[ noteId ] = lastSeen - timestamp of last seen

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

эти две строчки комментов оформлены не по jsdoc

Comment thread src/controllers/notes.js Outdated
isRootFolder: !noteData.folderId
});

// make "seen" edited note

@neSpecc neSpecc Mar 15, 2018 •

Copy link
Copy Markdown
Member

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

Comment thread src/controllers/notes.js Outdated
}

/**
* Get's information about note visits and emits the event

Copy link
Copy Markdown
Member

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

Comment thread src/controllers/notes.js Outdated
async markAsSeen(event, noteIds) {
let seenNotes = await this.seenStateObserver.getSeenNotes(noteIds);
event.sender.send('notes - seen', {
data: seenNotes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data не лучшее название в данном случае (я долго пытался понять код клиента), лучше назвать seenIds.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и вообще data — всегда плохое название

Comment thread src/models/seenStateObserver.js Outdated
@@ -0,0 +1,70 @@
/**
* @module SeenStateObserver
* Checks seen notes or makes notes "seen"

Copy link
Copy Markdown
Member

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

Comment thread 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this не нужно. тип ставится перед названием 😟

Comment thread src/models/seenStateObserver.js Outdated

/**
* Sets new last seen time to mark note as read
* @param noteId {Number} - note id

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тип перед названием

Comment thread src/models/seenStateObserver.js Outdated
let response = {};

notes.forEach( (note) => {
response[note.noteId] = note.lastSeen;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

есть подозрение, что у тебя не работает линтер

Comment thread src/models/seenStateObserver.js Outdated
lastSeen : Time.now
};

await db.update(db.VISITS, query, {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

из параметров нужно вынести объекты в переменные

@khaydarov khaydarov Mar 20, 2018 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

зачем создавать лишние переменные и выделять для них память, когда после вызова тут же уничтожаются

@neSpecc neSpecc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@neSpecc
neSpecc merged commit 595145d into version2.0 Mar 20, 2018
@neSpecc
neSpecc deleted the show-badge branch March 20, 2018 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Show count updates label

3 participants