mirror of
https://github.com/openvk/openvk
synced 2025-07-03 22:39:59 +03:00
feat(FeedIgnore): added js listner
This commit is contained in:
parent
67d8f4e351
commit
cb015a5710
1 changed files with 47 additions and 0 deletions
|
@ -43,6 +43,53 @@ u(document).on("click", "#__ignoreSomeone", async (e) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
u(document).on("click", "#__ignoreSomeoneFeed", async (e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
|
||||||
|
const TARGET = u(e.target)
|
||||||
|
const ENTITY_ID = Number(e.target.dataset.id)
|
||||||
|
const VAL = Number(e.target.dataset.val)
|
||||||
|
const ACT = VAL == 1 ? 'ignore' : 'unignore'
|
||||||
|
const METHOD_NAME = ACT == 'ignore' ? 'addBan' : 'deleteBan'
|
||||||
|
const PARAM_NAME = ENTITY_ID < 0 ? 'group_ids' : 'user_ids'
|
||||||
|
const ENTITY_NAME = ENTITY_ID < 0 ? 'club' : 'user'
|
||||||
|
const URL = `/method/newsfeed.${METHOD_NAME}?auth_mechanism=roaming&${PARAM_NAME}=${Math.abs(ENTITY_ID)}`
|
||||||
|
|
||||||
|
TARGET.closest('.post').addClass('lagged')
|
||||||
|
const REQ = await fetch(URL)
|
||||||
|
const RES = await REQ.json()
|
||||||
|
TARGET.closest('.post').removeClass('lagged')
|
||||||
|
|
||||||
|
if(RES.error_code) {
|
||||||
|
switch(RES.error_code) {
|
||||||
|
case -10:
|
||||||
|
fastError(';/')
|
||||||
|
break
|
||||||
|
case -50:
|
||||||
|
fastError(tr('ignored_sources_limit'))
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
fastError(res.error_msg)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if(RES.response == 1) {
|
||||||
|
if(ACT == 'unignore') {
|
||||||
|
TARGET.closest('.scroll_node').find('.post').removeClass('post-hidden');
|
||||||
|
TARGET.closest('.ignore-message').remove()
|
||||||
|
} else {
|
||||||
|
TARGET.closest('.post').addClass('post-hidden');
|
||||||
|
TARGET.closest('.scroll_node').append(`
|
||||||
|
<div class="ignore-message" width="100%">
|
||||||
|
${tr(`feed_${ENTITY_NAME}_ignored`)} <a id="__ignoreSomeoneFeed" data-val='0' data-id='${ENTITY_ID}' href="#">${tr('feed_unignore')}</a>
|
||||||
|
</div>
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
u(document).on('click', '#__feed_settings_link', (e) => {
|
u(document).on('click', '#__feed_settings_link', (e) => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue