Skip to content

Commit

Permalink
Add pre-release channel support for updates
Browse files Browse the repository at this point in the history
Fixes #1277
  • Loading branch information
perry-mitchell committed Mar 31, 2024
1 parent 266fe5c commit 4d7f2c9
Show file tree
Hide file tree
Showing 19 changed files with 47 additions and 25 deletions.
2 changes: 1 addition & 1 deletion source/main/library/build.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// This file updated automatically: changes made here will be overwritten!

export const VERSION = "2.26.1";
export const VERSION = "2.26.4";
11 changes: 10 additions & 1 deletion source/main/services/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,23 @@ export async function getVaultSettings(sourceID: VaultSourceID): Promise<VaultSe
}

export async function initialise(): Promise<void> {
// Run migrations
// Initialise config
const storage = getConfigStorage();
const config = (await storage.getValues()) as unknown as Config;
// Run migrations
const [updatedConfig, didMigrate] = runConfigMigrations(config);
if (didMigrate) {
logInfo("Detected config migration changes");
await storage.setValues(updatedConfig);
}
// Fill empty config values
for (const key in DEFAULT_CONFIG) {
const configKey = key as keyof Config;
if (typeof config[configKey] === "undefined") {
// Fill value
await setConfigValue(configKey, DEFAULT_CONFIG[configKey]);
}
}
// Initialise preferences
const preferences = naiveClone(await getConfigValue("preferences"));
for (const key in PREFERENCES_DEFAULT) {
Expand Down
4 changes: 4 additions & 0 deletions source/main/services/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { clearDelayedInterval, setDelayedInterval } from "delayable-setinterval"
import { getMainWindow } from "./windows";
import { logErr, logInfo, logWarn } from "../library/log";
import { fileExists } from "../library/file";
import { getConfigValue } from "./config";
import { UpdateProgressInfo } from "../types";

const UPDATE_AUTO_CHECK = ms("30m");
Expand Down Expand Up @@ -80,6 +81,9 @@ async function checkForUpdateInternal() {
__currentUpdate = null;
__readyUpdate = null;
__updateErrored = false;
const usePrerelease = await getConfigValue("prereleaseUpdates");
logInfo(`Using pre-release channel for updates: ${usePrerelease ? "yes" : "no"}`);
autoUpdater.allowPrerelease = usePrerelease;
autoUpdater.autoDownload = false;
autoUpdater.setFeedURL({
provider: "github",
Expand Down
31 changes: 23 additions & 8 deletions source/renderer/components/PreferencesDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const LOCK_VAULTS_TIME_MAX = ms("1d") / 1000;
const PAGE_CONNECTIVITY = "connectivity";
const PAGE_GENERAL = "general";
const PAGE_SECURITY = "security";
const PAGE_UPDATES = "updates";
const THEME_AUTO_NAME = "Auto (OS)";

const DialogFreeWidth = styled(Dialog)`
Expand Down Expand Up @@ -252,6 +253,23 @@ export function PreferencesDialog() {
</FormGroup>
</>
);
const pageUpdates = () => (
<>
<FormGroup label={t("preferences.item.pre-release.title")}>
<Callout icon="lab-test" intent={Intent.WARNING}>
<div dangerouslySetInnerHTML={{ __html: t("preferences.item.pre-release.description") }} />
</Callout>
<Switch
checked={preferences.prereleaseUpdates}
label={t("preferences.item.pre-release.label")}
onChange={(evt: React.ChangeEvent<HTMLInputElement>) => setPreferences({
...naiveClone(preferences),
prereleaseUpdates: evt.target.checked
})}
/>
</FormGroup>
</>
);
// Render
return (
<DialogFreeWidth isOpen={showPreferences.get()} onClose={close}>
Expand Down Expand Up @@ -283,21 +301,18 @@ export function PreferencesDialog() {
text={t("preferences.section.connectivity")}
/>
<Button
disabled
icon="eye-off"
text={t("preferences.section.privacy")}
/>
<Button
disabled
icon="lab-test"
text={t("preferences.section.debug")}
active={currentPage === PAGE_UPDATES}
icon="updated"
onClick={() => setCurrentPage(PAGE_UPDATES)}
text={t("preferences.section.updates")}
/>
</PreferencesMenu>
</PreferencesSidebar>
<PageContent>
{currentPage === PAGE_GENERAL && pageGeneral()}
{currentPage === PAGE_SECURITY && pageSecurity()}
{currentPage === PAGE_CONNECTIVITY && pageConnectivity()}
{currentPage === PAGE_UPDATES && pageUpdates()}
</PageContent>
</PreferencesContent>
)}
Expand Down
1 change: 0 additions & 1 deletion source/shared/i18n/translations/ca_es.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@
},
"section": {
"connectivity": "Connectivitat",
"debug": "Depurar",
"general": "General",
"privacy": "Privacitat",
"security": "Seguretat"
Expand Down
1 change: 0 additions & 1 deletion source/shared/i18n/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@
},
"section": {
"connectivity": "Konnektivität",
"debug": "Debug",
"general": "Allgemein",
"privacy": "Datenschutz",
"security": "Sicherheit"
Expand Down
10 changes: 7 additions & 3 deletions source/shared/i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@
"lock-vaults-after-time-desc": "Automatically lock vaults after some period of inactivity.",
"lock-vaults-window-closed": "Lock vaults if vault window closed",
"lock-vaults-window-closed-label": "Lock on close",
"pre-release": {
"description": "Allow Buttercup to update from the <strong>pre-release channel</strong> in addition to the stable channel. <strong>Use at your own risk</strong>. Pre-release versions are rarely stable and can corrupt vault contents and preferences.",
"label": "Enable the pre-release update channel",
"title": "Pre-release updates"
},
"secure-file-host": {
"description": "The secure file host allows the <strong>Buttercup Browser Extension</strong> to connect to local vaults on this PC via this application.",
"label": "Enable secure file host",
Expand All @@ -282,10 +287,9 @@
},
"section": {
"connectivity": "Connectivity",
"debug": "Debug",
"general": "General",
"privacy": "Privacy",
"security": "Security"
"security": "Security",
"updates": "Updates"
},
"title": "Preferences"
},
Expand Down
1 change: 0 additions & 1 deletion source/shared/i18n/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@
},
"section": {
"connectivity": "Conectividad",
"debug": "Depurar",
"general": "General",
"privacy": "Privacidad",
"security": "Seguridad"
Expand Down
1 change: 0 additions & 1 deletion source/shared/i18n/translations/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@
},
"section": {
"connectivity": "Yhteydet",
"debug": "Vianmääritys",
"general": "Yleinen",
"privacy": "Yksityisyys",
"security": "Turvallisuus"
Expand Down
1 change: 0 additions & 1 deletion source/shared/i18n/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@
},
"section": {
"connectivity": "Connexion",
"debug": "Débogage",
"general": "Général",
"privacy": "Vie privée",
"security": "Sécurité"
Expand Down
1 change: 0 additions & 1 deletion source/shared/i18n/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@
},
"section": {
"connectivity": "Connettività",
"debug": "Debug",
"general": "Generale",
"privacy": "Privacy",
"security": "Sicurezza"
Expand Down
1 change: 0 additions & 1 deletion source/shared/i18n/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@
},
"section": {
"connectivity": "接続性",
"debug": "デバッグ",
"general": "一般的",
"privacy": "プライバシー",
"security": "セキュリティ"
Expand Down
1 change: 0 additions & 1 deletion source/shared/i18n/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@
},
"section": {
"connectivity": "Verbinding",
"debug": "Debug",
"general": "Algemeen",
"privacy": "Privacy",
"security": "Beveiliging"
Expand Down
1 change: 0 additions & 1 deletion source/shared/i18n/translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@
},
"section": {
"connectivity": "Łączność",
"debug": "Debugowanie",
"general": "Ogólne",
"privacy": "Prywatność",
"security": "Bezpieczeństwo"
Expand Down
1 change: 0 additions & 1 deletion source/shared/i18n/translations/pt-br.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@
},
"section": {
"connectivity": "Conectividade",
"debug": "Depuração",
"general": "Geral",
"privacy": "Privacidade",
"security": "Segurança"
Expand Down
1 change: 0 additions & 1 deletion source/shared/i18n/translations/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@
},
"section": {
"connectivity": "Conectivitate",
"debug": "Debug",
"general": "General",
"privacy": "Confidențialitate",
"security": "Securitate"
Expand Down
1 change: 0 additions & 1 deletion source/shared/i18n/translations/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@
},
"section": {
"connectivity": "连接",
"debug": "调试",
"general": "常规",
"privacy": "隐私",
"security": "安全"
Expand Down
1 change: 1 addition & 0 deletions source/shared/symbols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const PREFERENCES_DEFAULT: Preferences = {
language: null,
lockVaultsAfterTime: false, // seconds
lockVaultsOnWindowClose: false,
prereleaseUpdates: false,
startMode: AppStartMode.None,
startWithSession: false,
uiTheme: ThemeSource.System
Expand Down
1 change: 1 addition & 0 deletions source/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export interface Preferences {
language: null | string;
lockVaultsAfterTime: false | number;
lockVaultsOnWindowClose: boolean;
prereleaseUpdates: boolean;
startMode: AppStartMode;
startWithSession: boolean;
uiTheme: ThemeSource;
Expand Down

0 comments on commit 4d7f2c9

Please sign in to comment.