forked from Mirrors/gomuks
web/util: remove oxfordHumanJoin
This commit is contained in:
parent
332d71cadd
commit
3e460da67d
3 changed files with 4 additions and 7 deletions
|
@ -15,18 +15,18 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import { PinnedEventsContent } from "@/api/types"
|
||||
import { listDiff } from "@/util/diff.ts"
|
||||
import { oxfordHumanJoin } from "@/util/join.ts"
|
||||
import { humanJoin } from "@/util/join.ts"
|
||||
import EventContentProps from "./props.ts"
|
||||
|
||||
function renderPinChanges(content: PinnedEventsContent, prevContent?: PinnedEventsContent): string {
|
||||
const [added, removed] = listDiff(content.pinned ?? [], prevContent?.pinned ?? [])
|
||||
if (added.length) {
|
||||
if (removed.length) {
|
||||
return `pinned ${oxfordHumanJoin(added)} and unpinned ${oxfordHumanJoin(removed)}`
|
||||
return `pinned ${humanJoin(added)} and unpinned ${humanJoin(removed)}`
|
||||
}
|
||||
return `pinned ${oxfordHumanJoin(added)}`
|
||||
return `pinned ${humanJoin(added)}`
|
||||
} else if (removed.length) {
|
||||
return `unpinned ${oxfordHumanJoin(removed)}`
|
||||
return `unpinned ${humanJoin(removed)}`
|
||||
} else {
|
||||
return "sent a no-op pin event"
|
||||
}
|
||||
|
|
|
@ -25,5 +25,3 @@ export function humanJoin(arr: string[], sep: string = ", ", lastSep: string = "
|
|||
}
|
||||
return arr.slice(0, -1).join(sep) + lastSep + arr[arr.length - 1]
|
||||
}
|
||||
|
||||
export const oxfordHumanJoin = (arr: string[]) => humanJoin(arr, ", ", ", and ")
|
||||
|
|
|
@ -27,5 +27,4 @@ export function humanJoinReact(
|
|||
</Fragment>)
|
||||
}
|
||||
|
||||
export const oxfordHumanJoinReact = (arr: (string | JSX.Element)[]) => humanJoinReact(arr, ", ", ", and ")
|
||||
export const joinReact = (arr: (string | JSX.Element)[]) => humanJoinReact(arr, " ", " ")
|
||||
|
|
Loading…
Add table
Reference in a new issue