mirror of https://github.com/MaxLeiter/Drift
client: mine page fixes, remove lodash.debounce
parent
1369bdf996
commit
fe589d63d8
@ -1,29 +1,35 @@
|
|||||||
const replaceLastInString = (
|
const replaceLastInString = (
|
||||||
string: string,
|
string: string,
|
||||||
search: string,
|
search: string,
|
||||||
replace: string
|
replace: string
|
||||||
): string => {
|
): string => {
|
||||||
const index = string.lastIndexOf(search);
|
const index = string.lastIndexOf(search)
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
return string;
|
return string
|
||||||
}
|
}
|
||||||
return string.substring(0, index) + replace + string.substring(index + search.length);
|
return (
|
||||||
|
string.substring(0, index) +
|
||||||
|
replace +
|
||||||
|
string.substring(index + search.length)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const getTitleForPostCopy = (
|
const getTitleForPostCopy = (title: string) => {
|
||||||
title: string,
|
const numberAtEndOfTitle = title.split(" ").pop()
|
||||||
) => {
|
if (numberAtEndOfTitle) {
|
||||||
const numberAtEndOfTitle = title.split(" ").pop()
|
const number = parseInt(numberAtEndOfTitle)
|
||||||
if (numberAtEndOfTitle) {
|
if (number) {
|
||||||
const number = parseInt(numberAtEndOfTitle)
|
return replaceLastInString(
|
||||||
if (number) {
|
title,
|
||||||
return replaceLastInString(title, numberAtEndOfTitle, (number + 1).toString())
|
numberAtEndOfTitle,
|
||||||
} else {
|
(number + 1).toString()
|
||||||
return title + " 1"
|
)
|
||||||
}
|
} else {
|
||||||
} else {
|
return title + " 1"
|
||||||
return title + " 1"
|
}
|
||||||
}
|
} else {
|
||||||
|
return title + " 1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default getTitleForPostCopy
|
export default getTitleForPostCopy
|
||||||
|
Loading…
Reference in New Issue