Skip to content

Commit

Permalink
chore: Release v0.2.1-beta.0 (#1599)
Browse files Browse the repository at this point in the history
  • Loading branch information
Innei authored Nov 14, 2024
2 parents cafeb07 + 9b35074 commit 17e1cf8
Show file tree
Hide file tree
Showing 143 changed files with 1,975 additions and 1,444 deletions.
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ body:
label: Describe the bug
description: A clear and concise description of what the bug is. If you intend to submit a PR for this issue, tell us in the description. Thanks!
placeholder: Bug description

validations:
required: true
- type: textarea
Expand Down Expand Up @@ -46,6 +47,8 @@ body:
required: true
- label: Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
required: true
- label: This issue is valid
required: true
- type: checkboxes
id: contributions
attributes:
Expand Down
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ body:
options:
- label: Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
required: true
- label: This issue is valid
required: true
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/i18n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ body:
options:
- label: I agree to follow this project's Code of Conduct
required: true
- label: This issue is valid
required: true
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/typo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ body:
id: context
attributes:
label: Additional context
- type: checkboxes
id: checkboxes
attributes:
label: Validations
description: Before submitting the issue, please make sure you do the following
options:
- label: This issue is valid
required: true
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,22 @@ jobs:
with:
name: ${{ matrix.os }}
path: |
out/make/**/*.dmg
out/make/**/*.zip
out/make/**/*.exe
out/make/**/*.AppImage
out/make/**/*.yml
retention-days: 90

- name: Upload file (dmg)
- name: Upload file (arm64.dmg)
uses: actions/upload-artifact@v4
if: matrix.os == 'macos-latest'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: macos-dmg
name: macos-arm64-dmg
path: |
out/make/**/*.dmg
out/make/**/*arm64.dmg
retention-days: 90

- name: Generate artifact attestation
Expand Down
53 changes: 52 additions & 1 deletion CHANGELOG.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion apps/main/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { app, nativeTheme, Notification, shell } from "electron"
import contextMenu from "electron-context-menu"

import { getIconPath } from "./helper"
import { clearCacheCronJob } from "./lib/cleaner"
import { checkAndCleanCodeCache, clearCacheCronJob } from "./lib/cleaner"
import { t } from "./lib/i18n"
import { store } from "./lib/store"
import { updateNotificationsToken } from "./lib/user"
Expand Down Expand Up @@ -61,6 +61,7 @@ export const initializeAppStage1 = () => {

registerPushNotifications()
clearCacheCronJob()
checkAndCleanCodeCache()
}

let contextMenuDisposer: () => void
Expand Down
42 changes: 36 additions & 6 deletions apps/main/src/lib/cleaner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ export const getCacheSize = async () => {
const cachePath = path.join(app.getPath("userData"), "cache")

// Size is in bytes
const sizeInBytes = await fastFolderSizeAsync(cachePath)
const sizeInBytes = await fastFolderSizeAsync(cachePath).catch((error) => {
logger.error(error)
})
return sizeInBytes || 0
}

Expand All @@ -90,6 +92,7 @@ const getCachedFilesRecursive = async (dir: string, result: string[] = []) => {
}

let timer: any = null

export const clearCacheCronJob = () => {
if (timer) {
timer = clearInterval(timer)
Expand Down Expand Up @@ -119,11 +122,16 @@ export const clearCacheCronJob = () => {

let cleanedSize = 0
for (const file of files) {
const fileSize = statSync(file).size
cleanedSize += fileSize
if (cleanedSize >= shouldCleanSize) {
logger.info(`Cleaned ${cleanedSize} bytes cache`)
break
try {
const fileSize = statSync(file).size
await fsp.rm(file, { force: true })
cleanedSize += fileSize
if (cleanedSize >= shouldCleanSize) {
logger.info(`Cleaned ${cleanedSize} bytes cache`)
break
}
} catch (error) {
logger.error(`Failed to delete cache file ${file}:`, error)
}
}
}
Expand All @@ -136,3 +144,25 @@ export const clearCacheCronJob = () => {
timer = clearInterval(timer)
}
}

export const checkAndCleanCodeCache = async () => {
const cachePath = path.join(app.getPath("userData"), "Code Cache")

const size = await fastFolderSizeAsync(cachePath).catch((error) => {
logger.error(error)
})

if (!size) return

const threshold = 1024 * 1024 * 100 // 100MB
if (size > threshold) {
await fsp
.rm(cachePath, { force: true, recursive: true })
.then(() => {
logger.info(`Cleaned ${size} bytes code cache`)
})
.catch((error) => {
logger.error(`clean code cache failed: ${error.message}`)
})
}
}
27 changes: 24 additions & 3 deletions apps/main/src/tipc/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import path from "node:path"
import { getRendererHandlers } from "@egoist/tipc/main"
import { callWindowExpose } from "@follow/shared/bridge"
import type { BrowserWindow } from "electron"
import { app, clipboard, dialog, screen } from "electron"
import { app, clipboard, dialog, screen, shell } from "electron"

import { registerMenuAndContextMenu } from "~/init"
import { clearAllData, getCacheSize } from "~/lib/cleaner"
Expand Down Expand Up @@ -275,13 +275,34 @@ ${content}
getCacheSize: t.procedure.action(async () => {
return getCacheSize()
}),
openCacheFolder: t.procedure.action(async () => {
const dir = path.join(app.getPath("userData"), "cache")
shell.openPath(dir)
}),
getCacheLimit: t.procedure.action(async () => {
return store.get(StoreKey.CacheSizeLimit)
}),

clearCache: t.procedure.action(async () => {
const cachePath = path.join(app.getPath("userData"), "cache")
await fsp.rm(cachePath, { recursive: true, force: true })
const cachePath = path.join(app.getPath("userData"), "cache", "Cache_Data")
if (process.platform === "win32") {
// Request elevation on Windows

try {
// Create a bat file to delete cache with elevated privileges
const batPath = path.join(app.getPath("temp"), "clear_cache.bat")
await fsp.writeFile(batPath, `@echo off\nrd /s /q "${cachePath}"\ndel "%~f0"`, "utf-8")

// Execute the bat file with admin privileges
await shell.openPath(batPath)
return
} catch (err) {
logger.error("Failed to clear cache with elevation", { error: err })
}
}
await fsp.rm(cachePath, { recursive: true, force: true }).catch(() => {
logger.error("Failed to clear cache")
})
}),

limitCacheSize: t.procedure.input<number>().action(async ({ input }) => {
Expand Down
21 changes: 21 additions & 0 deletions apps/renderer/__debug_proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,24 @@ fetch(`${host}`)
document.body.append($script)
})
})

const injectScript = (apiUrl: string) => {
const upstreamOrigin = window.location.origin
const template = `function injectEnv(env2) {
for (const key in env2) {
if (env2[key] === void 0) continue;
globalThis["__followEnv"] ??= {};
globalThis["__followEnv"][key] = env2[key];
}
}
injectEnv({"VITE_API_URL":"${apiUrl}","VITE_EXTERNAL_API_URL":"${apiUrl}","VITE_WEB_URL":"${upstreamOrigin}"})`
const $script = document.createElement("script")
$script.innerHTML = template
document.head.prepend($script)
}

const apiMap = {
"https://dev.follow.is": "https://api.dev.follow.is",
"https://app.follow.is": "https://api.follow.is",
}
injectScript(apiMap[window.location.origin])
4 changes: 2 additions & 2 deletions apps/renderer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<title>Follow</title>
<!-- Manifest -->
<link rel="manifest" href="/manifest.json" />

<meta property="og:type" content="website" />
<meta property="og:title" content="Follow" />
<meta property="og:url" content="https://app.follow.is" />
Expand All @@ -24,6 +23,7 @@
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Follow" />
<meta name="twitter:image" content="https://app.follow.is/og-image.png" />
<!-- Check Browser Script Inject -->

<script>
function setTheme() {
Expand Down Expand Up @@ -63,7 +63,7 @@
<body>
<div id="root"></div>

<div id="app-skeleton">
<div id="app-skeleton" class="drag-region">
<!-- Skeleton -->
<style>
html,
Expand Down
1 change: 1 addition & 0 deletions apps/renderer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"react-selecto": "^1.26.3",
"react-shadow": "20.5.0",
"react-virtuoso": "4.12.0",
"react-zoom-pan-pinch": "^3.6.1",
"rehype-infer-description-meta": "2.0.0",
"rehype-parse": "9.0.1",
"rehype-sanitize": "6.0.0",
Expand Down
3 changes: 2 additions & 1 deletion apps/renderer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useAppIsReady } from "./atoms/app"
import { useUISettingKey } from "./atoms/settings/ui"
import { navigateEntry } from "./hooks/biz/useNavigateEntry"
import { applyAfterReadyCallbacks } from "./initialize/queue"
import { removeAppSkeleton } from "./lib/app"
import { appLog } from "./lib/log"
import { Titlebar } from "./modules/app/Titlebar"
import { RootProviders } from "./providers/root-providers"
Expand Down Expand Up @@ -53,7 +54,7 @@ const AppLayer = () => {
const appIsReady = useAppIsReady()

useEffect(() => {
document.querySelector("#app-skeleton")?.remove()
removeAppSkeleton()

const doneTime = Math.trunc(performance.now())
window.analytics?.capture("ui_render_init", {
Expand Down
3 changes: 3 additions & 0 deletions apps/renderer/src/atoms/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ import { createAtomHooks } from "~/lib/jotai"

export const [, , useMainContainerElement, , getMainContainerElement, setMainContainerElement] =
createAtomHooks(atom<HTMLElement | null>(null))

export const [, , useRootContainerElement, , getRootContainerElement, setRootContainerElement] =
createAtomHooks(atom<HTMLElement | null>(null))
2 changes: 1 addition & 1 deletion apps/renderer/src/atoms/settings/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const createDefaultSettings = (): GeneralSettings => ({
reduceRefetch: true,

// view
unreadOnly: false,
unreadOnly: true,
// mark unread
scrollMarkUnread: true,
hoverMarkUnread: true,
Expand Down
3 changes: 2 additions & 1 deletion apps/renderer/src/components/common/ErrorElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useEffect, useRef } from "react"
import { isRouteErrorResponse, useNavigate, useRouteError } from "react-router-dom"
import { toast } from "sonner"

import { removeAppSkeleton } from "~/lib/app"
import { attachOpenInEditor } from "~/lib/dev"
import { getNewIssueUrl } from "~/lib/issues"
import { clearLocalPersistStoreData } from "~/store/utils/clear"
Expand All @@ -21,7 +22,7 @@ export function ErrorElement() {
const stack = error instanceof Error ? error.stack : null

useEffect(() => {
document.querySelector("#app-skeleton")?.remove()
removeAppSkeleton()
}, [])

useEffect(() => {
Expand Down
5 changes: 5 additions & 0 deletions apps/renderer/src/components/common/NotFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { Location } from "react-router-dom"
import { useLocation, useNavigate } from "react-router-dom"

import { isElectronBuild } from "~/constants"
import { removeAppSkeleton } from "~/lib/app"

import { PoweredByFooter } from "./PoweredByFooter"

Expand Down Expand Up @@ -37,6 +38,10 @@ export const NotFound = () => {
),
)
}, [location])

useEffect(() => {
removeAppSkeleton()
}, [])
const navigate = useNavigate()
return (
<div className="prose center m-auto size-full flex-col dark:prose-invert">
Expand Down
Loading

0 comments on commit 17e1cf8

Please sign in to comment.