mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-26 07:22:34 +00:00
Feature/year month day mode in gallery (#6725)
* add date mode in gallery * replace localStorage with sfMetadataContext.localStorage, update date tag render * update string to support translation, fix images shift up when date tag was hidden * update gallery ui * fix conflicts, update gallery-group-by-setter * fix conflict
This commit is contained in:
@@ -0,0 +1,56 @@
|
|||||||
|
.metadata-gallery-group-by-setter {
|
||||||
|
width: 272px;
|
||||||
|
height: 36px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
border: 1px solid #e2e2e2;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metadata-gallery-group-by-setter .metadata-gallery-group-by-button {
|
||||||
|
width: 66px;
|
||||||
|
height: 28px;
|
||||||
|
background-color: #fff;
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metadata-gallery-group-by-setter .metadata-gallery-group-by-button:hover {
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metadata-gallery-group-by-setter .metadata-gallery-group-by-button.active {
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metadata-gallery-group-by-setter .metadata-gallery-group-by-button span {
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metadata-gallery-group-by-button:not(:first-child)::before {
|
||||||
|
content: '';
|
||||||
|
width: 1px;
|
||||||
|
height: 22px;
|
||||||
|
background-color: #e2e2e2;
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
transition: opacity 0.3s;
|
||||||
|
left: -1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metadata-gallery-group-by-button:hover::before,
|
||||||
|
.metadata-gallery-group-by-button.active::before,
|
||||||
|
.metadata-gallery-group-by-button:hover + .metadata-gallery-group-by-button::before,
|
||||||
|
.metadata-gallery-group-by-button.active + .metadata-gallery-group-by-button::before {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
@@ -0,0 +1,51 @@
|
|||||||
|
import React, { useState, useCallback, useEffect } from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import classnames from 'classnames';
|
||||||
|
import { EVENT_BUS_TYPE, GALLERY_DATE_MODE } from '../../../constants';
|
||||||
|
import { gettext } from '../../../../utils/constants';
|
||||||
|
|
||||||
|
import './index.css';
|
||||||
|
|
||||||
|
const DATE_MODE_MAP = {
|
||||||
|
[GALLERY_DATE_MODE.YEAR]: gettext('Year'),
|
||||||
|
[GALLERY_DATE_MODE.MONTH]: gettext('Month'),
|
||||||
|
[GALLERY_DATE_MODE.DAY]: gettext('Day'),
|
||||||
|
[GALLERY_DATE_MODE.ALL]: gettext('All')
|
||||||
|
};
|
||||||
|
|
||||||
|
const GalleryGroupBySetter = ({ view }) => {
|
||||||
|
const [currentMode, setCurrentMode] = useState(GALLERY_DATE_MODE.DAY);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const savedValue = window.sfMetadataContext.localStorage.getItem('gallery-group-by', GALLERY_DATE_MODE.DAY);
|
||||||
|
setCurrentMode(savedValue || GALLERY_DATE_MODE.DAY);
|
||||||
|
}, [view?._id]);
|
||||||
|
|
||||||
|
const handleGroupByChange = useCallback((newMode) => {
|
||||||
|
setCurrentMode(newMode);
|
||||||
|
window.sfMetadataContext.localStorage.setItem('gallery-group-by', newMode);
|
||||||
|
window.sfMetadataContext.eventBus.dispatch(EVENT_BUS_TYPE.SWITCH_GALLERY_GROUP_BY, newMode);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="metadata-gallery-group-by-setter">
|
||||||
|
{Object.entries(DATE_MODE_MAP).map(([dateMode, label]) => (
|
||||||
|
<button
|
||||||
|
key={dateMode}
|
||||||
|
className={classnames('metadata-gallery-group-by-button', { active: currentMode === dateMode })}
|
||||||
|
onClick={() => handleGroupByChange(dateMode)}
|
||||||
|
>
|
||||||
|
<span>{label}</span>
|
||||||
|
</button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
GalleryGroupBySetter.propTypes = {
|
||||||
|
view: PropTypes.shape({
|
||||||
|
_id: PropTypes.string
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
export default GalleryGroupBySetter;
|
@@ -3,14 +3,15 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 4px;
|
gap: 2px;
|
||||||
|
margin-left: 8px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.metadata-slider {
|
.metadata-slider {
|
||||||
-webkit-appearance: none;
|
-webkit-appearance: none;
|
||||||
appearance: none;
|
appearance: none;
|
||||||
width: 100%;
|
width: 60px;
|
||||||
height: 4px;
|
height: 4px;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
background: #ccc;
|
background: #ccc;
|
@@ -1,12 +1,12 @@
|
|||||||
import React, { useState, useCallback, useEffect } from 'react';
|
import React, { useState, useCallback, useEffect } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Button, Input } from 'reactstrap';
|
import { Button, Input } from 'reactstrap';
|
||||||
import Icon from '../../../components/icon';
|
import Icon from '../../../../components/icon';
|
||||||
import { EVENT_BUS_TYPE } from '../../constants';
|
import { EVENT_BUS_TYPE } from '../../../constants';
|
||||||
|
|
||||||
import './slider-setter.css';
|
import './index.css';
|
||||||
|
|
||||||
const SliderSetter = ({ view }) => {
|
const GallerySliderSetter = ({ view }) => {
|
||||||
const [sliderValue, setSliderValue] = useState(() => {
|
const [sliderValue, setSliderValue] = useState(() => {
|
||||||
const savedValue = window.sfMetadataContext.localStorage.getItem('zoom-gear', 0);
|
const savedValue = window.sfMetadataContext.localStorage.getItem('zoom-gear', 0);
|
||||||
return savedValue || 0;
|
return savedValue || 0;
|
||||||
@@ -56,8 +56,8 @@ const SliderSetter = ({ view }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
SliderSetter.propTypes = {
|
GallerySliderSetter.propTypes = {
|
||||||
view: PropTypes.object,
|
view: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SliderSetter;
|
export default GallerySliderSetter;
|
@@ -1,4 +1,5 @@
|
|||||||
import SliderSetter from './slider-setter';
|
import GalleryGroupBySetter from './gallery-group-by-setter/index';
|
||||||
|
import GallerySliderSetter from './gallery-slider-setter/index';
|
||||||
import FilterSetter from './filter-setter';
|
import FilterSetter from './filter-setter';
|
||||||
import SortSetter from './sort-setter';
|
import SortSetter from './sort-setter';
|
||||||
import GroupbySetter from './groupby-setter';
|
import GroupbySetter from './groupby-setter';
|
||||||
@@ -6,7 +7,8 @@ import PreHideColumnSetter from './pre-hide-column-setter';
|
|||||||
import HideColumnSetter from './hide-column-setter';
|
import HideColumnSetter from './hide-column-setter';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
SliderSetter,
|
GalleryGroupBySetter,
|
||||||
|
GallerySliderSetter,
|
||||||
FilterSetter,
|
FilterSetter,
|
||||||
SortSetter,
|
SortSetter,
|
||||||
GroupbySetter,
|
GroupbySetter,
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { SliderSetter, FilterSetter, GroupbySetter, SortSetter, HideColumnSetter } from '../data-process-setter';
|
import { GalleryGroupBySetter, GallerySliderSetter, FilterSetter, GroupbySetter, SortSetter, HideColumnSetter } from '../data-process-setter';
|
||||||
import { EVENT_BUS_TYPE, VIEW_TYPE } from '../../constants';
|
import { EVENT_BUS_TYPE, VIEW_TYPE } from '../../constants';
|
||||||
|
|
||||||
import './index.css';
|
import './index.css';
|
||||||
@@ -71,7 +71,12 @@ const ViewToolBar = ({ viewId }) => {
|
|||||||
onClick={onHeaderClick}
|
onClick={onHeaderClick}
|
||||||
>
|
>
|
||||||
<div className="sf-metadata-tool-left-operations">
|
<div className="sf-metadata-tool-left-operations">
|
||||||
{view.type === VIEW_TYPE.GALLERY && <SliderSetter view={view} />}
|
{viewType === VIEW_TYPE.GALLERY && (
|
||||||
|
<>
|
||||||
|
<GalleryGroupBySetter view={view} />
|
||||||
|
<GallerySliderSetter view={view} />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<FilterSetter
|
<FilterSetter
|
||||||
isNeedSubmit={true}
|
isNeedSubmit={true}
|
||||||
wrapperClass="sf-metadata-view-tool-operation-btn sf-metadata-view-tool-filter"
|
wrapperClass="sf-metadata-view-tool-operation-btn sf-metadata-view-tool-filter"
|
||||||
|
@@ -52,4 +52,5 @@ export const EVENT_BUS_TYPE = {
|
|||||||
|
|
||||||
// gallery
|
// gallery
|
||||||
MODIFY_GALLERY_ZOOM_GEAR: 'modify_gallery_zoom_gear',
|
MODIFY_GALLERY_ZOOM_GEAR: 'modify_gallery_zoom_gear',
|
||||||
|
SWITCH_GALLERY_GROUP_BY: 'switch_gallery_group_by',
|
||||||
};
|
};
|
||||||
|
@@ -118,3 +118,12 @@ export {
|
|||||||
TRANSFER_TYPES,
|
TRANSFER_TYPES,
|
||||||
metadataZIndexes,
|
metadataZIndexes,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const DATE_TAG_HEIGHT = 44;
|
||||||
|
|
||||||
|
export const GALLERY_DATE_MODE = {
|
||||||
|
YEAR: 'year',
|
||||||
|
MONTH: 'month',
|
||||||
|
DAY: 'day',
|
||||||
|
ALL: 'all',
|
||||||
|
};
|
||||||
|
@@ -42,6 +42,10 @@ const getDateDisplayString = (date, format) => {
|
|||||||
return dateObj.format('DD.MM.YYYY');
|
return dateObj.format('DD.MM.YYYY');
|
||||||
case 'DD.MM.YYYY HH:mm':
|
case 'DD.MM.YYYY HH:mm':
|
||||||
return dateObj.format('DD.MM.YYYY HH:mm');
|
return dateObj.format('DD.MM.YYYY HH:mm');
|
||||||
|
case 'YYYY':
|
||||||
|
return dateObj.format('YYYY');
|
||||||
|
case 'YYYY-MM':
|
||||||
|
return dateObj.format('YYYY-MM');
|
||||||
default:
|
default:
|
||||||
// Compatible with older versions: if format is null, use defaultFormat
|
// Compatible with older versions: if format is null, use defaultFormat
|
||||||
return dateObj.format('YYYY-MM-DD');
|
return dateObj.format('YYYY-MM-DD');
|
||||||
|
@@ -8,7 +8,7 @@ const GalleryMain = ({ groups, overScan, columns, size, gap }) => {
|
|||||||
|
|
||||||
const renderDisplayGroup = useCallback((group) => {
|
const renderDisplayGroup = useCallback((group) => {
|
||||||
const { top: overScanTop, bottom: overScanBottom } = overScan;
|
const { top: overScanTop, bottom: overScanBottom } = overScan;
|
||||||
const { name, children, height, top } = group;
|
const { name, children, height, top, paddingTop } = group;
|
||||||
|
|
||||||
// group not in rendering area, return empty div
|
// group not in rendering area, return empty div
|
||||||
if (top >= overScanBottom || top + height <= overScanTop) {
|
if (top >= overScanBottom || top + height <= overScanTop) {
|
||||||
@@ -33,7 +33,7 @@ const GalleryMain = ({ groups, overScan, columns, size, gap }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={name} className="metadata-gallery-date-group w-100" style={{ height }}>
|
<div key={name} className="metadata-gallery-date-group w-100" style={{ height, paddingTop }}>
|
||||||
{childrenStartIndex === 0 && (<div className="metadata-gallery-date-tag">{name}</div>)}
|
{childrenStartIndex === 0 && (<div className="metadata-gallery-date-tag">{name}</div>)}
|
||||||
<div
|
<div
|
||||||
className="metadata-gallery-image-list"
|
className="metadata-gallery-image-list"
|
||||||
@@ -67,10 +67,26 @@ const GalleryMain = ({ groups, overScan, columns, size, gap }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
GalleryMain.propTypes = {
|
GalleryMain.propTypes = {
|
||||||
groups: PropTypes.array,
|
groups: PropTypes.arrayOf(PropTypes.shape({
|
||||||
overScan: PropTypes.object,
|
name: PropTypes.string.isRequired,
|
||||||
columns: PropTypes.number,
|
children: PropTypes.arrayOf(PropTypes.shape({
|
||||||
size: PropTypes.number,
|
top: PropTypes.number.isRequired,
|
||||||
|
children: PropTypes.arrayOf(PropTypes.shape({
|
||||||
|
src: PropTypes.string.isRequired,
|
||||||
|
name: PropTypes.string.isRequired,
|
||||||
|
})).isRequired,
|
||||||
|
})).isRequired,
|
||||||
|
height: PropTypes.number.isRequired,
|
||||||
|
top: PropTypes.number.isRequired,
|
||||||
|
paddingTop: PropTypes.number.isRequired,
|
||||||
|
})),
|
||||||
|
overScan: PropTypes.shape({
|
||||||
|
top: PropTypes.number.isRequired,
|
||||||
|
bottom: PropTypes.number.isRequired,
|
||||||
|
}).isRequired,
|
||||||
|
columns: PropTypes.number.isRequired,
|
||||||
|
size: PropTypes.number.isRequired,
|
||||||
|
gap: PropTypes.number.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default GalleryMain;
|
export default GalleryMain;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
.sf-metadata-gallery-container {
|
.sf-metadata-gallery-container {
|
||||||
height: calc(100vh - 100px);
|
height: calc(100vh - 100px);
|
||||||
margin: 2px;
|
padding: 0 16px;
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -15,20 +15,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.metadata-gallery-date-tag {
|
.metadata-gallery-date-tag {
|
||||||
width: 6rem;
|
height: 2.75rem;
|
||||||
height: 1.5rem;
|
|
||||||
top: 1rem;
|
|
||||||
left: 1rem;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: left;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
border-radius: 12px;
|
|
||||||
background-color: #fafaf7;
|
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
text-align: center;
|
font-weight: 500;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
opacity: 0.9;
|
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,19 +6,21 @@ import { useMetadataView } from '../../hooks/metadata-view';
|
|||||||
import { Utils } from '../../../utils/utils';
|
import { Utils } from '../../../utils/utils';
|
||||||
import { getDateDisplayString } from '../../utils/cell';
|
import { getDateDisplayString } from '../../utils/cell';
|
||||||
import { siteRoot, thumbnailSizeForGrid } from '../../../utils/constants';
|
import { siteRoot, thumbnailSizeForGrid } from '../../../utils/constants';
|
||||||
import { EVENT_BUS_TYPE, PER_LOAD_NUMBER, PRIVATE_COLUMN_KEY } from '../../constants';
|
import { EVENT_BUS_TYPE, PER_LOAD_NUMBER, PRIVATE_COLUMN_KEY, GALLERY_DATE_MODE, DATE_TAG_HEIGHT } from '../../constants';
|
||||||
|
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
const IMAGE_GAP = 2;
|
const IMAGE_GAP = 2;
|
||||||
|
|
||||||
const Gallery = () => {
|
const Gallery = () => {
|
||||||
const containerRef = useRef(null);
|
|
||||||
const [isFirstLoading, setFirstLoading] = useState(true);
|
const [isFirstLoading, setFirstLoading] = useState(true);
|
||||||
const [isLoadingMore, setLoadingMore] = useState(false);
|
const [isLoadingMore, setLoadingMore] = useState(false);
|
||||||
const [zoomGear, setZoomGear] = useState(0);
|
const [zoomGear, setZoomGear] = useState(0);
|
||||||
const [containerWidth, setContainerWidth] = useState(0);
|
const [containerWidth, setContainerWidth] = useState(0);
|
||||||
const [overScan, setOverScan] = useState({ top: 0, bottom: 0 });
|
const [overScan, setOverScan] = useState({ top: 0, bottom: 0 });
|
||||||
|
const [mode, setMode] = useState(GALLERY_DATE_MODE.DAY);
|
||||||
|
|
||||||
|
const containerRef = useRef(null);
|
||||||
const renderMoreTimer = useRef(null);
|
const renderMoreTimer = useRef(null);
|
||||||
|
|
||||||
const { metadata, store } = useMetadataView();
|
const { metadata, store } = useMetadataView();
|
||||||
@@ -30,9 +32,22 @@ const Gallery = () => {
|
|||||||
}, [zoomGear]);
|
}, [zoomGear]);
|
||||||
|
|
||||||
const imageSize = useMemo(() => {
|
const imageSize = useMemo(() => {
|
||||||
return (containerWidth - columns * 2 - 2) / columns;
|
return (containerWidth - (columns - 1) * 2 - 32) / columns;
|
||||||
}, [containerWidth, columns]);
|
}, [containerWidth, columns]);
|
||||||
|
|
||||||
|
const dateMode = useMemo(() => {
|
||||||
|
switch (mode) {
|
||||||
|
case GALLERY_DATE_MODE.YEAR:
|
||||||
|
return 'YYYY';
|
||||||
|
case GALLERY_DATE_MODE.MONTH:
|
||||||
|
return 'YYYY-MM';
|
||||||
|
case GALLERY_DATE_MODE.DAY:
|
||||||
|
return 'YYYY-MM-DD';
|
||||||
|
default:
|
||||||
|
return 'YYYY-MM-DD';
|
||||||
|
}
|
||||||
|
}, [mode]);
|
||||||
|
|
||||||
const groups = useMemo(() => {
|
const groups = useMemo(() => {
|
||||||
if (isFirstLoading) return [];
|
if (isFirstLoading) return [];
|
||||||
const firstSort = metadata.view.sorts[0];
|
const firstSort = metadata.view.sorts[0];
|
||||||
@@ -42,7 +57,7 @@ const Gallery = () => {
|
|||||||
const fileName = record[PRIVATE_COLUMN_KEY.FILE_NAME];
|
const fileName = record[PRIVATE_COLUMN_KEY.FILE_NAME];
|
||||||
const parentDir = record[PRIVATE_COLUMN_KEY.PARENT_DIR];
|
const parentDir = record[PRIVATE_COLUMN_KEY.PARENT_DIR];
|
||||||
const path = Utils.encodePath(Utils.joinPath(parentDir, fileName));
|
const path = Utils.encodePath(Utils.joinPath(parentDir, fileName));
|
||||||
const date = getDateDisplayString(record[firstSort.column_key], 'YYYY-MM-DD');
|
const date = mode !== GALLERY_DATE_MODE.ALL ? getDateDisplayString(record[firstSort.column_key], dateMode) : '';
|
||||||
const img = {
|
const img = {
|
||||||
name: fileName,
|
name: fileName,
|
||||||
url: `${siteRoot}lib/${repoID}/file${path}`,
|
url: `${siteRoot}lib/${repoID}/file${path}`,
|
||||||
@@ -77,17 +92,20 @@ const Gallery = () => {
|
|||||||
if (!rows[rowIndex]) rows[rowIndex] = { top: top + rowIndex * imageHeight, children: [] };
|
if (!rows[rowIndex]) rows[rowIndex] = { top: top + rowIndex * imageHeight, children: [] };
|
||||||
rows[rowIndex].children.push(child);
|
rows[rowIndex].children.push(child);
|
||||||
});
|
});
|
||||||
const height = rows.length * imageHeight;
|
|
||||||
|
const paddingTop = mode === GALLERY_DATE_MODE.ALL ? 0 : DATE_TAG_HEIGHT;
|
||||||
|
const height = rows.length * imageHeight + paddingTop;
|
||||||
_groups.push({
|
_groups.push({
|
||||||
...__init,
|
...__init,
|
||||||
top,
|
top,
|
||||||
height,
|
height,
|
||||||
|
paddingTop,
|
||||||
children: rows
|
children: rows
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return _groups;
|
return _groups;
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [isFirstLoading, metadata, metadata.recordsCount, repoID, columns, imageSize]);
|
}, [isFirstLoading, metadata, metadata.recordsCount, repoID, columns, imageSize, mode]);
|
||||||
|
|
||||||
const loadMore = useCallback(async () => {
|
const loadMore = useCallback(async () => {
|
||||||
if (isLoadingMore) return;
|
if (isLoadingMore) return;
|
||||||
@@ -110,6 +128,17 @@ const Gallery = () => {
|
|||||||
const gear = window.sfMetadataContext.localStorage.getItem('zoom-gear', 0) || 0;
|
const gear = window.sfMetadataContext.localStorage.getItem('zoom-gear', 0) || 0;
|
||||||
setZoomGear(gear);
|
setZoomGear(gear);
|
||||||
|
|
||||||
|
const mode = window.sfMetadataContext.localStorage.getItem('gallery-group-by', GALLERY_DATE_MODE.DAY) || GALLERY_DATE_MODE.DAY;
|
||||||
|
setMode(mode);
|
||||||
|
|
||||||
|
const switchGalleryModeSubscribe = window.sfMetadataContext.eventBus.subscribe(
|
||||||
|
EVENT_BUS_TYPE.SWITCH_GALLERY_GROUP_BY,
|
||||||
|
(mode) => {
|
||||||
|
setMode(mode);
|
||||||
|
window.sfMetadataContext.localStorage.setItem('gallery-group-by', mode);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const container = containerRef.current;
|
const container = containerRef.current;
|
||||||
if (container) {
|
if (container) {
|
||||||
const { offsetWidth, clientHeight } = container;
|
const { offsetWidth, clientHeight } = container;
|
||||||
@@ -141,6 +170,7 @@ const Gallery = () => {
|
|||||||
return () => {
|
return () => {
|
||||||
container && resizeObserver.unobserve(container);
|
container && resizeObserver.unobserve(container);
|
||||||
modifyGalleryZoomGearSubscribe();
|
modifyGalleryZoomGearSubscribe();
|
||||||
|
switchGalleryModeSubscribe();
|
||||||
renderMoreTimer.current && clearTimeout(renderMoreTimer.current);
|
renderMoreTimer.current && clearTimeout(renderMoreTimer.current);
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
Reference in New Issue
Block a user