Fixed rank-locked emoticons.
This commit is contained in:
parent
9ba034cf42
commit
d084b838f5
5 changed files with 27 additions and 10 deletions
|
@ -8,6 +8,10 @@
|
|||
# Sets the title of the application, might be overridden for the window title by the common settings below once they're loaded
|
||||
#MAMI_TITLE="Flashii Chat"
|
||||
|
||||
# Flashii API base URL
|
||||
# Sets the base URL for Flashii API, without the version part!
|
||||
#MAMI_API_URL="//flashii.net/api"
|
||||
|
||||
# Common configuration location
|
||||
# Contains further information shared by the other chat client
|
||||
#FUTAMI_URL="//futami.flashii.net/common.json"
|
||||
|
|
1
build.js
1
build.js
|
@ -18,6 +18,7 @@ const exec = require('util').promisify(require('child_process').exec);
|
|||
html: { title },
|
||||
build: {
|
||||
FUTAMI_DEBUG: isDebug,
|
||||
FII_API: process.env.MAMI_API_URL ?? '//flashii.net/api',
|
||||
FUTAMI_URL: process.env.FUTAMI_URL ?? '//futami.flashii.net/common.json',
|
||||
AMI_URL: process.env.AMI_URL ?? '//sockchat.flashii.net',
|
||||
GIT_HASH: (await exec('git log --pretty="%H" -n1 HEAD')).stdout,
|
||||
|
|
|
@ -9,19 +9,31 @@ const MamiEmotes = (function() {
|
|||
emotes.push(emote);
|
||||
};
|
||||
|
||||
const load = function(batch) {
|
||||
for(const emote of batch)
|
||||
add(emote);
|
||||
};
|
||||
|
||||
return {
|
||||
clear: clear,
|
||||
add: add,
|
||||
load: function(batch) {
|
||||
for(const emote of batch)
|
||||
add(emote);
|
||||
clear,
|
||||
add,
|
||||
load,
|
||||
async loadUrl(url=null) {
|
||||
const { status, body } = await $xhr.get(
|
||||
url ?? `${FII_API}/v1/emotes?fields=url,strings,min_rank`,
|
||||
{ type: 'json' }
|
||||
);
|
||||
if(status !== 200)
|
||||
throw 'Could not load emoticons';
|
||||
|
||||
load(body);
|
||||
},
|
||||
forEach: function(minRank, callback) {
|
||||
forEach(minRank, callback) {
|
||||
for(const emote of emotes)
|
||||
if(!emote.min_rank || emote.min_rank <= minRank)
|
||||
callback(emote);
|
||||
},
|
||||
all: minRank => {
|
||||
all(minRank) {
|
||||
const items = [];
|
||||
for(const emote of emotes)
|
||||
if(!emote.min_rank || emote.min_rank <= minRank)
|
||||
|
@ -29,7 +41,7 @@ const MamiEmotes = (function() {
|
|||
|
||||
return items;
|
||||
},
|
||||
findByName: function(minRank, name, returnString) {
|
||||
findByName(minRank, name, returnString) {
|
||||
const found = [];
|
||||
for(const emote of emotes)
|
||||
if(!emote.min_rank || emote.min_rank <= minRank) {
|
||||
|
|
|
@ -222,7 +222,7 @@ const MamiInit = async args => {
|
|||
// loading these asynchronously makes them not show up in the backlog
|
||||
// revisit when emote reparsing is implemented
|
||||
try {
|
||||
MamiEmotes.load(await futami.getApiJson('/v1/emotes'));
|
||||
MamiEmotes.loadUrl();
|
||||
} catch(ex) {
|
||||
console.error('Failed to load emoticons.', ex);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ Umi.UI.Emoticons = (function() {
|
|||
Parse: function(element, author) {
|
||||
let inner = element.innerHTML;
|
||||
|
||||
MamiEmotes.forEach(author?.perms?.rank ?? 0, function(emote) {
|
||||
MamiEmotes.forEach(author?.rank ?? 0, function(emote) {
|
||||
const image = $element('img', { className: 'emoticon', src: emote.url });
|
||||
|
||||
for (const i in emote.strings) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue