Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#369: Changed how theme logo is loaded #227

Merged
merged 3 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

- [#227](https://github.com/os2display/display-admin-client/pull/227)
- Changed how theme is loaded following change to API
- Added fetch all to avoid removing slides when saving playlist and all slides have not been fetched.
- [#225](https://github.com/os2display/display-admin-client/pull/225)
- Fixed caching issues when adding/removing playlists from slide.
Expand Down
2 changes: 1 addition & 1 deletion src/components/themes/theme-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ ThemeForm.defaultProps = {
ThemeForm.propTypes = {
theme: PropTypes.shape({
cssStyles: PropTypes.string,
logo: PropTypes.string,
logo: PropTypes.shape({}),
description: PropTypes.string,
title: PropTypes.string,
}),
Expand Down
24 changes: 2 additions & 22 deletions src/components/themes/theme-manager.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import { React, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import PropTypes from "prop-types";
import { useNavigate } from "react-router-dom";
import { useDispatch } from "react-redux";
import ThemeForm from "./theme-form";
import idFromUrl from "../util/helpers/id-from-url";
import {
api,
usePostV1ThemesMutation,
usePutV1ThemesByIdMutation,
usePostMediaCollectionMutation,
Expand Down Expand Up @@ -37,7 +34,6 @@ function ThemeManager({
// Hooks
const { t } = useTranslation("common", { keyPrefix: "theme-manager" });
const navigate = useNavigate();
const dispatch = useDispatch();

// State
const [headerText] = useState(
Expand Down Expand Up @@ -76,23 +72,7 @@ function ThemeManager({

/** Set loaded data into form state. */
useEffect(() => {
if (initialState) {
if (initialState.logo) {
dispatch(
api.endpoints.getV1MediaById.initiate({
id: idFromUrl(initialState.logo),
})
)
.then(({ data }) => {
setFormStateObject({ ...initialState, logo: data });
})
.catch((err) => {
displayError(t("error-messages.save-media-error"), err);
});
} else {
setFormStateObject(initialState);
}
}
setFormStateObject(initialState);
}, [initialState]);

/**
Expand Down Expand Up @@ -242,7 +222,7 @@ ThemeManager.defaultProps = {

ThemeManager.propTypes = {
initialState: PropTypes.shape({
logo: PropTypes.string,
logo: PropTypes.shape({}),
}),
saveMethod: PropTypes.string.isRequired,
id: PropTypes.string,
Expand Down
Loading