mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-26 15:44:46 +01:00
commit
5ba2af0970
2 changed files with 55 additions and 41 deletions
|
@ -17,7 +17,7 @@ function FollowRequestButtons({ accountID, onChange }) {
|
|||
<p class="follow-request-buttons">
|
||||
<button
|
||||
type="button"
|
||||
disabled={uiState === 'loading'}
|
||||
disabled={uiState === 'loading' || hasRelationship}
|
||||
onClick={() => {
|
||||
setUIState('loading');
|
||||
setRequestState('accept');
|
||||
|
@ -40,7 +40,7 @@ function FollowRequestButtons({ accountID, onChange }) {
|
|||
</button>{' '}
|
||||
<button
|
||||
type="button"
|
||||
disabled={uiState === 'loading'}
|
||||
disabled={uiState === 'loading' || hasRelationship}
|
||||
class="light danger"
|
||||
onClick={() => {
|
||||
setUIState('loading');
|
||||
|
|
|
@ -92,11 +92,16 @@ function Notifications({ columnMode }) {
|
|||
return allNotifications;
|
||||
}
|
||||
|
||||
function fetchFollowRequests() {
|
||||
async function fetchFollowRequests() {
|
||||
// Note: no pagination here yet because this better be on a separate page. Should be rare use-case???
|
||||
return masto.v1.followRequests.list({
|
||||
limit: 80,
|
||||
});
|
||||
try {
|
||||
return await masto.v1.followRequests.list({
|
||||
limit: 80,
|
||||
});
|
||||
} catch (e) {
|
||||
// Silently fail
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
const loadFollowRequests = () => {
|
||||
|
@ -112,8 +117,13 @@ function Notifications({ columnMode }) {
|
|||
})();
|
||||
};
|
||||
|
||||
function fetchAnnouncements() {
|
||||
return masto.v1.announcements.list();
|
||||
async function fetchAnnouncements() {
|
||||
try {
|
||||
return await masto.v1.announcements.list();
|
||||
} catch (e) {
|
||||
// Silently fail
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
const loadNotifications = (firstLoad) => {
|
||||
|
@ -379,39 +389,43 @@ function Notifications({ columnMode }) {
|
|||
)}
|
||||
{snapStates.notifications.length ? (
|
||||
<>
|
||||
{snapStates.notifications.map((notification) => {
|
||||
if (onlyMentions && notification.type !== 'mention') {
|
||||
return null;
|
||||
}
|
||||
const notificationDay = new Date(notification.createdAt);
|
||||
const differentDay =
|
||||
notificationDay.toDateString() !== currentDay.toDateString();
|
||||
if (differentDay) {
|
||||
currentDay = notificationDay;
|
||||
}
|
||||
// if notificationDay is yesterday, show "Yesterday"
|
||||
// if notificationDay is before yesterday, show date
|
||||
const heading =
|
||||
notificationDay.toDateString() === yesterdayDate.toDateString()
|
||||
? 'Yesterday'
|
||||
: niceDateTime(currentDay, {
|
||||
hideTime: true,
|
||||
});
|
||||
return (
|
||||
<>
|
||||
{differentDay && <h2 class="timeline-header">{heading}</h2>}
|
||||
<Notification
|
||||
instance={instance}
|
||||
notification={notification}
|
||||
key={notification.id}
|
||||
reload={() => {
|
||||
loadNotifications(true);
|
||||
loadFollowRequests();
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
})}
|
||||
{snapStates.notifications
|
||||
// This is leaked from Notifications popover
|
||||
.filter((n) => n.type !== 'follow_request')
|
||||
.map((notification) => {
|
||||
if (onlyMentions && notification.type !== 'mention') {
|
||||
return null;
|
||||
}
|
||||
const notificationDay = new Date(notification.createdAt);
|
||||
const differentDay =
|
||||
notificationDay.toDateString() !== currentDay.toDateString();
|
||||
if (differentDay) {
|
||||
currentDay = notificationDay;
|
||||
}
|
||||
// if notificationDay is yesterday, show "Yesterday"
|
||||
// if notificationDay is before yesterday, show date
|
||||
const heading =
|
||||
notificationDay.toDateString() ===
|
||||
yesterdayDate.toDateString()
|
||||
? 'Yesterday'
|
||||
: niceDateTime(currentDay, {
|
||||
hideTime: true,
|
||||
});
|
||||
return (
|
||||
<>
|
||||
{differentDay && <h2 class="timeline-header">{heading}</h2>}
|
||||
<Notification
|
||||
instance={instance}
|
||||
notification={notification}
|
||||
key={notification.id}
|
||||
reload={() => {
|
||||
loadNotifications(true);
|
||||
loadFollowRequests();
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
|
|
Loading…
Add table
Reference in a new issue