simplify icon indicating copy to clipboard operation
simplify copied to clipboard

Add "reminder" shortcut button

Open irapha opened this issue 7 years ago • 7 comments

Since Inbox shutdown, and the realization that Tasks is not a good replacement for reminders, many users have been using "emails to self" as a substitute for reminders.

This issue proposes adding a button (above the + button) that starts composing a new message to:self, and with the focus being given to the subject line

irapha avatar Apr 18 '19 17:04 irapha

I'm going to close this for now and add it to my Someday Maybe list (e.g. I'd like to come back to it but not in the immediate future).

(1) This adds a button for everyone and it doesn't actually work that well (you can't set it to remind you at a specific time during compose)

(2) This appears to be annoyingly difficult. I could maybe do this with a mailto link if you have Gmail set as your default mail client but not everyone will have that set. Doing it via simulating a click on the compose button (which would always work) doesn't seem to work (or I'm doing it wrong).

I made sure that when you click on the compose button, it is on this element: document.querySelector('.z0 div[role="button"]')

And I tried doing this: document.querySelector('.z0 div[role="button"]').click()

I also tried the various methods in here: https://stackoverflow.com/questions/2705583/how-to-simulate-a-click-with-javascript/2706236#2706236

It might be that these things are just blocked in the console and I need to bake them into Simplify to test.

leggett avatar Apr 18 '19 18:04 leggett

@iRapha, what do you think about: instead of (or in addition to) adding a reminder button, add a keyboard shortcut "t" ?

(1) I've been sending an email to myself, then clicking on snooze icon in inbox. It's actually not that bad. It's the same as Inbox -- after typing the reminder, you move your mouse cursor to the snooze icon and click.

melissachang avatar Apr 19 '19 19:04 melissachang

This flow is what I’ve been doing as well.

On Fri, Apr 19, 2019 at 12:38 melissachang [email protected] wrote:

@iRapha https://github.com/iRapha, what do you think about: instead of (or in addition to) adding a reminder button, add a keyboard shortcut "t" ?

(1) I've been sending an email to myself, then clicking on snooze icon in inbox. It's actually not that bad. It's the same as Inbox -- after typing the reminder, you move your mouse cursor to the snooze icon and click.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/leggett/simplify/issues/68#issuecomment-484995360, or mute the thread https://github.com/notifications/unsubscribe-auth/ABYLJB7OXV66PMRHHZSGX2DPRINT3ANCNFSM4HG7BKCA .

-- Cheers, -Rapha

irapha avatar Apr 20 '19 02:04 irapha

I was playing around with this. There was something like:

if (b._fastclick) {
  // This code was executed during a javascript .click()
}

So it looks like the compose button does something different if click is too fast. So I simulated a slow mouse click. simulate() is from SO. This code works for me.

function simulate(element, eventName)
{
    var options = extend(defaultOptions, arguments[2] || {});
    var oEvent, eventType = null;

    for (var name in eventMatchers)
    {
        if (eventMatchers[name].test(eventName)) { eventType = name; break; }
    }

    if (!eventType)
        throw new SyntaxError('Only HTMLEvents and MouseEvents interfaces are supported');

    if (document.createEvent)
    {
        oEvent = document.createEvent(eventType);
        if (eventType == 'HTMLEvents')
        {
            oEvent.initEvent(eventName, options.bubbles, options.cancelable);
        }
        else
        {
            oEvent.initMouseEvent(eventName, options.bubbles, options.cancelable, document.defaultView,
            options.button, options.pointerX, options.pointerY, options.pointerX, options.pointerY,
            options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.button, element);
        }
        element.dispatchEvent(oEvent);
    }
    else
    {
        options.clientX = options.pointerX;
        options.clientY = options.pointerY;
        var evt = document.createEventObject();
        oEvent = extend(evt, options);
        element.fireEvent('on' + eventName, oEvent);
    }
    return element;
}

function extend(destination, source) {
    for (var property in source)
      destination[property] = source[property];
    return destination;
}

var eventMatchers = {
    'HTMLEvents': /^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,
    'MouseEvents': /^(?:click|dblclick|mouse(?:down|up|over|move|out))$/
}
var defaultOptions = {
    pointerX: 0,
    pointerY: 0,
    button: 0,
    ctrlKey: false,
    altKey: false,
    shiftKey: false,
    metaKey: false,
    bubbles: true,
    cancelable: true
}

simulate(document.querySelector('.z0 div[role="button"]'), "mousedown");
simulate(document.querySelector('.z0 div[role="button"]'), "mouseup");

melissachang avatar Apr 20 '19 05:04 melissachang

@leggett I have found the approach suggested here to work well for simulating key presses in most cases: https://stackoverflow.com/a/24026594

As a working example for pressing the compose button,

var compose = document.querySelector('.z0 > div');
simulateClick(compose);

function simulateClick(node) {
	['mouseover','mousedown','mouseup','click'].forEach(function(ev) {
		var clickEvent = document.createEvent('MouseEvents');
		clickEvent.initEvent(ev, true, true);
		node.dispatchEvent(clickEvent);
	});
}

However I also disagree with this approach at imitating Reminders because it can't easily be replicated on mobile, and emails aren't editable whereas tasks are. As an alternative approach, I have modified the GTasks GUI to act more like Reminders while keeping it functionally similar to the mobile experience:

  1. When the sort order is "User mode", only tasks which are currently due are visible. This is similar to the notifications that Tasks gives on my phone: I don't swipe them away until they're done, so I get a list of tasks which are due in my notification bar.
  2. When the sort order is "Date", I can see the ordered list of when items are due. This is the same sort order that I use in the Tasks app on my phone.

This can mostly be done with CSS -- Javascript is only necessary for tasks which are due today, to determine whether their time has passed. If there's general interest then I can share the code, or submit a pull request with the implementation.

I've extended this further to move the addons pane into the left side nav menu, and added a Tasks icon over the hamburger menu when tasks are due (so I know when a task is due even if the addon pane is hidden) but my implementation is still slightly buggy, potentially incompatible with 3rd party addons, and I think that this goes beyond the spirit of Simplify.

sweinreich avatar Apr 26 '19 23:04 sweinreich

Regarding replicating on mobile -- I have a separate system for creating reminders on mobile that I'll document at some point. It works quite well (except reminders aren't editable, which is fine most of the time).

Obviously reminders can't be created on mobile with this extension. However, if this extension were to create reminders as described in this issue, they could be consumed on mobile just fine.

Emails not being editable -- I (and many others) have been using "emails-to-self" to simulate reminders in emails for a while. Most of the time -- say 90+% -- it's fine that they're not editable.

melissachang avatar Apr 26 '19 23:04 melissachang

Closing this as it is a dup for #10 -- I have this on my list of bigger things to do after I launch subscriptions. I have some good ideas I think on this around emails to yourself and schedule send.

leggett avatar Mar 17 '21 03:03 leggett