mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-29 10:18:29 -04:00
- Implement RecentActivity service to track recent planting, harvesting, and trading events. - Enhance TimelineService to include garden layouts in event queries. - Update navigation menu to include a link to friends and neighbours. - Create member card partial for displaying gardener information. - Add follow button partial for managing follow actions. - Refactor members index view to use the new member card partial. - Introduce neighbours feed view with daily updates and entries. - Implement entry partial for displaying individual neighbour activities. - Create layout partial for visualizing garden layouts. - Add posts section to neighbours view for displaying recent posts. - Implement reach section to show nearby gardeners. - Add suggestions section for recommending gardeners to follow. - Create routes for neighbours functionality and member dismissals. - Add migrations for member dismissals and garden layout timestamps. - Write feature and request specs for neighbours functionality. - Include support for creating located members in tests.
38 lines
1.1 KiB
React
38 lines
1.1 KiB
React
import React, {useState} from 'react';
|
|
|
|
import {getJson} from '../api';
|
|
|
|
// "Show earlier days" for the friends and neighbours feed: fetches the next
|
|
// small chunk of it, already rendered by Rails, and adds it below, so the page
|
|
// never loads more than a few days at a time. `url` is where the next chunk is;
|
|
// each reply says where the one after it is, until there is none.
|
|
export default function FeedMore({url, label}) {
|
|
const [chunks, setChunks] = useState([]);
|
|
const [next, setNext] = useState(url);
|
|
const [busy, setBusy] = useState(false);
|
|
|
|
async function load() {
|
|
setBusy(true);
|
|
try {
|
|
const {ok, data} = await getJson(next);
|
|
if (ok && data) {
|
|
setChunks((existing) => [...existing, data.html]);
|
|
setNext(data.next);
|
|
}
|
|
} finally {
|
|
setBusy(false);
|
|
}
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{chunks.map((html, index) => <div key={index} dangerouslySetInnerHTML={{__html: html}} />)}
|
|
{next && (
|
|
<p className="text-center">
|
|
<button type="button" className="btn btn-success" disabled={busy} onClick={load}>{label}</button>
|
|
</p>
|
|
)}
|
|
</>
|
|
);
|
|
}
|