mirror of
https://gitlab.com/ArkHost/HelixNotes.git
synced 2026-07-24 07:45:57 +02:00
v1.1.9 - Android version prep
This commit is contained in:
@@ -32,7 +32,9 @@
|
||||
appConfig,
|
||||
quickAccessPaths,
|
||||
tags,
|
||||
notes
|
||||
notes,
|
||||
updateAvailable as globalUpdateAvailable,
|
||||
settingsTab
|
||||
} from '$lib/stores/app';
|
||||
|
||||
const appWindow = getCurrentWindow();
|
||||
@@ -446,6 +448,11 @@
|
||||
{$activeNotebook?.name || 'All Notes'}
|
||||
{/if}
|
||||
</span>
|
||||
{#if $globalUpdateAvailable && $mobileView === 'sidebar'}
|
||||
<button class="mobile-update-badge" onclick={() => { $settingsTab = 'updates'; $showSettings = true; }}>
|
||||
v{$globalUpdateAvailable.version}
|
||||
</button>
|
||||
{/if}
|
||||
{/if}
|
||||
<div class="mobile-header-actions">
|
||||
{#if $mobileView === 'editor'}
|
||||
@@ -748,6 +755,20 @@
|
||||
padding: 0 4px;
|
||||
}
|
||||
|
||||
.mobile-update-badge {
|
||||
background: var(--accent);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 10px;
|
||||
padding: 2px 8px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.mobile-header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { showSettings, theme, appConfig, updateAvailable as globalUpdateAvailable, updateObj as globalUpdateObj, installType, settingsTab, vaultReady } from '$lib/stores/app';
|
||||
import { showSettings, theme, appConfig, updateAvailable as globalUpdateAvailable, updateObj as globalUpdateObj, installType, settingsTab, vaultReady, androidApkUrl, checkForUpdateMobile } from '$lib/stores/app';
|
||||
import { setTheme, setAccentColor, setFontSize, setFontFamily, setLineHeight, setGeneralSettings, importObsidian, createBackup, listBackups, restoreBackup, deleteBackup, setBackupSettings, setAiSettings, testAiConnection } from '$lib/api';
|
||||
import { open as openDialog } from '@tauri-apps/plugin-dialog';
|
||||
import { listen } from '@tauri-apps/api/event';
|
||||
import { check as checkUpdate } from '@tauri-apps/plugin-updater';
|
||||
import { getVersion } from '@tauri-apps/api/app';
|
||||
import { openUrl } from '@tauri-apps/plugin-opener';
|
||||
import type { ImportResult, BackupEntry } from '$lib/types';
|
||||
|
||||
const isMobile = /android|ios/i.test(navigator.userAgent);
|
||||
@@ -56,15 +56,27 @@
|
||||
updateMessage = null;
|
||||
updateAvailable = null;
|
||||
try {
|
||||
const update = await checkUpdate();
|
||||
if (update) {
|
||||
updateObj = update;
|
||||
$globalUpdateObj = update;
|
||||
updateAvailable = { version: update.version, body: update.body, date: update.date };
|
||||
globalUpdateAvailable.set({ version: update.version, body: update.body });
|
||||
updateMessage = { type: 'info', text: `Version ${update.version} is available!` };
|
||||
if (isMobile) {
|
||||
await checkForUpdateMobile();
|
||||
const global = $globalUpdateAvailable;
|
||||
if (global) {
|
||||
updateAvailable = { version: global.version, body: global.body };
|
||||
updateMessage = { type: 'info', text: `Version ${global.version} is available!` };
|
||||
} else {
|
||||
updateMessage = { type: 'success', text: 'You are on the latest version.' };
|
||||
}
|
||||
} else {
|
||||
updateMessage = { type: 'success', text: 'You are on the latest version.' };
|
||||
const { check: checkUpdate } = await import('@tauri-apps/plugin-updater');
|
||||
const update = await checkUpdate();
|
||||
if (update) {
|
||||
updateObj = update;
|
||||
$globalUpdateObj = update;
|
||||
updateAvailable = { version: update.version, body: update.body, date: update.date };
|
||||
globalUpdateAvailable.set({ version: update.version, body: update.body });
|
||||
updateMessage = { type: 'info', text: `Version ${update.version} is available!` };
|
||||
} else {
|
||||
updateMessage = { type: 'success', text: 'You are on the latest version.' };
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
updateMessage = { type: 'error', text: `Failed to check: ${e}` };
|
||||
@@ -1204,6 +1216,13 @@
|
||||
<p>Update via your AUR helper:</p>
|
||||
<code>yay -Syu helixnotes</code>
|
||||
</div>
|
||||
{:else if $installType === 'android'}
|
||||
<button class="update-install-btn" onclick={() => { openUrl('https://helixnotes.com/#download').catch(() => {}); }}>
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/>
|
||||
</svg>
|
||||
Download from Website
|
||||
</button>
|
||||
{:else}
|
||||
<a class="update-install-btn" href="https://codeberg.org/ArkHost/HelixNotes/releases" target="_blank" rel="noopener">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
|
||||
@@ -59,6 +59,7 @@ export const updateAvailable = writable<{
|
||||
} | null>(null);
|
||||
export const updateObj = writable<any>(null);
|
||||
export const installType = writable<string>("native");
|
||||
export const androidApkUrl = writable<string | null>(null);
|
||||
|
||||
export async function checkForUpdate() {
|
||||
try {
|
||||
@@ -73,6 +74,37 @@ export async function checkForUpdate() {
|
||||
}
|
||||
}
|
||||
|
||||
function isNewerVersion(remote: string, local: string): boolean {
|
||||
const r = remote.split(".").map(Number);
|
||||
const l = local.split(".").map(Number);
|
||||
for (let i = 0; i < Math.max(r.length, l.length); i++) {
|
||||
const rv = r[i] || 0;
|
||||
const lv = l[i] || 0;
|
||||
if (rv > lv) return true;
|
||||
if (rv < lv) return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function checkForUpdateMobile() {
|
||||
try {
|
||||
const { getVersion } = await import("@tauri-apps/api/app");
|
||||
const currentVersion = await getVersion();
|
||||
const res = await fetch("https://helixnotes.com/latest.json");
|
||||
if (!res.ok) return;
|
||||
const data = await res.json();
|
||||
if (data.version && isNewerVersion(data.version, currentVersion)) {
|
||||
updateAvailable.set({ version: data.version, body: data.notes });
|
||||
const android = data.platforms?.["android-universal"];
|
||||
if (android?.url) {
|
||||
androidApkUrl.set(android.url);
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// Silent fail
|
||||
}
|
||||
}
|
||||
|
||||
// Derived
|
||||
export const sortedNotes = derived(
|
||||
[notes, sortMode, viewMode],
|
||||
|
||||
Reference in New Issue
Block a user