Skip to content

Commit

Permalink
Merge pull request #227 from aroskanalen/feature/369-theme-changes
Browse files Browse the repository at this point in the history
#369: Changed how theme logo is loaded
  • Loading branch information
tuj authored Feb 23, 2024
2 parents 1d5ff78 + 32f847f commit a53e3d2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
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

0 comments on commit a53e3d2

Please sign in to comment.