PersonViewSafe,
PostReportView,
PostView,
+ PrivateMessageReportView,
PrivateMessageView,
RegistrationApplicationView,
Search,
});
}
-export function amAdmin(
- admins: Option<PersonViewSafe[]>,
- myUserInfo = UserService.Instance.myUserInfo
-): boolean {
- return myUserInfo.match({
- some: mui => isAdmin(admins, mui.local_user_view.person.id),
- none: false,
- });
+export function amAdmin(myUserInfo = UserService.Instance.myUserInfo): boolean {
+ return myUserInfo
+ .map(mui => mui.local_user_view.person.admin)
+ .unwrapOr(false);
}
export function amCommunityCreator(
export function pictrsDeleteToast(
clickToDeleteText: string,
deletePictureText: string,
+ failedDeletePictureText: string,
deleteUrl: string
) {
if (isBrowser()) {
duration: 10000,
onClick: () => {
if (toast) {
- window.location.replace(deleteUrl);
- alert(deletePictureText);
- toast.hideToast();
+ fetch(deleteUrl, {})
+ .then( res => {
+ console.log(res)
+ toast.hideToast();
+ if (res.ok === true){
+ alert(deletePictureText);
+ } else{
+ alert(failedDeletePictureText);
+ }
+ })
}
},
close: true,
}
}
+// TODO possible to make these generic?
export function updatePostReportRes(
data: PostReportView,
reports: PostReportView[]
}
}
+export function updatePrivateMessageReportRes(
+ data: PrivateMessageReportView,
+ reports: PrivateMessageReportView[]
+) {
+ let found = reports.find(
+ c => c.private_message_report.id == data.private_message_report.id
+ );
+ if (found) {
+ found.private_message_report = data.private_message_report;
+ }
+}
+
export function updateRegistrationApplicationRes(
data: RegistrationApplicationView,
applications: RegistrationApplicationView[]
shouldSort: false,
searchResultLimit: fetchLimit,
classNames: {
- containerOuter: "choices",
- containerInner: "choices__inner bg-secondary border-0",
- input: "form-control",
- inputCloned: "choices__input--cloned",
- list: "choices__list",
- listItems: "choices__list--multiple",
- listSingle: "choices__list--single",
- listDropdown: "choices__list--dropdown",
- item: "choices__item bg-secondary",
- itemSelectable: "choices__item--selectable",
- itemDisabled: "choices__item--disabled",
- itemChoice: "choices__item--choice",
- placeholder: "choices__placeholder",
- group: "choices__group",
- groupHeading: "choices__heading",
- button: "choices__button",
- activeState: "is-active",
- focusState: "is-focused",
- openState: "is-open",
- disabledState: "is-disabled",
- highlightedState: "text-info",
- selectedState: "text-info",
- flippedState: "is-flipped",
- loadingState: "is-loading",
- noResults: "has-no-results",
- noChoices: "has-no-choices",
- },
-};
-
-export const choicesModLogConfig = {
- shouldSort: false,
- searchResultLimit: fetchLimit,
- classNames: {
- containerOuter: "choices mb-2 custom-select px-0",
+ containerOuter: "choices custom-select px-0",
containerInner:
"choices__inner bg-secondary border-0 py-0 modlog-choices-font-size",
input: "form-control",
- inputCloned: "choices__input--cloned w-100",
+ inputCloned: "choices__input--cloned",
list: "choices__list",
listItems: "choices__list--multiple",
listSingle: "choices__list--single py-0",
);
}
-export function canCreateCommunity(siteRes: GetSiteResponse): boolean {
+export function canCreateCommunity(
+ siteRes: GetSiteResponse,
+ myUserInfo = UserService.Instance.myUserInfo
+): boolean {
let adminOnly = siteRes.site_view
.map(s => s.site.community_creation_admin_only)
.unwrapOr(false);
- return !adminOnly || amAdmin(Some(siteRes.admins));
+ return !adminOnly || amAdmin(myUserInfo);
}
export function isPostBlocked(