Progress
This commit is contained in:
@@ -77,10 +77,12 @@ export const ensureComposeIsVisible = (getState, routerHistory) => {
|
||||
}
|
||||
};
|
||||
|
||||
export function changeCompose(text) {
|
||||
export function changeCompose(text, markdown) {
|
||||
console.log("changeCompose:", markdown)
|
||||
return {
|
||||
type: COMPOSE_CHANGE,
|
||||
text: text,
|
||||
markdown: markdown,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -173,7 +175,7 @@ export function submitCompose(routerHistory, group) {
|
||||
if (!me) return;
|
||||
|
||||
let status = getState().getIn(['compose', 'text'], '');
|
||||
const statusMarkdown = getState().getIn(['compose', 'text_markdown'], '');
|
||||
const markdown = getState().getIn(['compose', 'markdown'], '');
|
||||
const media = getState().getIn(['compose', 'media_attachments']);
|
||||
|
||||
// : hack :
|
||||
@@ -182,11 +184,13 @@ export function submitCompose(routerHistory, group) {
|
||||
const hasProtocol = match.startsWith('https://') || match.startsWith('http://')
|
||||
return hasProtocol ? match : `http://${match}`
|
||||
})
|
||||
// statusMarkdown = statusMarkdown.replace(urlRegex, (match) =>{
|
||||
// markdown = statusMarkdown.replace(urlRegex, (match) =>{
|
||||
// const hasProtocol = match.startsWith('https://') || match.startsWith('http://')
|
||||
// return hasProtocol ? match : `http://${match}`
|
||||
// })
|
||||
|
||||
console.log("markdown:", markdown)
|
||||
|
||||
dispatch(submitComposeRequest());
|
||||
dispatch(closeModal());
|
||||
|
||||
@@ -202,7 +206,7 @@ export function submitCompose(routerHistory, group) {
|
||||
|
||||
api(getState)[method](endpoint, {
|
||||
status,
|
||||
// statusMarkdown,
|
||||
markdown,
|
||||
scheduled_at,
|
||||
in_reply_to_id: getState().getIn(['compose', 'in_reply_to'], null),
|
||||
quote_of_id: getState().getIn(['compose', 'quote_of_id'], null),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { normalizeAccount, normalizeStatus, normalizePoll } from './normalizer';
|
||||
import { fetchContext } from '../statuses'
|
||||
|
||||
export const ACCOUNT_IMPORT = 'ACCOUNT_IMPORT';
|
||||
export const ACCOUNTS_IMPORT = 'ACCOUNTS_IMPORT';
|
||||
@@ -78,6 +79,10 @@ export function importFetchedStatuses(statuses) {
|
||||
if (status.poll && status.poll.id) {
|
||||
pushUnique(polls, normalizePoll(status.poll));
|
||||
}
|
||||
|
||||
// if (status.replies_count > 0) {
|
||||
// dispatch(fetchComments(status.id));
|
||||
// }
|
||||
}
|
||||
|
||||
statuses.forEach(processStatus);
|
||||
|
||||
@@ -62,9 +62,10 @@ export function normalizeStatus(status, normalOldStatus) {
|
||||
const spoilerText = normalStatus.spoiler_text || '';
|
||||
const searchContent = [spoilerText, status.content].join('\n\n').replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n');
|
||||
const emojiMap = makeEmojiMap(normalStatus);
|
||||
const theContent = !!normalStatus.rich_content ? normalStatus.rich_content : normalStatus.content;
|
||||
|
||||
normalStatus.search_index = domParser.parseFromString(searchContent, 'text/html').documentElement.textContent;
|
||||
normalStatus.contentHtml = emojify(normalStatus.content, emojiMap);
|
||||
normalStatus.contentHtml = emojify(theContent, emojiMap);
|
||||
normalStatus.spoilerHtml = emojify(escapeTextContentForBrowser(spoilerText), emojiMap);
|
||||
normalStatus.hidden = expandSpoilers ? false : spoilerText.length > 0 || normalStatus.sensitive;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ export const CONTEXT_FETCH_REQUEST = 'CONTEXT_FETCH_REQUEST';
|
||||
export const CONTEXT_FETCH_SUCCESS = 'CONTEXT_FETCH_SUCCESS';
|
||||
export const CONTEXT_FETCH_FAIL = 'CONTEXT_FETCH_FAIL';
|
||||
|
||||
export const COMMENTS_FETCH_REQUEST = 'COMMENTS_FETCH_REQUEST';
|
||||
export const COMMENTS_FETCH_SUCCESS = 'COMMENTS_FETCH_SUCCESS';
|
||||
export const COMMENTS_FETCH_FAIL = 'COMMENTS_FETCH_FAIL';
|
||||
|
||||
export const STATUS_MUTE_REQUEST = 'STATUS_MUTE_REQUEST';
|
||||
export const STATUS_MUTE_SUCCESS = 'STATUS_MUTE_SUCCESS';
|
||||
export const STATUS_MUTE_FAIL = 'STATUS_MUTE_FAIL';
|
||||
@@ -85,8 +89,6 @@ export function fetchStatus(id) {
|
||||
return (dispatch, getState) => {
|
||||
const skipLoading = getState().getIn(['statuses', id], null) !== null;
|
||||
|
||||
dispatch(fetchContext(id));
|
||||
|
||||
if (skipLoading) {
|
||||
return;
|
||||
}
|
||||
@@ -205,6 +207,24 @@ export function fetchContext(id) {
|
||||
};
|
||||
};
|
||||
|
||||
export function fetchComments(id) {
|
||||
return (dispatch, getState) => {
|
||||
dispatch(fetchCommentsRequest(id));
|
||||
|
||||
api(getState).get(`/api/v1/statuses/${id}/comments`).then(response => {
|
||||
dispatch(importFetchedStatuses(response.data.descendants));
|
||||
dispatch(fetchCommentsSuccess(id, response.data.descendants));
|
||||
|
||||
}).catch(error => {
|
||||
if (error.response && error.response.status === 404) {
|
||||
dispatch(deleteFromTimelines(id));
|
||||
}
|
||||
|
||||
dispatch(fetchCommentsFail(id, error));
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export function fetchContextRequest(id) {
|
||||
return {
|
||||
type: CONTEXT_FETCH_REQUEST,
|
||||
@@ -231,6 +251,30 @@ export function fetchContextFail(id, error) {
|
||||
};
|
||||
};
|
||||
|
||||
export function fetchCommentsRequest(id) {
|
||||
return {
|
||||
type: COMMENTS_FETCH_REQUEST,
|
||||
id,
|
||||
};
|
||||
};
|
||||
|
||||
export function fetchCommentsSuccess(id, descendants) {
|
||||
return {
|
||||
type: COMMENTS_FETCH_SUCCESS,
|
||||
id,
|
||||
descendants,
|
||||
};
|
||||
};
|
||||
|
||||
export function fetchCommentsFail(id, error) {
|
||||
return {
|
||||
type: COMMENTS_FETCH_FAIL,
|
||||
id,
|
||||
error,
|
||||
skipAlert: true,
|
||||
};
|
||||
};
|
||||
|
||||
export function muteStatus(id) {
|
||||
return (dispatch, getState) => {
|
||||
if (!me) return;
|
||||
|
||||
Reference in New Issue
Block a user