From c6443f24b274a9fcdeba08a05572c5000bcf5934 Mon Sep 17 00:00:00 2001 From: Jed Fox <git@jedfox.com> Date: Wed, 21 Jun 2023 15:16:37 -0400 Subject: [PATCH] Remove upgrade notifications code (#1156) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit None of this code is relevant to people who have used the open source app. I initially wanted to leave it in so it could be used for major new features in the future, but as it falls further and further out of date I think it’s best to just delete it in a clean PR that can be referenced later if desired. --- .../src/components/FinancesApp.js | 10 --- .../src/client/upgrade-notifications.ts | 76 ------------------- packages/loot-core/src/server/main.ts | 24 ------ packages/loot-core/src/server/prefs.ts | 22 ++++-- .../loot-core/src/types/main-handlers.d.ts | 4 - upcoming-release-notes/1156.md | 6 ++ 6 files changed, 20 insertions(+), 122 deletions(-) delete mode 100644 packages/loot-core/src/client/upgrade-notifications.ts create mode 100644 upcoming-release-notes/1156.md diff --git a/packages/desktop-client/src/components/FinancesApp.js b/packages/desktop-client/src/components/FinancesApp.js index 74e592dd7..c82f1524f 100644 --- a/packages/desktop-client/src/components/FinancesApp.js +++ b/packages/desktop-client/src/components/FinancesApp.js @@ -20,7 +20,6 @@ import { AccountsProvider } from 'loot-core/src/client/data-hooks/accounts'; import { PayeesProvider } from 'loot-core/src/client/data-hooks/payees'; import { SpreadsheetProvider } from 'loot-core/src/client/SpreadsheetProvider'; import checkForUpdateNotification from 'loot-core/src/client/update-notification'; -import checkForUpgradeNotifications from 'loot-core/src/client/upgrade-notifications'; import * as undo from 'loot-core/src/platform/client/undo'; import Cog from '../icons/v1/Cog'; @@ -263,15 +262,6 @@ function FinancesApp(props) { setTimeout(async () => { await props.sync(); - // Check for upgrade notifications. We do this after syncing - // because these states are synced across devices, so they will - // only see it once for this file - checkForUpgradeNotifications( - props.addNotification, - props.resetSync, - patchedHistory, - ); - await checkForUpdateNotification( props.addNotification, getIsOutdated, diff --git a/packages/loot-core/src/client/upgrade-notifications.ts b/packages/loot-core/src/client/upgrade-notifications.ts deleted file mode 100644 index c2eca0d2a..000000000 --- a/packages/loot-core/src/client/upgrade-notifications.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { send } from '../platform/client/fetch'; - -import * as Platform from './platform'; - -export default function checkForUpgradeNotifications( - addNotification, - resetSync, - // Note: history is only available on desktop - history, -) { - // TODO: Probably should only show one of these at at time? - send('get-upgrade-notifications').then(types => { - types.forEach(type => { - switch (type) { - case 'schedules': { - let message = - 'Track bills and subscriptions and much more with scheduled transactions. We can search all your existing transactions and try to find existing schedules.\n\n' + - (global.IS_BETA - ? 'NOTE: You are using the beta version, and this will not reset your sync data. This is safe to do.' - : ''); - - if (Platform.env === 'mobile') { - message = - 'Track bills and subscriptions and much more with scheduled transactions. Upcoming transactions will be shown in the accounts screen. Use the desktop app to create schedules.'; - } - - addNotification({ - type: 'message', - title: 'Scheduled transactions are now available!', - message, - sticky: true, - id: 'find-schedules', - button: Platform.env !== 'mobile' && { - title: 'Find schedules', - action: async () => { - window.__history && - window.__history.push('/schedule/discover', { - locationPtr: window.__history.location, - }); - }, - }, - onClose: () => { - send('seen-upgrade-notification', { type: 'schedules' }); - }, - }); - break; - } - - case 'repair-splits': - if (history) { - addNotification({ - type: 'message', - title: 'Split transactions now support transfers & payees', - message: - 'The payee field is now available on split transactions, allowing you to perform transfers on individual split transactions.\n\nAll existing split transactions have a blank payee and we recommend using the tool below to set the payee from the parent. [View a video walkthrough](https://www.youtube.com/watch?v=5kTtAsB0Oqk)', - sticky: true, - id: 'repair-splits', - button: { - title: 'Repair splits...', - action: () => - history.push('/tools/fix-splits', { - locationPtr: history.location, - }), - }, - onClose: () => { - send('seen-upgrade-notification', { type: 'repair-splits' }); - }, - }); - } - break; - - default: - } - }); - }); -} diff --git a/packages/loot-core/src/server/main.ts b/packages/loot-core/src/server/main.ts index e003bd7c0..fa0015087 100644 --- a/packages/loot-core/src/server/main.ts +++ b/packages/loot-core/src/server/main.ts @@ -2266,30 +2266,6 @@ async function loadBudget(id) { return {}; } -handlers['get-upgrade-notifications'] = async function () { - let { id } = prefs.getPrefs(); - if (id === TEST_BUDGET_ID || id === DEMO_BUDGET_ID) { - return []; - } - - let types = ['schedules', 'repair-splits']; - let unseen = []; - - for (let type of types) { - let key = `notifications.${type}`; - if (prefs.getPrefs()[key] == null) { - unseen.push(type); - } - } - - return unseen; -}; - -handlers['seen-upgrade-notification'] = async function ({ type }) { - let key = `notifications.${type}`; - prefs.savePrefs({ [key]: true }); -}; - handlers['upload-file-web'] = async function ({ filename, contents }) { if (!Platform.isWeb) { return null; diff --git a/packages/loot-core/src/server/prefs.ts b/packages/loot-core/src/server/prefs.ts index ba62c9a41..46ced65dd 100644 --- a/packages/loot-core/src/server/prefs.ts +++ b/packages/loot-core/src/server/prefs.ts @@ -23,6 +23,19 @@ export async function loadPrefs(id?) { prefs = { id, budgetName: id }; } + // delete released feature flags + let releasedFeatures = ['syncAccount']; + for (const feature of releasedFeatures) { + delete prefs[`flags.${feature}`]; + } + + // delete legacy notifications + for (const key of Object.keys(prefs)) { + if (key.startsWith('notifications.')) { + delete prefs[key]; + } + } + // No matter what is in `id` field, force it to be the current id. // This makes it resilient to users moving around folders, etc prefs.id = id; @@ -69,14 +82,7 @@ export function getPrefs() { } export function getDefaultPrefs(id, budgetName) { - // Add any notifications in here that new users shouldn't see. - // Without them, a popup will show to explain a new feature. - return { - id, - budgetName, - 'notifications.schedules': true, - 'notifications.repair-splits': true, - }; + return { id, budgetName }; } export async function readPrefs(id) { diff --git a/packages/loot-core/src/types/main-handlers.d.ts b/packages/loot-core/src/types/main-handlers.d.ts index 79ff5d41d..3925c8d8d 100644 --- a/packages/loot-core/src/types/main-handlers.d.ts +++ b/packages/loot-core/src/types/main-handlers.d.ts @@ -306,10 +306,6 @@ export interface MainHandlers { 'export-budget': () => Promise<unknown>; - 'get-upgrade-notifications': () => Promise<unknown[]>; - - 'seen-upgrade-notification': (arg: { type }) => Promise<unknown>; - 'upload-file-web': (arg: { filename; contents }) => Promise<'ok'>; 'backups-get': (arg: { id }) => Promise<unknown>; diff --git a/upcoming-release-notes/1156.md b/upcoming-release-notes/1156.md new file mode 100644 index 000000000..d3e9c168e --- /dev/null +++ b/upcoming-release-notes/1156.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [j-f1] +--- + +Remove unused code for notifying about major new features when updating -- GitLab