Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32181873
D7907.1765077998.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D7907.1765077998.diff
View Options
diff --git a/lib/actions/link-actions.js b/lib/actions/link-actions.js
--- a/lib/actions/link-actions.js
+++ b/lib/actions/link-actions.js
@@ -6,6 +6,8 @@
InviteLinkVerificationResponse,
CreateOrUpdatePublicLinkRequest,
InviteLink,
+ DisableInviteLinkRequest,
+ DisableInviteLinkPayload,
} from '../types/link-types.js';
import type { CallServerEndpoint } from '../utils/call-server-endpoint.js';
@@ -75,6 +77,26 @@
};
};
+const disableInviteLinkLinkActionTypes = Object.freeze({
+ started: 'DISABLE_INVITE_LINK_STARTED',
+ success: 'DISABLE_INVITE_LINK_SUCCESS',
+ failed: 'DISABLE_INVITE_LINK_FAILED',
+});
+
+const disableInviteLink =
+ (
+ callServerEndpoint: CallServerEndpoint,
+ ): ((
+ request: DisableInviteLinkRequest,
+ ) => Promise<DisableInviteLinkPayload>) =>
+ async request => {
+ await callServerEndpoint('disable_invite_link', request);
+ return {
+ name: request.name,
+ communityID: request.communityID,
+ };
+ };
+
export {
verifyInviteLinkActionTypes,
verifyInviteLink,
@@ -82,4 +104,6 @@
fetchPrimaryInviteLinks,
createOrUpdatePublicLinkActionTypes,
createOrUpdatePublicLink,
+ disableInviteLinkLinkActionTypes,
+ disableInviteLink,
};
diff --git a/lib/reducers/invite-links-reducer.js b/lib/reducers/invite-links-reducer.js
--- a/lib/reducers/invite-links-reducer.js
+++ b/lib/reducers/invite-links-reducer.js
@@ -2,6 +2,7 @@
import {
createOrUpdatePublicLinkActionTypes,
+ disableInviteLinkLinkActionTypes,
fetchPrimaryInviteLinkActionTypes,
} from '../actions/link-actions.js';
import type { InviteLinksStore } from '../types/link-types.js';
@@ -34,6 +35,24 @@
},
},
};
+ } else if (action.type === disableInviteLinkLinkActionTypes.success) {
+ const communityID = action.payload.communityID;
+ const currentPrimaryLink = state.links[communityID]?.primaryLink;
+ const communityLinks = {
+ ...state.links[communityID],
+ primaryLink:
+ currentPrimaryLink?.name === action.payload.name
+ ? null
+ : currentPrimaryLink,
+ };
+
+ return {
+ ...state,
+ links: {
+ ...state.links,
+ [communityID]: communityLinks,
+ },
+ };
}
return state;
}
diff --git a/lib/types/link-types.js b/lib/types/link-types.js
--- a/lib/types/link-types.js
+++ b/lib/types/link-types.js
@@ -63,3 +63,8 @@
+name: string,
+communityID: string,
};
+
+export type DisableInviteLinkPayload = {
+ +name: string,
+ +communityID: string,
+};
diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js
--- a/lib/types/redux-types.js
+++ b/lib/types/redux-types.js
@@ -41,6 +41,7 @@
InviteLink,
InviteLinksStore,
InviteLinkVerificationResponse,
+ DisableInviteLinkPayload,
} from './link-types.js';
import type { LoadingStatus, LoadingInfo } from './loading-types.js';
import type { UpdateMultimediaMessageMediaPayload } from './media-types.js';
@@ -1046,6 +1047,22 @@
+error: true,
+payload: Error,
+loadingInfo: LoadingInfo,
+ }
+ | {
+ +type: 'DISABLE_INVITE_LINK_STARTED',
+ +loadingInfo?: LoadingInfo,
+ +payload?: void,
+ }
+ | {
+ +type: 'DISABLE_INVITE_LINK_SUCCESS',
+ +payload: DisableInviteLinkPayload,
+ +loadingInfo: LoadingInfo,
+ }
+ | {
+ +type: 'DISABLE_INVITE_LINK_FAILED',
+ +error: true,
+ +payload: Error,
+ +loadingInfo: LoadingInfo,
};
export type ActionPayload = ?(Object | Array<*> | $ReadOnlyArray<*> | string);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 7, 3:26 AM (4 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5842288
Default Alt Text
D7907.1765077998.diff (3 KB)
Attached To
Mode
D7907: [lib] Allow calling link-disabling endpoint
Attached
Detach File
Event Timeline
Log In to Comment