Skip to content

Commit

Permalink
debounce ForkModal after login
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasBuchfink committed Mar 15, 2024
1 parent d6d8018 commit c63fe0d
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function EditorHeader() {
)}
</For>
<Show when={user()?.isLoggedIn}>
<div class="absolute right-4 xl:right-[calc((100%_-_1240px)_/_2)] animate-fadeIn">
<div class="absolute h-8 right-4 xl:right-[calc((100%_-_1240px)_/_2)] animate-fadeIn">
<UserDropdown />
</div>
</Show>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,16 @@ export default function Page() {
* is required to use the useEditorState hook.
*/
function TheActualPage() {
const { repo, currentBranch, project, projectList, routeParams, doesInlangConfigExist, tourStep, lixErrors } =
useEditorState()
const {
repo,
currentBranch,
project,
projectList,
routeParams,
doesInlangConfigExist,
tourStep,
lixErrors,
} = useEditorState()
const [localStorage, setLocalStorage] = useLocalStorage()

onMount(() => {
Expand All @@ -65,9 +73,11 @@ function TheActualPage() {
})
})

createEffect(on([project, currentBranch], () => {
setMessageCount(0)
}))
createEffect(
on([project, currentBranch], () => {
setMessageCount(0)
})
)

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,14 @@ function ProjectMenu() {
const shortenProjectName = (projectPath: string) => {
const projectPathArray = projectPath.split("/")
if (projectPathArray.length > 3) {
return "/" + projectPathArray.at(-3) + "/" + projectPathArray.at(-2) + "/" + projectPathArray.at(-1)
return (
"/" +
projectPathArray.at(-3) +
"/" +
projectPathArray.at(-2) +
"/" +
projectPathArray.at(-1)
)
}
return projectPath
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from "#src/services/auth/src/components/SignInDialog.jsx"
import { WarningIcon } from "./Notification/NotificationHint.jsx"
import IconArrowDownward from "~icons/material-symbols/arrow-downward-alt"
import { debounce } from "throttle-debounce"

export const Gitfloat = () => {
const {
Expand Down Expand Up @@ -93,6 +94,8 @@ export const Gitfloat = () => {
createEffect(() => {
if (forkModalOpen()) {
forkDialog?.show()
} else {
forkDialog?.hide()
}
})

Expand Down Expand Up @@ -278,9 +281,14 @@ export const Gitfloat = () => {
if (gitState() === "login" && localChanges() > 2) setSignInModalOpen(true)
})

createEffect(() => {
if (gitState() === "fork" && localChanges() > 2) setForkModalOpen(true)
const debouncedForkModalState = debounce(2000, () => {
if (gitState() === "hasChanges") {
setForkModalOpen(false)
} else if (gitState() === "fork" && localChanges() > 2) {
setForkModalOpen(true)
}
})
createEffect(on([gitState, localChanges], debouncedForkModalState))

// prevent user from leaving the page when changes are not pushed
const beforeUnloadHandler = (event: BeforeUnloadEvent) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ export const ListHeader = () => {
}
prop:target="_blank"
>
<Show when={project()?.installed.messageLintRules().length === 0 || project()?.query.messages.includedMessageIds().length === 0}>
<Show
when={
project()?.installed.messageLintRules().length === 0 ||
project()?.query.messages.includedMessageIds().length === 0
}
>
Install lint rules
</Show>
<Show when={project()?.installed.messageLintRules().length !== 0}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ export function PatternEditor(props: {
})
}
})
))
)
)

const autoSave = () => {
let newMessage
Expand Down

0 comments on commit c63fe0d

Please sign in to comment.