FEATURE: Create notification schedule to automatically set do not disturb time (PR #11665)

The new setting is in user -> preferences -> notifications

Here is a screenshot which shows how it works. By default every day is 8am - 5pm when first enabled.

GitHub

we have an i18n helper which would allow you to just do:

dayLabel: i18n("day", "user. notification_schedule.%@")

watchout will all this code, you compare val with string so I expect it’s a string, you compare it with a value which I expect is an ineteger, and then you add integer to it.

You should know that:

"30" + 10 // "3010"

I would try to make the type of val clearer here from the beginning.

I know it’s v1, but AM/PM support is locale dependant so we should have this hardcoded.

please do direct styling on html element, this is how we end up in !important hell later

const DAYS_MAP = [
          day: DAYS_MAP[i],

I see what you did here :sweat_smile: I’m really annoyed we are creating hardcoded locales with AM/PM, this is not how we show localised time.

can you suggest something else for me?

Maybe you create a fake moment with hours and minutes and just format it to show hours and minutes?

moment().set("hour", 12).set("minute", 28).format("LT")
// 12:28 PM (if moment.locale() === "en")

@jjaffeux FEATURE: Create notification schedule to automatically set do not disturb time by markvanlan · Pull Request #11665 · discourse/discourse · GitHub

This is looking much better!

Was thinking:

wday == 0 ? 6 : wday - 1

Unless of course wday is sometimes > 6 or < 1, which would be quite bad. Your code would otherwise get nil then.

Could we use metaprogramming to DRY this up?

Could we use metaprogramming to DRY this up?

Looks good now. Thanks for iterating on it!