phanpy/src/utils/states.js

33 lines
743 B
JavaScript
Raw Normal View History

2022-12-10 12:14:48 +03:00
import { proxy } from 'valtio';
2023-01-09 14:11:34 +03:00
const states = proxy({
2022-12-10 12:14:48 +03:00
history: [],
statuses: {},
2022-12-10 12:14:48 +03:00
home: [],
homeNew: [],
homeLastFetchTime: null,
notifications: [],
notificationsNew: [],
notificationsLastFetchTime: null,
accounts: {},
2022-12-10 12:14:48 +03:00
reloadStatusPage: 0,
spoilers: {},
scrollPositions: {},
2022-12-10 12:14:48 +03:00
// Modals
showCompose: false,
showSettings: false,
showAccount: false,
composeCharacterCount: 0,
2022-12-10 12:14:48 +03:00
});
2023-01-09 14:11:34 +03:00
export default states;
export function saveStatus(status, opts) {
const { override } = Object.assign({ override: true }, opts);
if (!status) return;
if (!override && states.statuses[status.id]) return;
states.statuses[status.id] = status;
if (status.reblog) {
states.statuses[status.reblog.id] = status.reblog;
}
}