Skip to content

Commit

Permalink
Merge branch 'joplin:dev' into exclude_tag
Browse files Browse the repository at this point in the history
  • Loading branch information
mhelleboid authored Jul 29, 2023
2 parents 15b8d0e + 0e4098d commit 3eff8c7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export interface NewNoteAction {
};
}

export interface CloseAction {
type: "close";
}

export type Action =
| MoveNoteAction
| LoadAction
Expand All @@ -66,4 +70,5 @@ export type Action =
| OpenNoteAction
| AddColumnAction
| DeleteColAction
| NewNoteAction;
| NewNoteAction
| CloseAction;
11 changes: 9 additions & 2 deletions src/gui/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { render } from "react-dom";
import styled from "styled-components";
import { IoMdSettings, IoMdAdd } from "react-icons/io";
import { IoMdSettings, IoMdAdd, IoMdClose } from "react-icons/io";

import { capitalize } from "../utils";
import { DispatchFn, useRemoteBoard } from "./hooks";
Expand Down Expand Up @@ -59,6 +59,13 @@ function App() {
const cont = board ? (
<Container>
<Header>
<IconCont
onClick={() => {
dispatch({ type: "close" })
}}
>
<IoMdClose size="20px"/>
</IconCont>
{board.name}
<IconCont
onClick={() =>
Expand Down Expand Up @@ -147,7 +154,7 @@ const IconCont = styled("div")({
alignItems: "center",
borderRadius: "5px",

"&:first-child": {
"&:nth-child(2)": {
marginLeft: "auto",
},
"&:hover": {
Expand Down
20 changes: 15 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,9 @@ async function reloadConfig(noteId: string) {
const valid = ymlConfig !== null && (await board.loadConfig(ymlConfig));
if (valid) {
openBoard = board;
} else {
openBoard = undefined;
hideBoard();
}
// Do nothing if it is not valid.
// User could close the kanban by using the "x" button
}

// EVENT HANDLERS
Expand Down Expand Up @@ -220,6 +219,10 @@ async function handleKanbanMessage(msg: Action) {
case "load":
break;

case "close":
openBoard = undefined;
return hideBoard();

// Propagete action to the active board
default: {
if (!openBoard.isValid) break;
Expand Down Expand Up @@ -273,12 +276,19 @@ async function handleKanbanMessage(msg: Action) {
* the domain of the current board.
*/
async function handleNewlyOpenedNote(newNoteId: string) {

if (openBoard) {
if (openBoard.configNoteId === newNoteId) return;
if (await openBoard.isNoteIdOnBoard(newNoteId)) return;
else {
hideBoard();
openBoard = undefined;
const originalOpenBoard = openBoard;
await reloadConfig(newNoteId);
if (openBoard && openBoard.isValid && originalOpenBoard!==openBoard) {
// If user opened a new board, close and open again to refresh the content
hideBoard()
showBoard();
}
return;
}
}

Expand Down

0 comments on commit 3eff8c7

Please sign in to comment.