diff --git a/app/javascript/mastodon/actions/statuses.js b/app/javascript/mastodon/actions/statuses.js index 06a19afc3..b2f0bf07d 100644 --- a/app/javascript/mastodon/actions/statuses.js +++ b/app/javascript/mastodon/actions/statuses.js @@ -3,31 +3,31 @@ import openDB from '../storage/db'; import { evictStatus } from '../storage/modifier'; import { deleteFromTimelines } from './timelines'; -import { importFetchedStatus, importFetchedStatuses, importAccount, importStatus } from './importer'; +import { importAccount, importFetchedStatus, importFetchedStatuses, importStatus } from './importer'; import { ensureComposeIsVisible } from './compose'; export const STATUS_FETCH_REQUEST = 'STATUS_FETCH_REQUEST'; export const STATUS_FETCH_SUCCESS = 'STATUS_FETCH_SUCCESS'; -export const STATUS_FETCH_FAIL = 'STATUS_FETCH_FAIL'; +export const STATUS_FETCH_FAIL = 'STATUS_FETCH_FAIL'; export const STATUS_DELETE_REQUEST = 'STATUS_DELETE_REQUEST'; export const STATUS_DELETE_SUCCESS = 'STATUS_DELETE_SUCCESS'; -export const STATUS_DELETE_FAIL = 'STATUS_DELETE_FAIL'; +export const STATUS_DELETE_FAIL = 'STATUS_DELETE_FAIL'; export const CONTEXT_FETCH_REQUEST = 'CONTEXT_FETCH_REQUEST'; export const CONTEXT_FETCH_SUCCESS = 'CONTEXT_FETCH_SUCCESS'; -export const CONTEXT_FETCH_FAIL = 'CONTEXT_FETCH_FAIL'; +export const CONTEXT_FETCH_FAIL = 'CONTEXT_FETCH_FAIL'; export const STATUS_MUTE_REQUEST = 'STATUS_MUTE_REQUEST'; export const STATUS_MUTE_SUCCESS = 'STATUS_MUTE_SUCCESS'; -export const STATUS_MUTE_FAIL = 'STATUS_MUTE_FAIL'; +export const STATUS_MUTE_FAIL = 'STATUS_MUTE_FAIL'; export const STATUS_UNMUTE_REQUEST = 'STATUS_UNMUTE_REQUEST'; export const STATUS_UNMUTE_SUCCESS = 'STATUS_UNMUTE_SUCCESS'; -export const STATUS_UNMUTE_FAIL = 'STATUS_UNMUTE_FAIL'; +export const STATUS_UNMUTE_FAIL = 'STATUS_UNMUTE_FAIL'; export const STATUS_REVEAL = 'STATUS_REVEAL'; -export const STATUS_HIDE = 'STATUS_HIDE'; +export const STATUS_HIDE = 'STATUS_HIDE'; export const REDRAFT = 'REDRAFT'; @@ -37,7 +37,7 @@ export function fetchStatusRequest(id, skipLoading) { id, skipLoading, }; -}; +} function getFromDB(dispatch, getState, accountIndex, index, id) { return new Promise((resolve, reject) => { @@ -113,24 +113,24 @@ export function fetchStatus(id) { dispatch(fetchStatusFail(id, error, skipLoading)); }); }; -}; +} export function fetchStatusSuccess(skipLoading) { return { type: STATUS_FETCH_SUCCESS, skipLoading, }; -}; +} export function fetchStatusFail(id, error, skipLoading) { return { - type: STATUS_FETCH_FAIL, + type : STATUS_FETCH_FAIL, id, error, skipLoading, skipAlert: true, }; -}; +} export function redraft(status, raw_text) { return { @@ -138,7 +138,7 @@ export function redraft(status, raw_text) { status, raw_text, }; -}; +} export function deleteStatus(id, routerHistory, withRedraft = false) { return (dispatch, getState) => { @@ -163,29 +163,29 @@ export function deleteStatus(id, routerHistory, withRedraft = false) { dispatch(deleteStatusFail(id, error)); }); }; -}; +} export function deleteStatusRequest(id) { return { type: STATUS_DELETE_REQUEST, - id: id, + id : id, }; -}; +} export function deleteStatusSuccess(id) { return { type: STATUS_DELETE_SUCCESS, - id: id, + id : id, }; -}; +} export function deleteStatusFail(id, error) { return { - type: STATUS_DELETE_FAIL, - id: id, + type : STATUS_DELETE_FAIL, + id : id, error: error, }; -}; +} export function fetchContext(id) { return (dispatch, getState) => { @@ -203,33 +203,33 @@ export function fetchContext(id) { dispatch(fetchContextFail(id, error)); }); }; -}; +} export function fetchContextRequest(id) { return { type: CONTEXT_FETCH_REQUEST, id, }; -}; +} export function fetchContextSuccess(id, ancestors, descendants) { return { - type: CONTEXT_FETCH_SUCCESS, + type : CONTEXT_FETCH_SUCCESS, id, ancestors, descendants, statuses: ancestors.concat(descendants), }; -}; +} export function fetchContextFail(id, error) { return { - type: CONTEXT_FETCH_FAIL, + type : CONTEXT_FETCH_FAIL, id, error, skipAlert: true, }; -}; +} export function muteStatus(id) { return (dispatch, getState) => { @@ -241,21 +241,21 @@ export function muteStatus(id) { dispatch(muteStatusFail(id, error)); }); }; -}; +} export function muteStatusRequest(id) { return { type: STATUS_MUTE_REQUEST, id, }; -}; +} export function muteStatusSuccess(id) { return { type: STATUS_MUTE_SUCCESS, id, }; -}; +} export function muteStatusFail(id, error) { return { @@ -263,7 +263,7 @@ export function muteStatusFail(id, error) { id, error, }; -}; +} export function unmuteStatus(id) { return (dispatch, getState) => { @@ -275,21 +275,21 @@ export function unmuteStatus(id) { dispatch(unmuteStatusFail(id, error)); }); }; -}; +} export function unmuteStatusRequest(id) { return { type: STATUS_UNMUTE_REQUEST, id, }; -}; +} export function unmuteStatusSuccess(id) { return { type: STATUS_UNMUTE_SUCCESS, id, }; -}; +} export function unmuteStatusFail(id, error) { return { @@ -297,7 +297,7 @@ export function unmuteStatusFail(id, error) { id, error, }; -}; +} export function hideStatus(ids) { if (!Array.isArray(ids)) { @@ -308,7 +308,7 @@ export function hideStatus(ids) { type: STATUS_HIDE, ids, }; -}; +} export function revealStatus(ids) { if (!Array.isArray(ids)) { @@ -319,4 +319,4 @@ export function revealStatus(ids) { type: STATUS_REVEAL, ids, }; -}; +} diff --git a/app/javascript/mastodon/features/ui/components/link_footer.js b/app/javascript/mastodon/features/ui/components/link_footer.js index 27f3107e9..5ea4f7c3f 100644 --- a/app/javascript/mastodon/features/ui/components/link_footer.js +++ b/app/javascript/mastodon/features/ui/components/link_footer.js @@ -23,18 +23,22 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ }, }); +// const themeIsDark = true; +// const displaythemetoggler = true; export default @injectIntl @connect(null, mapDispatchToProps) class LinkFooter extends React.PureComponent { static propTypes = { - withHotkeys: PropTypes.bool, - displaySnow: PropTypes.bool, - onLogout : PropTypes.func.isRequired, - intl : PropTypes.object.isRequired, + enableChristmasSnow: PropTypes.bool, + snowActive : PropTypes.bool, + withHotkeys : PropTypes.bool, + snow : PropTypes.func, + onLogout : PropTypes.func.isRequired, + intl : PropTypes.object.isRequired, }; static defaultProps = { - displaySnow: false, + enableChristmasSnow: true, }; handleLogoutClick = e => { @@ -46,33 +50,113 @@ class LinkFooter extends React.PureComponent { return false; }; - componentDidMount() { + constructor(props) { + super(props); + Date.prototype.getWeek = function () { + var onejan = new Date(this.getFullYear(), 0, 1); + return Math.ceil((((this - onejan) / 86400000) + onejan.getDay() + 1) / 7); + }; + + var weekNumber = (new Date()).getWeek(); + // display snow during the last two weeks of the year + console.log('week', weekNumber); + const shouldWeDisplaySnow = (weekNumber > 48) && props.enableChristmasSnow; + + this.state = { enableChristmasSnow: shouldWeDisplaySnow }; + // make snow effect - if (this.props.displaySnow) { + if (shouldWeDisplaySnow) { import('../../../utils/snowstorm-min') .then((snowstorm) => { - console.log(snowstorm); - snowstorm(window, document); + Window.snowstorm = snowstorm.default; + this.state.snow = Window.snowstorm; + console.log('snowstorm', snowstorm); + // snowstorm.start(); + this.state.snowActive = true; }) .catch((err) => console.error(err)); } + + } + + toggleSnow() { + console.log('toggle snow'); + if (this.state.snow) { + if (this.state.snowActive) { + this.state.snow.stop(); + this.state.snowActive = false; + } else { + this.state.snow.start(); + this.state.snowActive = true; + } + + } + } + + changeTheme(newTheme) { + console.log('change theme en ', newTheme); } render() { const { withHotkeys } = this.props; + var snowClasses = this.props.snowActive ? 'snow-button active' : 'snow-button '; return ( +
+
+ + {/*// TODO*/} + {/**/} + + {this.state.enableChristmasSnow && ( +
+
+