forked from hinterland/hearth
feat: vendor gitea 1.16.2
This commit is contained in:
@@ -6,16 +6,20 @@ import {registerGlobalEventFunc} from '../modules/observer.ts';
|
||||
|
||||
const {appSubUrl} = window.config;
|
||||
|
||||
function isUserSignedIn() {
|
||||
return Boolean(document.querySelector('#navbar .user-menu'));
|
||||
}
|
||||
|
||||
async function toggleSidebar(btn: HTMLElement) {
|
||||
const elToggleShow = document.querySelector('.repo-view-file-tree-toggle-show');
|
||||
const elFileTreeContainer = document.querySelector('.repo-view-file-tree-container');
|
||||
const elToggleShow = document.querySelector('.repo-view-file-tree-toggle[data-toggle-action="show"]')!;
|
||||
const elFileTreeContainer = document.querySelector('.repo-view-file-tree-container')!;
|
||||
const shouldShow = btn.getAttribute('data-toggle-action') === 'show';
|
||||
toggleElem(elFileTreeContainer, shouldShow);
|
||||
toggleElem(elToggleShow, !shouldShow);
|
||||
|
||||
// FIXME: need to remove "full height" style from parent element
|
||||
|
||||
if (!elFileTreeContainer.hasAttribute('data-user-is-signed-in')) return;
|
||||
if (!isUserSignedIn()) return;
|
||||
await POST(`${appSubUrl}/user/settings/update_preferences`, {
|
||||
data: {codeViewShowFileTree: shouldShow},
|
||||
});
|
||||
@@ -28,7 +32,7 @@ export async function initRepoViewFileTree() {
|
||||
|
||||
registerGlobalEventFunc('click', 'onRepoViewFileTreeToggle', toggleSidebar);
|
||||
|
||||
const fileTree = sidebar.querySelector('#view-file-tree');
|
||||
const fileTree = sidebar.querySelector('#view-file-tree')!;
|
||||
createApp(ViewFileTree, {
|
||||
repoLink: fileTree.getAttribute('data-repo-link'),
|
||||
treePath: fileTree.getAttribute('data-tree-path'),
|
||||
|
||||
Reference in New Issue
Block a user