add toot-edit
This commit is contained in:
parent
cb9a3c4af1
commit
742b93bbef
|
@ -82,7 +82,13 @@ function post(mode, postvis, dry) {
|
||||||
$('.toot-btn-group').prop('disabled', true)
|
$('.toot-btn-group').prop('disabled', true)
|
||||||
todo('Posting')
|
todo('Posting')
|
||||||
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
||||||
var start = 'https://' + domain + '/api/v1/statuses'
|
let start = 'https://' + domain + '/api/v1/statuses'
|
||||||
|
let method = 'POST'
|
||||||
|
const editTarget = $('#tootmodal').attr('data-edit')
|
||||||
|
if (editTarget) {
|
||||||
|
start = start + `/${editTarget}`
|
||||||
|
method = 'PUT'
|
||||||
|
}
|
||||||
var reply = $('#reply').val()
|
var reply = $('#reply').val()
|
||||||
if (str.indexOf(localStorage.getItem('stable')) == -1) {
|
if (str.indexOf(localStorage.getItem('stable')) == -1) {
|
||||||
str + ' #' + localStorage.getItem('stable')
|
str + ' #' + localStorage.getItem('stable')
|
||||||
|
@ -174,7 +180,7 @@ function post(mode, postvis, dry) {
|
||||||
return toot
|
return toot
|
||||||
}
|
}
|
||||||
var httpreq = new XMLHttpRequest()
|
var httpreq = new XMLHttpRequest()
|
||||||
httpreq.open('POST', start, true)
|
httpreq.open(method, start, true)
|
||||||
httpreq.setRequestHeader('Content-Type', 'application/json')
|
httpreq.setRequestHeader('Content-Type', 'application/json')
|
||||||
httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
|
httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
|
||||||
httpreq.setRequestHeader('Idempotency-Key', ideKey)
|
httpreq.setRequestHeader('Idempotency-Key', ideKey)
|
||||||
|
@ -375,5 +381,6 @@ function clear() {
|
||||||
width = 300
|
width = 300
|
||||||
}
|
}
|
||||||
$('#post-box').css('width', width)
|
$('#post-box').css('width', width)
|
||||||
|
$('#tootmodal').attr('data-edit', null)
|
||||||
mdCheck()
|
mdCheck()
|
||||||
}
|
}
|
||||||
|
|
|
@ -459,17 +459,40 @@ function redraft(id, acct_id) {
|
||||||
setLog(start, this.status, this.response)
|
setLog(start, this.status, this.response)
|
||||||
}
|
}
|
||||||
var json = httpreq.response
|
var json = httpreq.response
|
||||||
draftToPost(json, acct_id, id)
|
draftToPost(json, acct_id, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// edit
|
||||||
|
function editToot(id, acct_id) {
|
||||||
|
show()
|
||||||
|
var domain = localStorage.getItem('domain_' + acct_id)
|
||||||
|
var at = localStorage.getItem('acct_' + acct_id + '_at')
|
||||||
|
var start = 'https://' + domain + '/api/v1/statuses/' + id + '/source'
|
||||||
|
var httpreq = new XMLHttpRequest()
|
||||||
|
httpreq.open('GET', start, true)
|
||||||
|
httpreq.setRequestHeader('Content-Type', 'application/json')
|
||||||
|
httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
|
||||||
|
httpreq.responseType = 'json'
|
||||||
|
httpreq.send()
|
||||||
|
httpreq.onreadystatechange = function () {
|
||||||
|
if (httpreq.readyState === 4) {
|
||||||
|
if (this.status !== 200) {
|
||||||
|
setLog(start, this.status, this.response)
|
||||||
|
}
|
||||||
|
var json = httpreq.response
|
||||||
|
draftToPost(json, acct_id, id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function draftToPost(json, acct_id, id) {
|
function draftToPost(json, acct_id, id) {
|
||||||
$('#post-acct-sel').prop('disabled', true)
|
$('#post-acct-sel').prop('disabled', true)
|
||||||
$('#post-acct-sel').val(acct_id)
|
$('#post-acct-sel').val(acct_id)
|
||||||
$('select').formSelect()
|
$('select').formSelect()
|
||||||
|
if (id) $('#tootmodal').attr('data-edit', id)
|
||||||
mdCheck()
|
mdCheck()
|
||||||
mediack = null
|
mediack = null
|
||||||
if (json.media_attachments) mediack = json.media_attachments[0]
|
if (json.media_attachments) mediack = json.media_attachments[0]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//トゥートの詳細
|
//トゥートの詳細
|
||||||
function details(id, acct_id, tlid, mode) {
|
async function details(id, acct_id, tlid, mode) {
|
||||||
if (mode == 'dm') {
|
if (mode == 'dm') {
|
||||||
$('.dm-hide').hide()
|
$('.dm-hide').hide()
|
||||||
} else {
|
} else {
|
||||||
|
@ -39,25 +39,17 @@ function details(id, acct_id, tlid, mode) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
fetch(start, i)
|
const response = await fetch(start, i)
|
||||||
.then(function(response) {
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
response.text().then(function (text) {
|
response.text().then(function (text) {
|
||||||
setLog(response.url, response.status, text)
|
setLog(response.url, response.status, text)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return response.json()
|
const json = await response.json()
|
||||||
})
|
|
||||||
.catch(function(error) {
|
|
||||||
todo(error)
|
|
||||||
setLog(start, 'JSON', error)
|
|
||||||
console.error(error)
|
|
||||||
})
|
|
||||||
.then(function(json) {
|
|
||||||
console.log(['Toot data:', json])
|
console.log(['Toot data:', json])
|
||||||
if (!$('#timeline_' + tlid + ' #pub_' + id).length) {
|
if (!$('#timeline_' + tlid + ' #pub_' + id).length) {
|
||||||
var html = parse([json], '', acct_id)
|
var html = parse([json], '', acct_id, '', '', mute)
|
||||||
$('#toot-this').html(html)
|
$('#toot-this').html(html)
|
||||||
jQuery('time.timeago').timeago()
|
jQuery('time.timeago').timeago()
|
||||||
}
|
}
|
||||||
|
@ -112,6 +104,18 @@ function details(id, acct_id, tlid, mode) {
|
||||||
afterFTLToot(id, acct_id, dom)
|
afterFTLToot(id, acct_id, dom)
|
||||||
faved(id, acct_id)
|
faved(id, acct_id)
|
||||||
rted(id, acct_id)
|
rted(id, acct_id)
|
||||||
|
if (json.edited_at) {
|
||||||
|
$('.edited-hide').show()
|
||||||
|
try {
|
||||||
|
const history = await (await fetch(`https://${domain}/api/v1/statuses/${id}/history`, i)).json()
|
||||||
|
const temp = parse(history, 'noauth', acct_id)
|
||||||
|
console.log(temp)
|
||||||
|
$('#toot-edit').html(temp)
|
||||||
|
} catch(e) { console.error(e) }
|
||||||
|
} else {
|
||||||
|
$('#toot-edit').html('')
|
||||||
|
$('.edited-hide').hide()
|
||||||
|
}
|
||||||
if ($('#toot-this div').hasClass('cvo')) {
|
if ($('#toot-this div').hasClass('cvo')) {
|
||||||
$('#toot-this').removeClass('cvo')
|
$('#toot-this').removeClass('cvo')
|
||||||
} else {
|
} else {
|
||||||
|
@ -122,7 +126,11 @@ function details(id, acct_id, tlid, mode) {
|
||||||
if (!$('#activator').hasClass('active')) {
|
if (!$('#activator').hasClass('active')) {
|
||||||
$('#det-col').collapsible('open', 4)
|
$('#det-col').collapsible('open', 4)
|
||||||
}
|
}
|
||||||
})
|
} catch (e) {
|
||||||
|
todo(error)
|
||||||
|
setLog(start, 'JSON', error)
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//返信タイムライン
|
//返信タイムライン
|
||||||
|
|
|
@ -482,6 +482,9 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type, onlyContent) {
|
||||||
var locked = ' <i class="fas fa-lock red-text"></i>'
|
var locked = ' <i class="fas fa-lock red-text"></i>'
|
||||||
} else {
|
} else {
|
||||||
var locked = ''
|
var locked = ''
|
||||||
|
}
|
||||||
|
if (toot.edited_at) {
|
||||||
|
locked = locked + ` <i class="material-icons teal-text" style="font-size: 0.8rem" title="Edited at ${date(toot.edited_at, 'absolute')}">create</i>`
|
||||||
}
|
}
|
||||||
if (!toot.application) {
|
if (!toot.application) {
|
||||||
var via = ''
|
var via = ''
|
||||||
|
@ -642,7 +645,6 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type, onlyContent) {
|
||||||
} else {
|
} else {
|
||||||
var desc = ''
|
var desc = ''
|
||||||
}
|
}
|
||||||
console.log('https://' + domain + '/storage/no-preview.png')
|
|
||||||
if (media.preview_url == 'https://' + domain + '/storage/no-preview.png') {
|
if (media.preview_url == 'https://' + domain + '/storage/no-preview.png') {
|
||||||
purl = url
|
purl = url
|
||||||
nsfwmes = '<div class="nsfw-media">Unavailable preview</div>'
|
nsfwmes = '<div class="nsfw-media">Unavailable preview</div>'
|
||||||
|
@ -664,10 +666,9 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type, onlyContent) {
|
||||||
viewer = ''
|
viewer = ''
|
||||||
hasmedia = 'nomedia'
|
hasmedia = 'nomedia'
|
||||||
}
|
}
|
||||||
var menck = toot.mentions[0]
|
|
||||||
var mentions = ''
|
var mentions = ''
|
||||||
//メンションであれば
|
//メンションであれば
|
||||||
if (menck) {
|
if (toot.mentions && toot.mentions[0]) {
|
||||||
mentions = ''
|
mentions = ''
|
||||||
var to_mention = []
|
var to_mention = []
|
||||||
Object.keys(toot.mentions).forEach(function (key3) {
|
Object.keys(toot.mentions).forEach(function (key3) {
|
||||||
|
@ -1144,6 +1145,10 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type, onlyContent) {
|
||||||
style="padding:0; padding-top: 5px;">
|
style="padding:0; padding-top: 5px;">
|
||||||
<i class="material-icons" aria-hidden="true">redo</i>${lang.lang_parse_redraft}
|
<i class="material-icons" aria-hidden="true">redo</i>${lang.lang_parse_redraft}
|
||||||
</li>
|
</li>
|
||||||
|
<li class="${if_mine}" onclick="editToot('${uniqueid}','${acct_id}')"
|
||||||
|
style="padding:0; padding-top: 5px;">
|
||||||
|
<i class="material-icons" aria-hidden="true">create</i>${lang.lang_edit}(v3.5.0~)
|
||||||
|
</li>
|
||||||
${trans}
|
${trans}
|
||||||
<li onclick="postMessage(['openUrl', '${toot.url}'], '*')"
|
<li onclick="postMessage(['openUrl', '${toot.url}'], '*')"
|
||||||
style="padding:0; padding-top: 5px;">
|
style="padding:0; padding-top: 5px;">
|
||||||
|
@ -1565,6 +1570,13 @@ function mastodonBaseStreaming(acct_id) {
|
||||||
filterUpdate(acct_id)
|
filterUpdate(acct_id)
|
||||||
} else if (~typeA.indexOf('announcement')) {
|
} else if (~typeA.indexOf('announcement')) {
|
||||||
announ(acct_id, tlid)
|
announ(acct_id, tlid)
|
||||||
|
} else if (typeA === 'status.update') {
|
||||||
|
const tl = JSON.parse(mess.data).stream
|
||||||
|
const obj = JSON.parse(JSON.parse(mess.data).payload)
|
||||||
|
const tls = getTlMeta(tl[0], tl, acct_id, obj)
|
||||||
|
const template = insertTl(obj, tls, true)
|
||||||
|
$(`[unique-id=${obj.id}]`).html(template)
|
||||||
|
$(`[unique-id=${obj.id}] [unique-id=${obj.id}]`).unwrap()
|
||||||
} else if (typeA == 'notification') {
|
} else if (typeA == 'notification') {
|
||||||
const obj = JSON.parse(JSON.parse(mess.data).payload)
|
const obj = JSON.parse(JSON.parse(mess.data).payload)
|
||||||
let template = ''
|
let template = ''
|
||||||
|
@ -1635,7 +1647,7 @@ function mastodonBaseStreaming(acct_id) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function insertTl(obj, tls) {
|
function insertTl(obj, tls, dry) {
|
||||||
for (const timeline of tls) {
|
for (const timeline of tls) {
|
||||||
const { id, voice, type, acct_id } = timeline
|
const { id, voice, type, acct_id } = timeline
|
||||||
const mute = getFilterTypeByAcct(acct_id, type)
|
const mute = getFilterTypeByAcct(acct_id, type)
|
||||||
|
@ -1645,6 +1657,7 @@ function insertTl(obj, tls) {
|
||||||
say(obj.content)
|
say(obj.content)
|
||||||
}
|
}
|
||||||
const template = parse([obj], type, acct_id, id, '', mute, type)
|
const template = parse([obj], type, acct_id, id, '', mute, type)
|
||||||
|
if (dry) return template
|
||||||
console.log($(`#timeline_box_${id}_box .tl-box`).scrollTop(), `timeline_box_${id}_box .tl-box`)
|
console.log($(`#timeline_box_${id}_box .tl-box`).scrollTop(), `timeline_box_${id}_box .tl-box`)
|
||||||
if (
|
if (
|
||||||
$(`#timeline_box_${id}_box .tl-box`).scrollTop() === 0
|
$(`#timeline_box_${id}_box .tl-box`).scrollTop() === 0
|
||||||
|
|
|
@ -50,6 +50,10 @@
|
||||||
<div class="collapsible-header"><i class="text-darken-3 false fas fa-retweet"></i>@@btedPeople@@</div>
|
<div class="collapsible-header"><i class="text-darken-3 false fas fa-retweet"></i>@@btedPeople@@</div>
|
||||||
<div class="collapsible-body toot-reset" id="toot-rt"></div>
|
<div class="collapsible-body toot-reset" id="toot-rt"></div>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="edited-hide">
|
||||||
|
<div class="collapsible-header"><i class="material-icons">create</i>@@editHistory@@</div>
|
||||||
|
<div class="collapsible-body toot-reset" id="toot-edit"></div>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="dm-hide" style="max-width: 450px">
|
<div class="dm-hide" style="max-width: 450px">
|
||||||
@@useOtherAcct1@@(<i class="fas fa-retweet"></i>/<i class="fas fa-star"></i>@@useOtherAcct2@@)<br />
|
@@useOtherAcct1@@(<i class="fas fa-retweet"></i>/<i class="fas fa-star"></i>@@useOtherAcct2@@)<br />
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
"afterFTL": "Federated TL after this toot",
|
"afterFTL": "Federated TL after this toot",
|
||||||
"favedPeople": "People who favourited it",
|
"favedPeople": "People who favourited it",
|
||||||
"btedPeople": "People who boosted it",
|
"btedPeople": "People who boosted it",
|
||||||
|
"editHistory": "Edit history",
|
||||||
"useOtherAcct1": "Use other account",
|
"useOtherAcct1": "Use other account",
|
||||||
"useOtherAcct2": ":unfav and unBT are disabled.",
|
"useOtherAcct2": ":unfav and unBT are disabled.",
|
||||||
"btWithVis": "Boost with visibility",
|
"btWithVis": "Boost with visibility",
|
||||||
|
|
|
@ -63,6 +63,7 @@
|
||||||
"afterFTL": "これより後の連合TL(誰のトゥート言及してんねん)",
|
"afterFTL": "これより後の連合TL(誰のトゥート言及してんねん)",
|
||||||
"favedPeople": "誰がお気に入りに登録してるんや",
|
"favedPeople": "誰がお気に入りに登録してるんや",
|
||||||
"btedPeople": "誰がお気に入りブーストしたんや",
|
"btedPeople": "誰がお気に入りブーストしたんや",
|
||||||
|
"editHistory": "編集履歴",
|
||||||
"useOtherAcct1": "他のアカウント使う",
|
"useOtherAcct1": "他のアカウント使う",
|
||||||
"useOtherAcct2": "の解除はできひん",
|
"useOtherAcct2": "の解除はできひん",
|
||||||
"btWithVis": "公開範囲も決めてからブースト",
|
"btWithVis": "公開範囲も決めてからブースト",
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
"afterFTL": "これより後の連合TL(言及確認)",
|
"afterFTL": "これより後の連合TL(言及確認)",
|
||||||
"favedPeople": "このトゥートをお気に入りに登録した人",
|
"favedPeople": "このトゥートをお気に入りに登録した人",
|
||||||
"btedPeople": "このトゥートをブーストした人",
|
"btedPeople": "このトゥートをブーストした人",
|
||||||
|
"editHistory": "編集履歴",
|
||||||
"useOtherAcct1": "他のアカウントを使用",
|
"useOtherAcct1": "他のアカウントを使用",
|
||||||
"useOtherAcct2": "の解除はできません",
|
"useOtherAcct2": "の解除はできません",
|
||||||
"btWithVis": "公開範囲を指定してブースト",
|
"btWithVis": "公開範囲を指定してブースト",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user