forked from glitch-soc/mastodon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request glitch-soc#2718 from ClearlyClaire/glitch-soc/merg…
…e-upstream Merge upstream changes up to b6fd14f
- Loading branch information
Showing
119 changed files
with
833 additions
and
384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,10 @@ | ||
import type { ApiRelationshipJSON } from 'flavours/glitch/api_types/relationships'; | ||
import { createAppAsyncThunk } from 'flavours/glitch/store/typed_functions'; | ||
import { apiSubmitAccountNote } from 'flavours/glitch/api/accounts'; | ||
import { createDataLoadingThunk } from 'flavours/glitch/store/typed_functions'; | ||
|
||
import api from '../api'; | ||
|
||
export const submitAccountNote = createAppAsyncThunk( | ||
export const submitAccountNote = createDataLoadingThunk( | ||
'account_note/submit', | ||
async (args: { id: string; value: string }) => { | ||
const response = await api().post<ApiRelationshipJSON>( | ||
`/api/v1/accounts/${args.id}/note`, | ||
{ | ||
comment: args.value, | ||
}, | ||
); | ||
|
||
return { relationship: response.data }; | ||
}, | ||
({ accountId, note }: { accountId: string; note: string }) => | ||
apiSubmitAccountNote(accountId, note), | ||
(relationship) => ({ relationship }), | ||
{ skipLoading: true }, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
app/javascript/flavours/glitch/actions/interactions_typed.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { apiReblog, apiUnreblog } from 'flavours/glitch/api/interactions'; | ||
import type { StatusVisibility } from 'flavours/glitch/models/status'; | ||
import { createDataLoadingThunk } from 'flavours/glitch/store/typed_functions'; | ||
|
||
import { importFetchedStatus } from './importer'; | ||
|
||
export const reblog = createDataLoadingThunk( | ||
'status/reblog', | ||
({ | ||
statusId, | ||
visibility, | ||
}: { | ||
statusId: string; | ||
visibility: StatusVisibility; | ||
}) => apiReblog(statusId, visibility), | ||
(data, { dispatch, discardLoadData }) => { | ||
// The reblog API method returns a new status wrapped around the original. In this case we are only | ||
// interested in how the original is modified, hence passing it skipping the wrapper | ||
dispatch(importFetchedStatus(data.reblog)); | ||
|
||
// The payload is not used in any actions | ||
return discardLoadData; | ||
}, | ||
); | ||
|
||
export const unreblog = createDataLoadingThunk( | ||
'status/unreblog', | ||
({ statusId }: { statusId: string }) => apiUnreblog(statusId), | ||
(data, { dispatch, discardLoadData }) => { | ||
dispatch(importFetchedStatus(data)); | ||
|
||
// The payload is not used in any actions | ||
return discardLoadData; | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { apiRequest } from 'flavours/glitch/api'; | ||
import type { ApiRelationshipJSON } from 'flavours/glitch/api_types/relationships'; | ||
|
||
export const apiSubmitAccountNote = (id: string, value: string) => | ||
apiRequest<ApiRelationshipJSON>('post', `v1/accounts/${id}/note`, { | ||
comment: value, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { apiRequest } from 'flavours/glitch/api'; | ||
import type { Status, StatusVisibility } from 'flavours/glitch/models/status'; | ||
|
||
export const apiReblog = (statusId: string, visibility: StatusVisibility) => | ||
apiRequest<{ reblog: Status }>('post', `v1/statuses/${statusId}/reblog`, { | ||
visibility, | ||
}); | ||
|
||
export const apiUnreblog = (statusId: string) => | ||
apiRequest<Status>('post', `v1/statuses/${statusId}/unreblog`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.