diff --git a/CHANGELOG.md b/CHANGELOG.md index 9514f07d..f055705d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [?] - 2026 +### Added +- Full flow for setting up SMS notifications + + ## [1.3.8] - 2026 ### Added - Device wake-up for notifications diff --git a/src/components/SmsVerificationDialog.vue b/src/components/SmsVerificationDialog.vue new file mode 100644 index 00000000..aafb27f7 --- /dev/null +++ b/src/components/SmsVerificationDialog.vue @@ -0,0 +1,284 @@ + + + diff --git a/src/constants/accountView.ts b/src/constants/accountView.ts index 6fee50ff..fb5b5029 100644 --- a/src/constants/accountView.ts +++ b/src/constants/accountView.ts @@ -65,6 +65,8 @@ export const ACCOUNT_VIEW_CONSTANTS = { Standard message and data rates may apply, and you can turn it off at any time. Do you want more details? `, + SMS_FORGET_PHONE_CONFIRM: + "This will remove your phone number and turn off all text messages. You will have to verify a number again to re-enable them. Are you sure?", REMINDER_INFO: ` This will notify you at a specific time each day. Note that it does not give you personalized notifications, diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index affc3938..1f4b2734 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -220,7 +220,7 @@ - +
@@ -229,26 +229,23 @@ class="fa-fw text-slate-400" aria-hidden="true" /> - SMS Text Message - + {{ + notifyingNewActivitySmsPhone + ? "SMS Text Message" + : "Enable Text Messages" + }}
- +
-
+
+
- Time: - {{ notifyingNewActivitySmsTime.replace(" ", " ") }} + Texting: {{ notifyingNewActivitySmsPhone }}
+ +
+
+ +
+
- Text to: - {{ notifyingNewActivitySmsPhone || "(number not set)" }} + New Activity Text + +
+ +
+ +
+
-
- +
+ Time: + {{ notifyingNewActivitySmsTime.replace(" ", " ") }} +
+
+
+ +
@@ -291,6 +341,7 @@ +
{ - if (!this.notifyingNewActivitySms) { - ( - this.$refs.pushNotificationPermission as PushNotificationPermission - ).open( - DAILY_CHECK_TITLE, - async (success: boolean, timeText: string) => { - if (success) { - // TODO: verify phone number + register SMS preference with notify-api - this.notifyingNewActivitySms = true; - this.notifyingNewActivitySmsTime = timeText; - } - }, - { skipSchedule: true }, - ); - } else { - // TODO: remove SMS preference from notify-api + async toggleSmsEnabled(): Promise { + if (this.smsEnabled) { + // Pause the channel; the verified number stays for easy re-enable. + // TODO(notify-api): disable all SMS preferences server-side. + this.smsEnabled = false; this.notifyingNewActivitySms = false; this.notifyingNewActivitySmsTime = ""; + return; } + + if (this.notifyingNewActivitySmsPhone) { + // Number already verified: just switch the channel back on. + this.smsEnabled = true; + return; + } + + (this.$refs.smsVerificationDialog as SmsVerificationDialog).open( + async (success: boolean, phoneNumber?: string) => { + if (success && phoneNumber) { + this.notifyingNewActivitySmsPhone = phoneNumber; + this.smsEnabled = true; + } + }, + ); + } + + /** + * Forget the verified phone number entirely: the master toggle turns off + * and every SMS notification becomes unavailable until a number is + * verified again. + */ + async forgetSmsPhoneNumber(): Promise { + this.notify.confirm( + ACCOUNT_VIEW_CONSTANTS.NOTIFICATIONS.SMS_FORGET_PHONE_CONFIRM, + async () => { + // TODO(notify-api): DELETE /api/sms/register to remove the number + // and all SMS preferences server-side. + this.notifyingNewActivitySmsPhone = ""; + this.smsEnabled = false; + this.notifyingNewActivitySms = false; + this.notifyingNewActivitySmsTime = ""; + }, + ); + } + + /** + * Toggle the "New Activity Text" notification (only reachable while the + * SMS channel is enabled). + * + * TODO (notify-api wiring): on enable, POST the SMS-notification preference + * with SMS-specific params (channel="sms", phoneNumber, sendTime) -- the + * same alert as the in-app channel, delivered by a different transport. On + * disable, tell the notify-api to remove it. + */ + async showNewActivitySmsNotificationChoice(): Promise { + if (this.notifyingNewActivitySms) { + this.notifyingNewActivitySms = false; + this.notifyingNewActivitySmsTime = ""; + return; + } + await this.promptSmsTimeAndEnable(); + } + + /** + * Prompt for the SMS send time (reusing the time-picker dialog) and enable + * the SMS channel on success. + * + * MOCK-UP: the chosen time is held in component state only. + */ + async promptSmsTimeAndEnable(): Promise { + (this.$refs.pushNotificationPermission as PushNotificationPermission).open( + DAILY_CHECK_TITLE, + async (success: boolean, timeText: string) => { + if (success) { + // TODO: register SMS preference with notify-api (phone + time) + this.notifyingNewActivitySms = true; + this.notifyingNewActivitySmsTime = timeText; + } + }, + { skipSchedule: true }, + ); } /** @@ -1922,6 +2040,10 @@ export default class AccountViewView extends Vue { this.notifyingReminder = false; this.notifyingReminderMessage = ""; this.notifyingReminderTime = ""; + // SMS channel (mock-up, component-local). TODO: also tell the notify-api. + // Leaves the verified phone number in place intentionally. + this.notifyingNewActivitySms = false; + this.notifyingNewActivitySmsTime = ""; } /** diff --git a/src/views/HelpNotificationTypesView.vue b/src/views/HelpNotificationTypesView.vue index 9516b851..a42c0835 100644 --- a/src/views/HelpNotificationTypesView.vue +++ b/src/views/HelpNotificationTypesView.vue @@ -58,11 +58,43 @@

New Activity Notifications -- Texts From A Server

- This New Activity Notification SMS will be sent to you when there is new, relevant activity - for you. + This New Activity Notification SMS will be sent to you when there is new, relevant activity + for you. It will only trigger if something involves you or a project of interest; it will not bug you for other, general activity.

+

Notes and caveats for text messages:

+
    +
  • + Text messages are opt-in: they are only sent after you enter your + phone number and confirm it with a verification code. +
  • +
  • + Standard message and data rates from your carrier may apply. +
  • +
  • + Message frequency is at most one New Activity text per day, at the + time you choose. +
  • +
  • + You can stop at any time: turn off the toggle in your settings, use + "Forget Phone Number" to remove your number entirely, or reply STOP + to any message. Reply HELP for help. +
  • +
  • + Delivery is not guaranteed or precisely timed; carriers may delay + or drop messages, and neither we nor the carriers are liable for + late or undelivered texts. +
  • +
  • + Only US phone numbers are currently supported. +
  • +
  • + Your phone number is used only to send you these notifications; it + is stored on the notification server and is deleted when you choose + "Forget Phone Number". +
  • +