Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
stickerpicker
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneurs
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
salixor
stickerpicker
Validations
05a6e046
Valider
05a6e046
rédigé
Il y a 4 ans
par
Tulir Asokan
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Only reload packs instead of whole page
parent
3045faae
Branches
Branches contenant la validation
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
web/index.js
+21
-8
21 ajouts, 8 suppressions
web/index.js
avec
21 ajouts
et
8 suppressions
web/index.js
+
21
−
8
Voir le fichier @
05a6e046
...
...
@@ -41,6 +41,7 @@ class App extends Component {
this
.
navRef
=
null
this
.
sendSticker
=
this
.
sendSticker
.
bind
(
this
)
this
.
navScroll
=
this
.
navScroll
.
bind
(
this
)
this
.
reloadPacks
=
this
.
reloadPacks
.
bind
(
this
)
}
_getStickersByID
(
ids
)
{
...
...
@@ -60,8 +61,16 @@ class App extends Component {
localStorage
.
mauFrequentlyUsedStickerCache
=
JSON
.
stringify
(
stickers
.
map
(
sticker
=>
[
sticker
.
id
,
sticker
]))
}
componentDidMount
()
{
fetch
(
`
${
PACKS_BASE_URL
}
/index.json`
).
then
(
async
indexRes
=>
{
reloadPacks
()
{
this
.
imageObserver
.
disconnect
()
this
.
sectionObserver
.
disconnect
()
this
.
setState
({
packs
:
[]
})
this
.
_loadPacks
(
true
)
}
_loadPacks
(
disableCache
=
false
)
{
const
cache
=
disableCache
?
"
no-cache
"
:
undefined
fetch
(
`
${
PACKS_BASE_URL
}
/index.json`
,
{
cache
}).
then
(
async
indexRes
=>
{
if
(
indexRes
.
status
>=
400
)
{
this
.
setState
({
loading
:
false
,
...
...
@@ -73,7 +82,7 @@ class App extends Component {
HOMESERVER_URL
=
indexData
.
homeserver_url
||
HOMESERVER_URL
// TODO only load pack metadata when scrolled into view?
for
(
const
packFile
of
indexData
.
packs
)
{
const
packRes
=
await
fetch
(
`
${
PACKS_BASE_URL
}
/
${
packFile
}
`
)
const
packRes
=
await
fetch
(
`
${
PACKS_BASE_URL
}
/
${
packFile
}
`
,
{
cache
}
)
const
packData
=
await
packRes
.
json
()
for
(
const
sticker
of
packData
.
stickers
)
{
this
.
stickersByID
.
set
(
sticker
.
id
,
sticker
)
...
...
@@ -85,7 +94,10 @@ class App extends Component {
}
this
.
updateFrequentlyUsed
()
},
error
=>
this
.
setState
({
loading
:
false
,
error
}))
}
componentDidMount
()
{
this
.
_loadPacks
()
this
.
imageObserver
=
new
IntersectionObserver
(
this
.
observeImageIntersections
,
{
rootMargin
:
"
100px
"
,
})
...
...
@@ -118,6 +130,9 @@ class App extends Component {
}
componentDidUpdate
()
{
if
(
this
.
packListRef
===
null
)
{
return
}
for
(
const
elem
of
this
.
packListRef
.
getElementsByClassName
(
"
sticker
"
))
{
this
.
imageObserver
.
observe
(
elem
)
}
...
...
@@ -163,19 +178,17 @@ class App extends Component {
<div class="pack-list
${
isMobileSafari
?
"
ios-safari-hack
"
:
""
}
" ref=
${
elem
=>
this
.
packListRef
=
elem
}
>
<
${
Pack
}
pack=
${
this
.
state
.
frequentlyUsed
}
send=
${
this
.
sendSticker
}
/>
${
this
.
state
.
packs
.
map
(
pack
=>
html
`<
${
Pack
}
id=
${
pack
.
id
}
pack=
${
pack
}
send=
${
this
.
sendSticker
}
/>`
)}
<
${
Settings
}
/>
<
${
Settings
}
app=
${
this
}
/>
</div>
</main>`
}
}
const
reload
=
()
=>
isMobileSafari
?
(
window
.
location
.
href
=
window
.
location
.
href
)
:
window
.
location
.
reload
()
const
Settings
=
()
=>
html
`
const
Settings
=
({
app
})
=>
html
`
<section class="stickerpack settings" id="pack-settings" data-pack-id="settings">
<h1>Settings</h1>
<div class="settings-list">
<button onClick=
${
reload
}
>Reload</button>
<button onClick=
${
app
.
reload
Packs
}
>Reload</button>
</div>
</section>
`
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter