feat(phase4): Quick Edit, Contents API commit flow, editor workspace
- portable UTF-8 base64 helpers (Hermes-safe), used for file round-trips - endpoints: updateFileContents, createFileContents, createPull - hooks: useCommitFile (invalidates repo cache), useCreatePull - FileEdit screen: native monospace editor, dirty/discard, branch picker, commit-to-new-branch, protected-branch handling, post-commit PR creation; stale-SHA 409 surfaces as a conflict message - settings: editor URL template; repo overview 'Open in editor' (no token) - tests: base64 round-trips (accents/emoji), editor URL expansion
This commit is contained in:
1 parent
ddd834b7ac
commit
c9dd49446a
18 files changed
+733
-29
No files matched your search
@@ -20,6 +20,7 @@ import type { RawResponse } from '@/core/api/client';
|
||||
import {
|
||||
createIssue,
|
||||
createIssueComment,
|
||||
createPull,
|
||||
createPullReview,
|
||||
deleteIssueComment,
|
||||
fetchCombinedStatus,
|
||||
@@ -39,6 +40,7 @@ import {
|
||||
updateIssue,
|
||||
updateIssueComment,
|
||||
type CreateIssueInput,
|
||||
type CreatePullInput,
|
||||
type CreateReviewInput,
|
||||
type EditIssueInput,
|
||||
type IssueSearchParams,
|
||||
@@ -437,5 +439,20 @@ export function useCombinedStatus(owner: string, name: string, ref: string | und
|
||||
});
|
||||
}
|
||||
|
||||
/** Create a pull request (used after committing to a new branch). */
|
||||
export function useCreatePull(owner: string, name: string) {
|
||||
const { client, account } = useSession();
|
||||
const queryClient = useQueryClient();
|
||||
const accountId = account?.id ?? '';
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (input: CreatePullInput) => createPull(client!, owner, name, input),
|
||||
onSuccess: () => {
|
||||
void queryClient.invalidateQueries({ queryKey: queryKeys.pullsRoot(accountId, owner, name) });
|
||||
void queryClient.invalidateQueries({ queryKey: queryKeys.issueSearchRoot(accountId) });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export type { Issue, Label, PullRequest };
|
||||
export type { ChangedFile, CombinedStatus, Comment, Milestone, PullReview, User };
|
||||
@@ -3,7 +3,9 @@
|
||||
import {
|
||||
keepPreviousData,
|
||||
useInfiniteQuery,
|
||||
useMutation,
|
||||
useQuery,
|
||||
useQueryClient,
|
||||
type InfiniteData,
|
||||
} from '@tanstack/react-query';
|
||||
|
||||
@@ -17,9 +19,12 @@ import {
|
||||
listCommits,
|
||||
listContents,
|
||||
listTags,
|
||||
updateFileContents,
|
||||
type CommitFileInput,
|
||||
} from '@/core/api/endpoints';
|
||||
import { queryKeys } from '@/core/api/query-keys';
|
||||
import type { Branch, Commit, Tag } from '@/core/api/types';
|
||||
import { decodeBase64Utf8 } from '@/core/utils/base64';
|
||||
import { useSession } from '@/features/accounts/use-session';
|
||||
|
||||
/** Directory listing (or file entry when a path is given). */
|
||||
@@ -159,12 +164,21 @@ export function useCommit(owner: string, name: string, sha: string) {
|
||||
});
|
||||
}
|
||||
|
||||
/** Convenience: decode a base64 contents payload from the API. */
|
||||
/** Convenience: decode a base64 contents payload from the API (UTF-8 safe). */
|
||||
export function decodeBase64(content: string): string {
|
||||
// Gitea returns base64 without line wrapping; atob is available in Hermes.
|
||||
try {
|
||||
return globalThis.atob(content.replace(/\s/g, ''));
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
return decodeBase64Utf8(content);
|
||||
}
|
||||
|
||||
/** Commit a file edit through the Contents API (update path; handles new branches). */
|
||||
export function useCommitFile(owner: string, name: string) {
|
||||
const { client, account } = useSession();
|
||||
const queryClient = useQueryClient();
|
||||
const accountId = account?.id ?? '';
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (input: CommitFileInput) => updateFileContents(client!, owner, name, input),
|
||||
onSuccess: () => {
|
||||
void queryClient.invalidateQueries({ queryKey: queryKeys.repo(accountId, owner, name) });
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,299 @@
|
||||
import { useMemo, useState } from 'react';
|
||||
import { Alert, StyleSheet, Switch, View } from 'react-native';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { Screen } from '@/components/layout/screen';
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { ChipSelect } from '@/components/ui/chip-select';
|
||||
import { Field } from '@/components/ui/field';
|
||||
import { TextArea } from '@/components/ui/text-area';
|
||||
import { ErrorState, LoadingView } from '@/components/ui/state-views';
|
||||
import { apiErrorMessage } from '@/core/api/error-text';
|
||||
import type { Branch, ContentsEntry, Repository } from '@/core/api/types';
|
||||
import { encodeBase64Utf8 } from '@/core/utils/base64';
|
||||
import { flattenPages } from '@/core/utils/infinite';
|
||||
import { useCreatePull } from '@/features/issues/queries';
|
||||
import { useRepository } from '@/features/repositories/queries';
|
||||
import { decodeBase64, useBranches, useCommitFile, useFile } from '@/features/repository/queries';
|
||||
import { useTheme } from '@/theme/theme-provider';
|
||||
import { spacing } from '@/theme/tokens';
|
||||
import type { RepositoryStackParamList } from '@/navigation/types';
|
||||
import type { ScreenProps } from '@/navigation/typing';
|
||||
|
||||
type Props = ScreenProps<RepositoryStackParamList, 'FileEdit'>;
|
||||
|
||||
/**
|
||||
* Quick Edit: edit a file in a monospace editor and commit it through the
|
||||
* Contents API. Supports committing to a new branch (which also handles
|
||||
* protected branches) and optionally opening a pull request afterwards.
|
||||
*/
|
||||
export function FileEditScreen({ navigation, route }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const { owner, name, path, ref } = route.params;
|
||||
|
||||
const fileQuery = useFile(owner, name, path, ref);
|
||||
const refetchFile = fileQuery.refetch;
|
||||
const repoQuery = useRepository(owner, name);
|
||||
const branchesQuery = useBranches(owner, name, '');
|
||||
const branches = flattenPages(branchesQuery.data);
|
||||
const entry = fileQuery.data;
|
||||
|
||||
if (fileQuery.isPending) return <LoadingView />;
|
||||
if (fileQuery.isError) {
|
||||
return (
|
||||
<ErrorState
|
||||
title={t('errors.title')}
|
||||
body={apiErrorMessage(fileQuery.error, t)}
|
||||
retryLabel={t('common.retry')}
|
||||
onRetry={() => void refetchFile()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (!entry) {
|
||||
return (
|
||||
<ErrorState
|
||||
title={t('files.rawUnavailable')}
|
||||
retryLabel={t('common.retry')}
|
||||
onRetry={() => void refetchFile()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<FileEditForm
|
||||
key={entry.sha ?? entry.path}
|
||||
owner={owner}
|
||||
name={name}
|
||||
path={path}
|
||||
initialRef={ref}
|
||||
entry={entry}
|
||||
repo={repoQuery.data}
|
||||
branches={branches}
|
||||
onDone={() => navigation.goBack()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
interface FormProps {
|
||||
owner: string;
|
||||
name: string;
|
||||
path: string;
|
||||
initialRef?: string;
|
||||
entry: ContentsEntry;
|
||||
repo?: Repository;
|
||||
branches: Branch[];
|
||||
onDone: () => void;
|
||||
}
|
||||
|
||||
function FileEditForm({ owner, name, path, initialRef, entry, repo, branches, onDone }: FormProps) {
|
||||
const { t } = useTranslation();
|
||||
const { colors } = useTheme();
|
||||
const commitFile = useCommitFile(owner, name);
|
||||
const createPull = useCreatePull(owner, name);
|
||||
|
||||
// Initialised once per file (the parent remounts this component via `key`).
|
||||
const [original] = useState(() => decodeBase64(entry.content ?? ''));
|
||||
const [draft, setDraft] = useState(original);
|
||||
const [message, setMessage] = useState('');
|
||||
const [branch, setBranch] = useState<string | null>(initialRef ?? null);
|
||||
const [useNewBranch, setUseNewBranch] = useState(false);
|
||||
const [newBranch, setNewBranch] = useState('');
|
||||
const [createPr, setCreatePr] = useState(false);
|
||||
const [prTitle, setPrTitle] = useState('');
|
||||
const [submitted, setSubmitted] = useState(false);
|
||||
|
||||
const targetBranch = branch ?? repo?.default_branch ?? null;
|
||||
const branchOptions = useMemo(
|
||||
() => branches.map((b) => ({ id: b.name, label: b.name })),
|
||||
[branches],
|
||||
);
|
||||
const currentBranch = branches.find((b) => b.name === targetBranch);
|
||||
const branchProtected = Boolean(currentBranch?.protected && currentBranch?.user_can_push !== true);
|
||||
const effectiveNewBranch = useNewBranch || branchProtected;
|
||||
|
||||
const dirty = draft !== original;
|
||||
const canSubmit =
|
||||
dirty &&
|
||||
message.trim().length > 0 &&
|
||||
(effectiveNewBranch ? newBranch.trim().length > 0 : Boolean(targetBranch)) &&
|
||||
!commitFile.isPending;
|
||||
|
||||
const submit = () => {
|
||||
setSubmitted(true);
|
||||
if (!canSubmit || !entry.sha) return;
|
||||
const newBranchName = effectiveNewBranch ? newBranch.trim() : undefined;
|
||||
commitFile.mutate(
|
||||
{
|
||||
path,
|
||||
content: encodeBase64Utf8(draft),
|
||||
message: message.trim(),
|
||||
branch: targetBranch ?? undefined,
|
||||
newBranch: newBranchName,
|
||||
sha: entry.sha,
|
||||
},
|
||||
{
|
||||
onSuccess: async () => {
|
||||
if (createPr && newBranchName && targetBranch && prTitle.trim().length > 0) {
|
||||
try {
|
||||
await createPull.mutateAsync({
|
||||
title: prTitle.trim(),
|
||||
head: newBranchName,
|
||||
base: targetBranch,
|
||||
body: message.trim(),
|
||||
});
|
||||
} catch {
|
||||
// The commit succeeded; a failed PR can be opened from the web UI.
|
||||
}
|
||||
}
|
||||
Alert.alert(t('edit.commitSuccessTitle'), t('edit.commitSuccessBody'));
|
||||
onDone();
|
||||
},
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Screen scroll padded>
|
||||
<View style={styles.toolbar}>
|
||||
<AppText variant="monoSmall" tone="tertiary" numberOfLines={1} style={styles.pathLabel}>
|
||||
{path}
|
||||
</AppText>
|
||||
{dirty ? (
|
||||
<Button
|
||||
label={t('edit.discard')}
|
||||
variant="ghost"
|
||||
size="md"
|
||||
onPress={() => setDraft(original)}
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
<TextArea
|
||||
value={draft}
|
||||
onChangeText={setDraft}
|
||||
minHeight={360}
|
||||
mono
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
testID="file-editor"
|
||||
/>
|
||||
|
||||
{branchProtected ? (
|
||||
<AppText variant="caption" tone="warning">
|
||||
{t('edit.protectedBranch', { branch: targetBranch ?? '' })}
|
||||
</AppText>
|
||||
) : null}
|
||||
|
||||
<Card>
|
||||
<AppText variant="label" tone="secondary" style={styles.sectionLabel}>
|
||||
{t('edit.branch')}
|
||||
</AppText>
|
||||
<ChipSelect
|
||||
options={branchOptions}
|
||||
selectedIds={targetBranch ? [targetBranch] : []}
|
||||
onToggle={(id) => setBranch(id)}
|
||||
emptyLabel={t('edit.loadingBranches')}
|
||||
single
|
||||
/>
|
||||
|
||||
<View style={styles.switchRow}>
|
||||
<AppText variant="bodyMedium" style={styles.switchLabel}>
|
||||
{t('edit.createBranch')}
|
||||
</AppText>
|
||||
<Switch
|
||||
value={effectiveNewBranch}
|
||||
onValueChange={setUseNewBranch}
|
||||
disabled={branchProtected}
|
||||
trackColor={{ true: colors.primary, false: colors.border }}
|
||||
/>
|
||||
</View>
|
||||
{effectiveNewBranch ? (
|
||||
<Field
|
||||
label={t('edit.newBranchName')}
|
||||
value={newBranch}
|
||||
onChangeText={setNewBranch}
|
||||
placeholder={t('edit.newBranchPlaceholder')}
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
mono
|
||||
testID="new-branch"
|
||||
/>
|
||||
) : null}
|
||||
</Card>
|
||||
|
||||
<TextArea
|
||||
label={t('edit.commitMessage')}
|
||||
value={message}
|
||||
onChangeText={setMessage}
|
||||
placeholder={t('edit.commitMessagePlaceholder')}
|
||||
minHeight={80}
|
||||
autoCapitalize="sentences"
|
||||
autoCorrect
|
||||
testID="commit-message"
|
||||
/>
|
||||
|
||||
{effectiveNewBranch ? (
|
||||
<Card>
|
||||
<View style={styles.switchRow}>
|
||||
<AppText variant="bodyMedium" style={styles.switchLabel}>
|
||||
{t('edit.openPullRequest')}
|
||||
</AppText>
|
||||
<Switch
|
||||
value={createPr}
|
||||
onValueChange={setCreatePr}
|
||||
trackColor={{ true: colors.primary, false: colors.border }}
|
||||
/>
|
||||
</View>
|
||||
{createPr ? (
|
||||
<Field
|
||||
label={t('edit.prTitle')}
|
||||
value={prTitle}
|
||||
onChangeText={setPrTitle}
|
||||
placeholder={t('edit.prTitlePlaceholder')}
|
||||
autoCapitalize="sentences"
|
||||
testID="pr-title"
|
||||
/>
|
||||
) : null}
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
{submitted && !canSubmit ? (
|
||||
<AppText variant="caption" tone="error">
|
||||
{t('edit.incomplete')}
|
||||
</AppText>
|
||||
) : null}
|
||||
{commitFile.isError ? (
|
||||
<AppText variant="caption" tone="error">
|
||||
{apiErrorMessage(commitFile.error, t)}
|
||||
</AppText>
|
||||
) : null}
|
||||
|
||||
<Button
|
||||
label={t('edit.commit')}
|
||||
onPress={submit}
|
||||
loading={commitFile.isPending}
|
||||
disabled={!canSubmit}
|
||||
fullWidth
|
||||
testID="commit-submit"
|
||||
/>
|
||||
<View style={styles.spacer} />
|
||||
</Screen>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
toolbar: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
|
||||
pathLabel: { flex: 1 },
|
||||
sectionLabel: { marginBottom: spacing.sm },
|
||||
switchRow: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
gap: spacing.md,
|
||||
marginTop: spacing.md,
|
||||
},
|
||||
switchLabel: { flex: 1 },
|
||||
spacer: { height: spacing.xl },
|
||||
});
|
||||
@@ -5,6 +5,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { Markdown } from '@/components/git/markdown';
|
||||
import { Screen } from '@/components/layout/screen';
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { ErrorState, LoadingView } from '@/components/ui/state-views';
|
||||
import { apiErrorMessage } from '@/core/api/error-text';
|
||||
@@ -30,7 +31,7 @@ function extensionOf(path: string): string {
|
||||
}
|
||||
|
||||
/** Renders a single file: image preview, markdown, or source text. */
|
||||
export function FileViewerScreen({ route }: Props) {
|
||||
export function FileViewerScreen({ navigation, route }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const { colors } = useTheme();
|
||||
const { instance, token } = useSession();
|
||||
@@ -115,6 +116,15 @@ export function FileViewerScreen({ route }: Props) {
|
||||
{t('files.large', { size: formatBytes(entry.size) })}
|
||||
</AppText>
|
||||
) : null}
|
||||
<View style={styles.editRow}>
|
||||
<Button
|
||||
label={t('edit.title')}
|
||||
variant="secondary"
|
||||
size="md"
|
||||
iconLeft="edit"
|
||||
onPress={() => navigation.navigate('FileEdit', { owner, name, path, ref })}
|
||||
/>
|
||||
</View>
|
||||
{MARKDOWN_EXTENSIONS.has(extension) ? (
|
||||
<View style={styles.markdownWrap}>
|
||||
<Markdown content={content} baseUrl={instance?.baseUrl} />
|
||||
@@ -137,6 +147,7 @@ export function FileViewerScreen({ route }: Props) {
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
notice: { paddingHorizontal: spacing.lg, paddingVertical: spacing.sm },
|
||||
editRow: { paddingHorizontal: spacing.lg, paddingBottom: spacing.sm },
|
||||
markdownWrap: { paddingHorizontal: spacing.lg },
|
||||
imageCard: { overflow: 'hidden', minHeight: 200 },
|
||||
image: { width: '100%', height: 320 },
|
||||
|
||||
@@ -13,9 +13,11 @@ import { LabelChip } from '@/components/ui/label-chip';
|
||||
import { ListItem } from '@/components/ui/list-item';
|
||||
import { ErrorState, LoadingView } from '@/components/ui/state-views';
|
||||
import { apiErrorMessage } from '@/core/api/error-text';
|
||||
import { buildEditorUrl } from '@/core/utils/editor-url';
|
||||
import { useRepository, useRepositoryLanguages } from '@/features/repositories/queries';
|
||||
import { useReadme } from '@/features/repository/queries';
|
||||
import { decodeBase64, useReadme } from '@/features/repository/queries';
|
||||
import { useSession } from '@/features/accounts/use-session';
|
||||
import { useSettingsStore } from '@/features/settings/settings-store';
|
||||
import { useTheme } from '@/theme/theme-provider';
|
||||
import { radius, spacing } from '@/theme/tokens';
|
||||
import type { RepositoryStackParamList } from '@/navigation/types';
|
||||
@@ -28,6 +30,7 @@ export function RepoOverviewScreen({ navigation, route }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const { colors } = useTheme();
|
||||
const { instance } = useSession();
|
||||
const editorUrlTemplate = useSettingsStore((s) => s.editorUrlTemplate);
|
||||
const { owner, name, ref } = route.params;
|
||||
|
||||
const repoQuery = useRepository(owner, name);
|
||||
@@ -107,6 +110,23 @@ export function RepoOverviewScreen({ navigation, route }: Props) {
|
||||
onPress={() => void Linking.openURL(repo.html_url as string).catch(() => undefined)}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{editorUrlTemplate ? (
|
||||
<Button
|
||||
label={t('repo.openInEditor')}
|
||||
variant="secondary"
|
||||
iconLeft="externalLink"
|
||||
onPress={() => {
|
||||
const url = buildEditorUrl(editorUrlTemplate, {
|
||||
owner,
|
||||
name,
|
||||
cloneUrl: repo.clone_url,
|
||||
htmlUrl: repo.html_url,
|
||||
});
|
||||
void Linking.openURL(url).catch(() => undefined);
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
{/* Quick navigation */}
|
||||
@@ -265,11 +285,7 @@ function languageColor(index: number, fallback: string): string {
|
||||
|
||||
function decodeReadme(content: string | undefined): string {
|
||||
if (!content) return '';
|
||||
try {
|
||||
return globalThis.atob(content.replace(/\s/g, ''));
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
return decodeBase64(content);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
|
||||
@@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { Screen } from '@/components/layout/screen';
|
||||
import { AppText } from '@/components/ui/app-text';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import { Field } from '@/components/ui/field';
|
||||
import { ListItem } from '@/components/ui/list-item';
|
||||
import { SegmentedControl } from '@/components/ui/segmented';
|
||||
import { queryClient } from '@/core/api/query-client';
|
||||
@@ -39,6 +40,8 @@ export function SettingsScreen(_props: Props) {
|
||||
const setLanguage = useSettingsStore((s) => s.setLanguage);
|
||||
const setBiometricsEnabled = useSettingsStore((s) => s.setBiometricsEnabled);
|
||||
const setNotificationPollSeconds = useSettingsStore((s) => s.setNotificationPollSeconds);
|
||||
const editorUrlTemplate = useSettingsStore((s) => s.editorUrlTemplate);
|
||||
const setEditorUrlTemplate = useSettingsStore((s) => s.setEditorUrlTemplate);
|
||||
|
||||
const [support, setSupport] = useState<BiometricSupport | null>(null);
|
||||
|
||||
@@ -146,6 +149,22 @@ export function SettingsScreen(_props: Props) {
|
||||
</Card>
|
||||
</Section>
|
||||
|
||||
{/* Editor integration */}
|
||||
<Section title={t('settings.editor')}>
|
||||
<Card style={styles.card}>
|
||||
<Field
|
||||
label={t('settings.editorUrlTemplate')}
|
||||
value={editorUrlTemplate}
|
||||
onChangeText={setEditorUrlTemplate}
|
||||
placeholder={t('settings.editorUrlPlaceholder')}
|
||||
helper={t('settings.editorUrlHelp')}
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
mono
|
||||
/>
|
||||
</Card>
|
||||
</Section>
|
||||
|
||||
{/* Data */}
|
||||
<Section title={t('settings.data')}>
|
||||
<Card padded={false} variant="flat">
|
||||
|
||||
@@ -20,10 +20,17 @@ export interface SettingsState {
|
||||
biometricsEnabled: boolean;
|
||||
/** Background polling interval for the notifications inbox, in seconds. 0 = only manual/foreground refresh. */
|
||||
notificationPollSeconds: number;
|
||||
/**
|
||||
* Optional editor/IDE URL template for the "Open in editor" action.
|
||||
* Placeholders: {owner} {repo} {path} {cloneUrl}. Empty hides the action.
|
||||
* Opened in the system browser/app only — the API token is never appended.
|
||||
*/
|
||||
editorUrlTemplate: string;
|
||||
setThemePreference: (preference: ThemePreference) => void;
|
||||
setLanguage: (language: LanguagePreference) => void;
|
||||
setBiometricsEnabled: (enabled: boolean) => void;
|
||||
setNotificationPollSeconds: (seconds: number) => void;
|
||||
setEditorUrlTemplate: (template: string) => void;
|
||||
}
|
||||
|
||||
export const useSettingsStore = create<SettingsState>()(
|
||||
@@ -33,10 +40,12 @@ export const useSettingsStore = create<SettingsState>()(
|
||||
language: 'system',
|
||||
biometricsEnabled: false,
|
||||
notificationPollSeconds: 60,
|
||||
editorUrlTemplate: '',
|
||||
setThemePreference: (themePreference) => set({ themePreference }),
|
||||
setLanguage: (language) => set({ language }),
|
||||
setBiometricsEnabled: (biometricsEnabled) => set({ biometricsEnabled }),
|
||||
setNotificationPollSeconds: (notificationPollSeconds) => set({ notificationPollSeconds }),
|
||||
setEditorUrlTemplate: (editorUrlTemplate) => set({ editorUrlTemplate }),
|
||||
}),
|
||||
{
|
||||
name: 'gitea-native:settings:v1',
|
||||
@@ -46,6 +55,7 @@ export const useSettingsStore = create<SettingsState>()(
|
||||
language: state.language,
|
||||
biometricsEnabled: state.biometricsEnabled,
|
||||
notificationPollSeconds: state.notificationPollSeconds,
|
||||
editorUrlTemplate: state.editorUrlTemplate,
|
||||
}),
|
||||
},
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user