getConfig()\r
.then((data) => {\r
globalStore.authType = data.authType;\r
+ globalStore.hideRecentlyModified = data.hideRecentlyModified;\r
})\r
.catch((error) => {\r
apiErrorHandler(error, toast);\r
+import * as constants from "./constants.js";
+
import { defineStore } from "pinia";
import { ref } from "vue";
export const useGlobalStore = defineStore("global", () => {
- const authType = ref("authType");
+ const authType = ref(constants.authTypes.password);
+ const hideRecentlyModified = ref(true);
- return { authType };
+ return { authType, hideRecentlyModified };
});
import { useToast } from "primevue/usetoast";
import { ref, watch } from "vue";
import { useRouter } from "vue-router";
-import * as constants from "../constants";
-import { getTags, apiErrorHandler } from "../api.js";
+import { apiErrorHandler, getTags } from "../api.js";
import IconLabel from "../components/IconLabel.vue";
+import * as constants from "../constants.js";
import { getToastOptions } from "../helpers.js";
const props = defineProps({
<script setup>
import { useToast } from "primevue/usetoast";
-import { onMounted, ref } from "vue";
+import { onMounted, ref, watch } from "vue";
import { RouterLink } from "vue-router";
import { mdiPencil } from "@mdi/js";
import CustomButton from "../components/CustomButton.vue";
import LoadingIndicator from "../components/LoadingIndicator.vue";
import Logo from "../components/Logo.vue";
+import { useGlobalStore } from "../globalStore.js";
import SearchInput from "../partials/SearchInput.vue";
+const globalStore = useGlobalStore();
const loadingIndicator = ref();
const noNotesMessage =
"Click the 'New Note' button at the top of the page to get started.";
const toast = useToast();
function init() {
+ if (globalStore.hideRecentlyModified) {
+ return;
+ }
getNotes("*", "lastModified", "desc", 5)
.then((data) => {
notes.value = data;
});
}
+// Watch to allow for delayed config load.
+watch(() => globalStore.hideRecentlyModified, init);
onMounted(init);
</script>
def __init__(self) -> None:\r
logger.debug("Loading global config...")\r
self.auth_type: AuthType = self._load_auth_type()\r
+ self.hide_recently_modified: bool = self._load_hide_recently_modified()\r
\r
def load_auth(self):\r
if self.auth_type in (AuthType.NONE, AuthType.READ_ONLY):\r
sys.exit(1)\r
return auth_type\r
\r
+ def _load_hide_recently_modified(self):\r
+ key = "FLATNOTES_HIDE_RECENTLY_MODIFIED"\r
+ return get_env(key, mandatory=False, default=False, cast_bool=True)\r
+\r
\r
class AuthType(str, Enum):\r
NONE = "none"\r
\r
class GlobalConfigResponseModel(CustomBaseModel):\r
auth_type: AuthType\r
+ hide_recently_modified: bool\r
return value.strip()\r
\r
\r
-def get_env(key, mandatory=False, default=None, cast_int=False):\r
+def get_env(\r
+ key, mandatory=False, default=None, cast_int=False, cast_bool=False\r
+):\r
"""Get an environment variable. If `mandatory` is True and environment\r
variable isn't set, exit the program"""\r
value = os.environ.get(key)\r
except (TypeError, ValueError):\r
logger.error(f"Invalid value '{value}' for {key}.")\r
sys.exit(1)\r
+ if cast_bool:\r
+ value = value.lower()\r
+ if value == "true":\r
+ value = True\r
+ elif value == "false":\r
+ value = False\r
+ else:\r
+ logger.error(f"Invalid value '{value}' for {key}.")\r
+ sys.exit(1)\r
return value\r
\r
\r
@app.get("/api/config", response_model=GlobalConfigResponseModel)\r
def get_config():\r
"""Retrieve server-side config required for the UI."""\r
- return GlobalConfigResponseModel(auth_type=global_config.auth_type)\r
+ return GlobalConfigResponseModel(\r
+ auth_type=global_config.auth_type,\r
+ hide_recently_modified=global_config.hide_recently_modified,\r
+ )\r
\r
\r
# endregion\r