Got to instance them all

This commit is contained in:
Lim Chee Aun 2023-02-19 00:05:46 +08:00
parent d4a6aa2d3b
commit f0eb684412
5 changed files with 16 additions and 6 deletions

View file

@ -8,7 +8,7 @@ const LIMIT = 20;
function Bookmarks() { function Bookmarks() {
useTitle('Bookmarks', '/b'); useTitle('Bookmarks', '/b');
const { masto } = api(); const { masto, instance } = api();
const bookmarksIterator = useRef(); const bookmarksIterator = useRef();
async function fetchBookmarks(firstLoad) { async function fetchBookmarks(firstLoad) {
if (firstLoad || !bookmarksIterator.current) { if (firstLoad || !bookmarksIterator.current) {
@ -23,6 +23,7 @@ function Bookmarks() {
id="bookmarks" id="bookmarks"
emptyText="No bookmarks yet. Go bookmark something!" emptyText="No bookmarks yet. Go bookmark something!"
errorText="Unable to load bookmarks" errorText="Unable to load bookmarks"
instance={instance}
fetchItems={fetchBookmarks} fetchItems={fetchBookmarks}
/> />
); );

View file

@ -8,7 +8,7 @@ const LIMIT = 20;
function Favourites() { function Favourites() {
useTitle('Favourites', '/f'); useTitle('Favourites', '/f');
const { masto } = api(); const { masto, instance } = api();
const favouritesIterator = useRef(); const favouritesIterator = useRef();
async function fetchFavourites(firstLoad) { async function fetchFavourites(firstLoad) {
if (firstLoad || !favouritesIterator.current) { if (firstLoad || !favouritesIterator.current) {
@ -23,6 +23,7 @@ function Favourites() {
id="favourites" id="favourites"
emptyText="No favourites yet. Go favourite something!" emptyText="No favourites yet. Go favourite something!"
errorText="Unable to load favourites" errorText="Unable to load favourites"
instance={instance}
fetchItems={fetchFavourites} fetchItems={fetchFavourites}
/> />
); );

View file

@ -113,6 +113,7 @@ function Following({ title, path, id, ...props }) {
id={id || 'following'} id={id || 'following'}
emptyText="Nothing to see here." emptyText="Nothing to see here."
errorText="Unable to load posts." errorText="Unable to load posts."
instance={instance}
fetchItems={fetchHome} fetchItems={fetchHome}
checkForUpdates={checkForUpdates} checkForUpdates={checkForUpdates}
useItemID useItemID

View file

@ -10,7 +10,7 @@ import useTitle from '../utils/useTitle';
const LIMIT = 20; const LIMIT = 20;
function List(props) { function List(props) {
const { masto } = api(); const { masto, instance } = api();
const id = props?.id || useParams()?.id; const id = props?.id || useParams()?.id;
const latestItem = useRef(); const latestItem = useRef();
@ -66,6 +66,7 @@ function List(props) {
id="list" id="list"
emptyText="Nothing yet." emptyText="Nothing yet."
errorText="Unable to load posts." errorText="Unable to load posts."
instance={instance}
fetchItems={fetchList} fetchItems={fetchList}
checkForUpdates={checkForUpdates} checkForUpdates={checkForUpdates}
boostsCarousel boostsCarousel

View file

@ -50,7 +50,7 @@ const LIMIT = 30; // 30 is the maximum limit :(
function Notifications() { function Notifications() {
useTitle('Notifications', '/notifications'); useTitle('Notifications', '/notifications');
const { masto } = api(); const { masto, instance } = api();
const snapStates = useSnapshot(states); const snapStates = useSnapshot(states);
const [uiState, setUIState] = useState('default'); const [uiState, setUIState] = useState('default');
const [showMore, setShowMore] = useState(false); const [showMore, setShowMore] = useState(false);
@ -227,6 +227,7 @@ function Notifications() {
<> <>
{differentDay && <h2 class="timeline-header">{heading}</h2>} {differentDay && <h2 class="timeline-header">{heading}</h2>}
<Notification <Notification
instance={instance}
notification={notification} notification={notification}
key={notification.id} key={notification.id}
/> />
@ -279,7 +280,7 @@ function Notifications() {
</div> </div>
); );
} }
function Notification({ notification }) { function Notification({ notification, instance }) {
const { id, type, status, account, _accounts } = notification; const { id, type, status, account, _accounts } = notification;
// status = Attached when type of the notification is favourite, reblog, status, mention, poll, or update // status = Attached when type of the notification is favourite, reblog, status, mention, poll, or update
@ -392,7 +393,11 @@ function Notification({ notification }) {
{status && ( {status && (
<Link <Link
class={`status-link status-type-${type}`} class={`status-link status-type-${type}`}
to={`/s/${actualStatusID}`} to={
instance
? `/${instance}/s/${actualStatusID}`
: `/s/${actualStatusID}`
}
> >
<Status status={status} size="s" /> <Status status={status} size="s" />
</Link> </Link>
@ -403,6 +408,7 @@ function Notification({ notification }) {
} }
function FollowRequestButtons({ accountID, onChange }) { function FollowRequestButtons({ accountID, onChange }) {
const { masto } = api();
const [uiState, setUIState] = useState('default'); const [uiState, setUIState] = useState('default');
return ( return (
<p> <p>