You are viewing a single comment's thread from:

RE: ​

in #utopian-io6 years ago (edited)

Great job buddy !! the idea you had looks awesome :) What i would suggest is to implement aswell a function that also analyses text even if it is on another line...I believe a lot will do this mistake so why not implement it ! :)

quoting your code:

function findMentionLine(comment) {
    return comment.split(/\r?\n/).find(line => line.includes('@' + REMAIND_ME_USERNAME)) || null;
}

function getFutureDateByTextAndContext(text, context) {
    return chrono.parseDate(text, context);
}

function getFurureDateByCommentTextAndContextDate(commentText, contextDate) {
    const mentionText = findMentionLine(commentText);
    const future = getFutureDateByTextAndContext(mentionText || '', moment(contextDate));
    return future ? moment(future) : null;
}

In terms of coding that will not be even a big issue for you. Just read each line of the comment and assign it in to an array of strings (each line of the comment as one element of the array) then loop through the array as per array.length (that will let the code know that if the array.length > 1 there are more lines to look at) and do a text matching into a couple IF statement containing some keyword as (Day, Hour, Minute, etc...) to know where to start looking for the time of the set reminder then pass the result to the other functions.

Again great job man !! i will for sure use it !! and by the way i already forked your repo to keep up to date with whatever you will implement :)

Sort:  

Hey!

In the very beginning the entire comment text was allowed to be parsed in order to search for a target date.

What I was concern about was that a random text might be picked by a search algorithm instead of user-intended one.

It's important, as even ordinary words matter, like "today", so a comment starting with "How are you today?" might fool an algorithm.

That might be tricky, so eventually decided to use one-line rule, as it's more secure, but - as you pointed correctly - less user friendly.

Really appreciate your input. Thank you for your comment!
All the best!

Thank you for your answer!!

I agree that a comment such as "how are you today" could fool the algorythm but in the meantime whoever will tag remind-me is already aware of what he is doing so i dont think he might write such comment.

The only possibility i forsee is that he could write his date/time on another line.

Still the "how are you today" example could be excluded by the algorythm since a reminder will have any date/time keywords but the most important thing is they will use AT or ON as a prefix to their messages most of the time like "ON the 2th of June 2019" or " AT 5:00 a. m.". Thus filtering aswell using this keywords will help in detecting REAL reminders.

Again great job and keep the good work up!!

Cheers