Run a giveaway from a bsky post. Choose from those who interacted with it

Added Likes OR Reposts

Changed files
+21 -7
+21 -7
Index.html
··· 73 74 // Get option and ensure it's one of the valid options 75 let option = params.get('option') || 'likes'; 76 - if (option && !['likes', 'reposts', 'both'].includes(option)) { 77 - console.warn('Invalid option parameter. Must be "likes", "reposts", or "both".'); 78 option = 'likes'; 79 } 80 ··· 115 likes_only: true, 116 reposts_only: false, 117 likes_and_reposts: false, 118 119 error: '', 120 loading: false, ··· 141 this.likes_only = params.option === 'likes'; 142 this.reposts_only = params.option === 'reposts'; 143 this.likes_and_reposts = params.option === 'both'; 144 } 145 146 // Automatically run the giveaway if post_url is provided ··· 157 this.likes_only = targetId === 'likes'; 158 this.reposts_only = targetId === 'reposts_only'; 159 this.likes_and_reposts = targetId === 'likes_and_reposts'; 160 }, 161 async runGiveaway() { 162 this.error = ''; ··· 171 return; 172 } 173 174 - if (!this.likes_only && !this.reposts_only && !this.likes_and_reposts) { 175 this.error = 'Well, you have to pick some way for them to win'; 176 return; 177 } ··· 207 208 // Determine which collections to fetch based on user selection 209 const collections = []; 210 - if (this.likes_only || this.likes_and_reposts) { 211 collections.push(likesCollection); 212 } 213 - if (this.reposts_only || this.likes_and_reposts) { 214 collections.push(repostsCollection); 215 } 216 ··· 267 const repostsDids = results.filter(x => x.collection === repostsCollection).map(x => x.did); 268 uniqueDids = likesDids.filter(did => repostsDids.includes(did)); 269 } 270 271 this.participants = uniqueDids.length; 272 // Select winners ··· 359 id="likes_and_reposts" 360 type="checkbox" 361 class="checkbox"/> 362 - Likes & Reposts 363 </label> 364 365 </fieldset> ··· 397 <ul class="list-disc pl-5 mb-2"> 398 <li><code>post_url</code>: URL of the Bluesky post</li> 399 <li><code>winner_count</code>: Number of winners (default: 1)</li> 400 - <li><code>option</code>: 'likes', 'reposts', or 'both' (default: 'likes')</li> 401 </ul> 402 403 </div>
··· 73 74 // Get option and ensure it's one of the valid options 75 let option = params.get('option') || 'likes'; 76 + if (option && !['likes', 'reposts', 'both', 'or'].includes(option)) { 77 + console.warn('Invalid option parameter. Must be "likes", "reposts", "both", or "or".'); 78 option = 'likes'; 79 } 80 ··· 115 likes_only: true, 116 reposts_only: false, 117 likes_and_reposts: false, 118 + likes_or_reposts: false, 119 120 error: '', 121 loading: false, ··· 142 this.likes_only = params.option === 'likes'; 143 this.reposts_only = params.option === 'reposts'; 144 this.likes_and_reposts = params.option === 'both'; 145 + this.likes_or_reposts = params.option === 'or'; 146 } 147 148 // Automatically run the giveaway if post_url is provided ··· 159 this.likes_only = targetId === 'likes'; 160 this.reposts_only = targetId === 'reposts_only'; 161 this.likes_and_reposts = targetId === 'likes_and_reposts'; 162 + this.likes_or_reposts = targetId === 'likes_or_reposts'; 163 }, 164 async runGiveaway() { 165 this.error = ''; ··· 174 return; 175 } 176 177 + if (!this.likes_only && !this.reposts_only && !this.likes_and_reposts && !this.likes_or_reposts) { 178 this.error = 'Well, you have to pick some way for them to win'; 179 return; 180 } ··· 210 211 // Determine which collections to fetch based on user selection 212 const collections = []; 213 + if (this.likes_only || this.likes_and_reposts || this.likes_or_reposts) { 214 collections.push(likesCollection); 215 } 216 + if (this.reposts_only || this.likes_and_reposts || this.likes_or_reposts) { 217 collections.push(repostsCollection); 218 } 219 ··· 270 const repostsDids = results.filter(x => x.collection === repostsCollection).map(x => x.did); 271 uniqueDids = likesDids.filter(did => repostsDids.includes(did)); 272 } 273 + if (this.likes_or_reposts) { 274 + uniqueDids = [...new Set(results.map(x => x.did))]; 275 + } 276 277 this.participants = uniqueDids.length; 278 // Select winners ··· 365 id="likes_and_reposts" 366 type="checkbox" 367 class="checkbox"/> 368 + Both Likes & Reposts 369 + </label> 370 + 371 + <label class="label"> 372 + <input x-model="likes_or_reposts" x-on:change="validateCheckBoxes($event)" 373 + id="likes_or_reposts" 374 + type="checkbox" 375 + class="checkbox"/> 376 + Likes OR Reposts 377 </label> 378 379 </fieldset> ··· 411 <ul class="list-disc pl-5 mb-2"> 412 <li><code>post_url</code>: URL of the Bluesky post</li> 413 <li><code>winner_count</code>: Number of winners (default: 1)</li> 414 + <li><code>option</code>: 'likes', 'reposts', 'both', or 'or' (default: 'likes')</li> 415 </ul> 416 417 </div>